How to get relay state?
-
repeater started, id 100
send: 100-100-0-0 s=255,c=0,t=18,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=255,c=3,t=6,pt=1,l=1,st=ok:0
send: 100-100-0-0 s=255,c=3,t=11,pt=0,l=5,st=ok:Relay
send: 100-100-0-0 s=255,c=3,t=12,pt=0,l=3,st=ok:1.0
send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1I have 3 relays and i want to make a logic something like this; if 3.relay is on than 1. relay is off
How can i get relay status in orginal sketch?
"
void incomingMessage(const MyMessage &message) {
// We only expect one type of message from controller. But we better check anyway.
if (message.type==V_LIGHT) {
// Change relay state
digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
// Store state in eeprom
gw.saveState(message.sensor, message.getBool());
// Write some debug info
Serial.print("Incoming change for sensor:");
Serial.print(message.sensor);
Serial.print(", New status: ");
Serial.println(message.getBool());
}
"
-
On http://www.mysensors.org/build/relay you will find apart from the Relay also a RelayWithButtonActuator Example.
Do you have some kind of feedback from the relay indicating it's status? If so, connect that to the button input and done!
-
@daulagari Thank you. i am trying to learn "message.xxxxx" but it is hard for me.
How can i get 1-2-3 variables from "message.xxxxx"? So i can find which relay get a command.
send: 100-100-0-0 s=1,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=2,c=0,t=3,pt=0,l=5,st=ok:1.4.1
send: 100-100-0-0 s=3,c=0,t=3,pt=0,l=5,st=ok:1.4.1http://www.mysensors.org/build/sensor_api#the-full-api this link is very useful but very hard for me...
+++ i have some trouble with your link ; http://forum.mysensors.org/topic/738/relaywithbuttonactuator-example-with-touch-sensor/7
-
-
@BulldogLowell That's it! Thank you
if (message.sensor==1 && message.getBool()==true)
{....
Suggested Topics
-
Day 1 - Status report
Announcements • 23 Mar 2014, 22:45 • hek 24 Mar 2014, 20:12 -
NODs stop responding, but ping works.
Troubleshooting • 8 Mar 2025, 19:47 • Marcin 8 Mar 2025, 19:47 -
Getting system time from the controller
Troubleshooting • 27 Feb 2025, 01:39 • dpcons 3 Mar 2025, 01:00 -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting • 26 Feb 2025, 00:32 • dpcons 26 Feb 2025, 06:22 -
Echo request is not set
Troubleshooting • 12 Aug 2024, 15:36 • kamilb85 3 Sept 2024, 08:58 -
DHT22 wrong sensor type in Home Assistant
Troubleshooting • 19 days ago • Commodoreuno 13 days ago