Adding Multiple Relay to Home Assistant
-
Hello
In struggling with adding more relays to Home assistant, till now only this sketch was working.
but wit it I can add only 1 Relay, pleas help me to add more relays/*
- Documentation: http://www.mysensors.org
- Support Forum: http://forum.mysensors.org
- http://www.mysensors.org/build/relay
*/
#include <MySensor.h>
#include <SPI.h>#define SN "Relay"
#define SV "1.0"
#define CHILD_ID 1
#define RELAY_PIN 3MySensor gw;
MyMessage msgRelay(CHILD_ID, V_STATUS);void setup()
{
gw.begin(incomingMessage);
gw.sendSketchInfo(SN, SV);
// Initialize the digital pin as an output.
pinMode(RELAY_PIN, OUTPUT);
gw.present(CHILD_ID, S_BINARY);
gw.send(msgRelay.set(0));
}void loop()
{
gw.process();
}void incomingMessage(const MyMessage &message)
{
if (message.type == V_STATUS) {
// Change relay state.
digitalWrite(RELAY_PIN, message.getBool() ? 1 : 0);
gw.send(msgRelay.set(message.getBool() ? 1 : 0));
}
}
Suggested Topics
-
Forum Theme Problems
Announcements • 8 Apr 2014, 07:05 • hek 8 Apr 2014, 07:05 -
Node 2 is unknown warning in Homeassistant.
Home Assistant • 10 Mar 2019, 19:27 • badisensors 15 Oct 2024, 20:33 -
Where to change settings?
Home Assistant • 15 Mar 2023, 14:58 • eiten 25 Jul 2024, 19:19 -
2x BME 280 on 2x arduino nano hangs in HomeAssistant
Home Assistant • 27 Jul 2024, 12:25 • HJ_SK 11 Aug 2024, 19:56 -
HVAC type sensor in homeassistant
Home Assistant • 17 Aug 2024, 10:50 • tbowmo 17 Aug 2024, 20:51 -
Home Assistant update changed USB port name
Home Assistant • 14 Jan 2024, 17:25 • therik 15 Jan 2024, 10:26