Switch changed without trigger

Hi,

I have been working with openhab for about two months now and am really happy with it. However there is one tiny problem. I have a switch for the status of the alarm functions. There are only two rules triggering this switch OFF to ON or the other way around. Not much source for errors.

However only this switch (and no other) sometimes and out of the blue changes states.

The log appears as follows…

2020-06-15 21:00:36.414 [ome.event.ItemCommandEvent] - Item ‘Alarm_state’ received command OFF

2020-06-15 21:00:36.424 [vent.ItemStateChangedEvent] - Alarm_state changed from ON to OFF

Any clue where this command could be coming from? Before and after that log entry there is nothing else that would relate to the two rules that would be legitimate to change status of this switch. Also nothing else that those rules would usually trigger at the same time happens. Just this stupid switch flips.

Thanks for any advice.

You haven’t offered us many possibilities to work with, so let’s see if we can’t come up with pointers for further scrutiny.
A command to an Item has definitely come from a source. It’s not something that is a (direct) consequence of a spurious re-initialialization or suchlike.

So, generally, commands come from UIs. Seems unlikely you wouldn’t be aware of someone else clicking, but give it some thought.

Commands can be issued by rules. Can we see your relevant rules? Most likely this is where we should be looking.

Exceptionally, commands can come from bindings (instead of the usual state update) when configured that ay. Is your Item linked to any bindings? Config, if so?

Further background interest, time of day pattern? Other activity at the time? eg. sunset lighting, home/away transitions etc.

Hi,

first of all thanks for picking up my topic and for forgiving a newcomer in not providing adequate documentation.

These are the only rules containing a sendcommand for the Switch (shortened by a list of lamps that would be switched on and off at the same time):

rule “Zuhause”
when
Item Home_Modus received update “Zuhause”
then
Alarm_state.sendCommand(OFF)
Dunst_SWITCH.sendCommand(ON)

end

rule “HomeAway”
when
Item Home_Modus received update “HomeAway”
then
Flur_SWITCH.sendCommand(OFF)
createTimer(now.plusSeconds(30))[|
if (Home_Modus.state == “HomeAway”)
{Alarm_state.sendCommand(ON)}

end

The only other point where it appears is rules that use the item state as an if condition like
if (Alarm_state.state == ON)

There is no visible pattern. I once had it switch on several times in a row while everyone was at home and no apparent trigger was set. Today it switched off before anyone returned home. No date / time relation.

I haven’t knowingly linked it to any binding. It’s just a manual switch on my items list configured as:
Switch Alarm_state “Alarm Status [%s]”

I was suspecting the UI before and moved the switch in the sitemap (which is the only place that could trigger it except the rule) down into a sub directory so that no one could accidently click it. Even added a mapping (creating two buttons ON and OFF) to avoid the normal toggle which I found too easy to accidentally click.

Still the UI to me is the most likely cause of error. But the only two persons with the APP on their phones were sitting in a restaurant at the same time, not touching the cellphones. No other browser in use.

If it is the UI then it would explain why no other command is sent which would normally be sent by the two rules that containt the command. The UI is the only point that could trigger just this switch without anything else happening in context.

It would be cool if somehow the log could report the triggers.

That really leaps out at me, given your unexpected command was at 21:00:36 i.e. a 21:00 event plus a 30-sec timer.

Okay, so let’s be sure this rule is a culprit

...
createTimer(now.plusSeconds(30))[|
   if (Home_Modus.state == “HomeAway”) {
      logInfo("HomeAwayRule", "timer commanding ON")
      Alarm_state.sendCommand(ON)
   }

I think you need to think about how the rule gets triggered.
Note, that an update trigger will trigger on every update, i.e. in this case if anyone posts “HomeAway” to your Item, the rule will run even if the Item was already “HomeAway”
Updates to same value are not normally logged, so there will be no trace in your events.log

You ought to put confirmation in your other suspect rule too

rule “Zuhause”
when
   Item Home_Modus received update “Zuhause”
then
   logInfo("ZuHauseRule", "rule commanding OFF")
   ...
1 Like

Thanks for the advice. I have implemented the loginfo. Now we’ll have to wait for a couple of days until the next time the error occurs. I will post an update then.

I have also implemented a notification now that will send a push message every time the alarm mode is changed in contradiction to the Home_Modus. It may help finding the cause quicker.

However the idea that an Update is not logged may not be the explanation because in the case of alarm switching off it would have required the Home_Modus.state to change from where it was set when the errot happened to trigger the alarm off rule.

So… it happened again. There is only ONE rule left that contains Alarm_state.sendCommand(ON) and it is perfectly equipped with the loginfo line that you suggested. It also writes the loginfo every time the rule is executed.

However… THIS happened again today:

2020-06-23 09:06:46.884 [vent.ItemStateChangedEvent] - Bewegungssensoren_Alarm_count_item changed from 0 to 1
2020-06-23 09:06:54.421 [vent.ItemStateChangedEvent] - Sensor_Bad_TEMP changed from 22.61 to 22.95
2020-06-23 09:07:41.209 [vent.ItemStateChangedEvent] - Sensor_Haustuer_LINK changed from 36 to 44
2020-06-23 09:07:41.220 [vent.ItemStateChangedEvent] - Sensor_Haustuer_TEMP changed from 21.9 to 21.97
2020-06-23 09:07:48.223 [ome.event.ItemCommandEvent] - Item ‘Alarm_state’ received command ON
2020-06-23 09:07:48.232 [vent.ItemStateChangedEvent] - Alarm_state changed from OFF to ON

The rule is untouched for sure and the Alarm switches out of nowhere.

I think the only explanation left is the UI or the App. Any suggestions?

I may just have found the solution… I had tasker integration switched on in the APP. I think switching it off may just have solved the problem. Let’s give it some time to check…