I have OpenHab1 running on a Raspberry Pi 2 along with MySensors configured hardware dotted around. They speak over a MQTT connection like normal, however i’m having a little issue with one of my nodes, well maybe two.
So i have a custom made light switch and a relay module with an on board button/switch. At the moment my initial thinking was to have the light switch send a message onto a MQTT topic that has a ‘number’ item assigned to it to either be on or off. Then i would have my relay as another item, but this is a ‘switch’ item that is either on or off.
The items are:
Number CinemaRoom_Switch01 "Light Switch [MAP(1on2off.map):%s]" <shield> (SF_CinemaRoom, gSwitch) {mqtt="<[mymosquitto:Gateway1-out/3/3/1/0/2:state:default]"} Switch CinemaRoom_Light01 "Ceiling Lights" <light> (SF_CinemaRoom, gLight) {mqtt=">[mymosquitto:Gateway1-in/4/1/1/0/2:command:ON:1],>[mymosquitto:Gateway1-in/4/1/1/0/2:command:OFF:0]"}
For this to work, the light switch sends a message on the topic that my relay is assigned to, it receives the message and activates. The rule for this is:
rule "Cinema Room Light Toggle" when Item CinemaRoom_Switch01 changed then if (CinemaRoom_Light01.state == ON){ sendCommand(CinemaRoom_Light01, OFF) } else { sendCommand(CinemaRoom_Light01, ON) } end
As you can see from the rules, i have it set up so that when it receives a message it then toggles the state of the relay, no matter what the current state is. However, this all becomes a mess when i use the on board switch on the relay. It works fine, however, when i come to use the light switch afterwards, the first press/toggle will not work. The second does and any after that does, until i then use the on board switch again. The web interface is acting exactly the same way as the light switch node does, this makes me think that maybe the relay output is not working with my way of configuration on OpenHab, I’m not sure if i need to change my rules config or the MySensors config to correct this.
I’m not 100% sure this is an issue with my OpenHab configuration, but we’re lost on the MySensors community regarding this and thought that maybe its my error with config on the OpenHab side maybe?
If the logs from the MySensors are any help to you, these are the logs from the gateway when it receives its messages from the nodes:
Light Switch Node:
0;0;3;0;9;read: 3-3-0 s=3,c=1,t=2,pt=2,l=2,sg=0:1 0;0;3;0;9;Sending message on topic: Gateway1-out/3/3/1/0/2 0;0;3;0;9;Message arrived on topic: Gateway1-in/4/1/1/0/2 0;0;3;0;9;send: 0-0-4-4 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:1
On board switch:
0;0;3;0;9;read: 4-4-0 s=1,c=1,t=2,pt=2,l=2,sg=0:1 0;0;3;0;9;send: 0-0-4-4 s=1,c=1,t=2,pt=2,l=2,sg=0,st=ok:1 0;0;3;0;9;Sending message on topic: Gateway1-out/4/1/1/0/2
OpenHab Web Interface:
0;0;3;0;9;Message arrived on topic: Gateway1-in/4/1/1/0/2 0;0;3;0;9;send: 0-0-4-4 s=1,c=1,t=2,pt=0,l=1,sg=0,st=ok:1