Simple rule for sonoff switch is not triggered

I have added a new Sonoff POW switch (with current Tasmota firmware) to my openHAB installation. Basic MQTT messaging is working fine.

This is my item definition:

Group group_sonoff
Switch sonoff_Test "Sonoff Test" (group_sonoff) { mqtt=">[mosquitto:sonoff_test/cmnd/POWER:command:*:default], <[mosquitto:sonoff_test/stat/POWER:state:default]" }

I’ve added the Sonoff switch to my sitemap and can toggle it without problems and see the result in my events.log file. These events are also logged when I manually trigger the switch with the button on the Sonoff.

2018-02-05 11:02:45.815 [vent.ItemStateChangedEvent] - sonoff_Test changed from OFF to ON
2018-02-05 11:03:53.565 [vent.ItemStateChangedEvent] - sonoff_Test changed from ON to OFF

However, this simple rule never seems to be triggered:

rule "Sonoff Test"
when
    Item sonoff_Test changed from OFF to ON or Item sonoff_Test changed from ON to OFF
then
    logInfo("sonoff.rules", "sonoff_Test changed")
end

I have also tried the triggers “Item sonoff_Test changed” and “Item sonoff_Test received update” without success. No errors where logged with any of the triggers, but the log-action itself was never executed.

Any ideas? Thanks you!

have you modified the default logging options? (for eclipse.smarthome.model.script.xxxx that goes into openhab.log)

Your rule looks ok… it should fire with when Item sonoff_Test changed

I have another rule which includes a very similar logInfo call (other texts of course).This log ends up in my events.log file, so I assume that default logging options are not the problem.

logInfo(“…”) should go into openhab.log
in events.log you will see the state change event
try another name for the rule
also, try to avoid the dot for the first part of the logInfo statement (change sonoff.rules to sonoff_rules to see if this helps)

Arrrg, I found the problem :persevere:
It was a simple uppercase/lowercase typo in the name of the item. Now it all works fine and the log does indeed end up in openhab.log. Thank you for your help!

1 Like