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 -
DHT22 wrong sensor type in Home Assistant
Troubleshooting ā¢ 4 days ago ā¢ Commodoreuno a day ago -
Forum Search not working?
Troubleshooting ā¢ 4 Oct 2023, 23:33 ā¢ Gibber 2 Sept 2024, 20:28 -
Can not compile MySensors on esp8266
Troubleshooting ā¢ 24 Aug 2024, 15:35 ā¢ TheoL 29 Aug 2024, 20:47 -
JSN-SR04T-V3.0 Coax cable extended
Troubleshooting ā¢ 26 days ago ā¢ bocalexandru 24 days ago -
Echo request is not set
Troubleshooting ā¢ 12 Aug 2024, 15:36 ā¢ kamilb85 3 Sept 2024, 08:58