- Platform information:
- Hardware: Raspberry Pi 3
- OS: Raspbian 9 (stretch)
- Java Runtime Environment: openjdk version “1.8.0_232”
OpenJDK Runtime Environment (build 1.8.0_232-8u232-b09-1~deb9u1-b09)
OpenJDK Client VM (build 25.232-b09, mixed mode) - openHAB version: 2.5.0~S1742-1
I am trying to do something very basic. Using a PIR I am activating a light using Sonoff Mini and deactivating after 10 seconds. So that’s working without any problems.
Now, what I want to do is to ONLY turn “ON and OFF” the light if the state is OFF or NULL.
So for that I have this rule:
val actions = getActions("mqtt","mqtt:systemBroker:embedded-mqtt-broker")
rule "Sensor Luz Entrada"
when
Item Sensor433mhz changed
then
switch Sensor433mhz.state {
case "79E006": {
actions.publishMQTT("cmnd/LuzEntradaFrente/POWER", "ON")
Thread::sleep(10000)
actions.publishMQTT("cmnd/LuzEntradaFrente/POWER", "OFF")
}
}
if(Sensor433mhz.state.toString !="") {
Thread::sleep(500)
Sensor433mhz.postUpdate("")
}
end
And to make it work as I wanted, I added this condition right after getting inside case:
if (LuzEntradaFrente.state == OFF || LuzEntradaFrente.state == NULL) { ...
Problem is, it did not worked.
On my .items file I have this:
Switch Luz_Entrada_Frente "Luz Entrada Frente" <light> (iluminacao) ["Lighting"] { mqtt=">[embedded-mqtt-broker:cmnd/LuzEntradaFrente/POWER:command:ON:1],
>[embedded-mqtt-broker:cmnd/LuzEntradaFrente/POWER:command:OFF:0],
<[embedded-mqtt-broker:stat/LuzEntradaFrente/POWER:state:default]"}
I don’t know if somehow this is related with my problem or not, but I cannot have state updated on the APP nor online in Paper UI whenever I press the button manually on my Sonoff Mini.
Can someone help me out here?
Thanks!
EDIT
I am now able to update in realtime my manual switches. So if I click a Sonoff (or a switch connected to it) I immediately see OH updated with it. These are my configurations in Paper UI to achieve that:
Then I already tried in my rule to use this:
var LEF = LuzEntradaFrente.state.toString
Also tried directly here:
if (LuzEntradaFrente.state.toString == "OFF" || LuzEntradaFrente.state.toString == "NULL" || LuzEntradaFrente.state.toString == NULL) { ...
Still nothing…