Yes, that’s correct. The POWER1 and POWER2 channels just send it plain text, not JSON, so you can get rid of the transformationPattern lines completely!
Confused yet?!
Yes, that’s correct. The POWER1 and POWER2 channels just send it plain text, not JSON, so you can get rid of the transformationPattern lines completely!
Confused yet?!
Confused yet?!
Haha, absolutely!! So sorry to put you through this
No problem - this is good practice for me too!!
Right, so the 2 channels are now switching my switch items without errors…result!!!
Now, this switch switches an item called Porch_CH1, I have a rule that uses that switch to change the state of my Hue bulb item (currently Light_FF_Landing_Ceiling)
rule "Porch Light Changes State"
when
Item Porch_CH1 changed
then
if(Porch_CH1.state == ON) {
sendCommand(Light_FF_Landing_Ceiling, ON)
}
else if(Porch_CH1.state == OFF) {
sendCommand(Light_FF_Landing_Ceiling, OFF)
}
end
So far so good, however I would like the state of the switch to update with the state of the Hue bulb. I tried the following rule, but it doesn’t switch the state of the switch…
rule "Porch Light Change Switch State"
when
Item Light_FF_Landing_Ceiling changed
then
if(Light_FF_Landing_Ceiling.state == ON) {
sendCommand(Porch_CH1, ON)
}
else if(Light_FF_Landing_Ceiling.state == OFF) {
sendCommand(Porch_CH1, OFF)
}
end
I’m probably looking at it the wrong way, and need to do something fancy with MQTT?
At the moment my item definition is simple:
Switch Porch_CH1
Should it be something like this:
Switch Porch_CH1 "Porch Switch Ch1" { channel="mqtt:topic:Porch:switch" }
EDIT: - This worked!!
Good work!
You shouldn’t need that second rule, however. Because you’re subscribed to the two POWER stat
topics, and you’ve now coupled them to your items, openHAB should take care of the switch state automatically!
I tried it without and it didn’t update the switch…also, I needed to reverse the states, so the LED in the switch was ON when the light was OFF…so I’ve ended up with:
rule "Porch Light CH1 Changes State"
when
Item Porch_CH1 changed
then
if(Porch_CH1.state == ON) {
sendCommand(Light_FF_Landing_Ceiling, OFF)
}
else if(Porch_CH1.state == OFF) {
sendCommand(Light_FF_Landing_Ceiling, ON)
}
end
rule "Porch Light Change Switch State"
when
Item Light_FF_Landing_Ceiling changed
then
if(Light_FF_Landing_Ceiling.state == ON) {
sendCommand(Porch_CH1, OFF)
}
else if(Light_FF_Landing_Ceiling.state == OFF) {
sendCommand(Porch_CH1, ON)
}
end
rule "Porch Light CH2 Changes State"
when
Item Porch_CH2 changed
then
if(Porch_CH2.state == ON) {
sendCommand(Light_FF_Daughter_Ceiling, OFF)
}
else if(Porch_CH2.state == OFF) {
sendCommand(Light_FF_Daughter_Ceiling, ON)
}
end
rule "Porch Light Change Switch State"
when
Item Light_FF_Daughter_Ceiling changed
then
if(Light_FF_Daughter_Ceiling.state == ON) {
sendCommand(Porch_CH2, OFF)
}
else if(Light_FF_Daughter_Ceiling.state == OFF) {
sendCommand(Porch_CH2, ON)
}
end
I would like to say a big thank you for your help!!!
It should be said that I’ve found the Openhab community to be the most helpful and patient that I’ve encountered on forums I’ve been in
It’s too little too late, but Tasmota has a flag you can enable to cause it to use the Home Assistant standard for topics. openHAB can automatically discover devices that use that standard, creating the Things for you.
But where’s the fun in that…!