[SOLVED] Is event from physical device or openhab

  • Platform information:

    • Hardware: RPI3
    • OS: Linux openhab 4.19.66-v7+ Raspbian GNU/Linux 9
    • Java Runtime Environment: OpenJDK 1.8.0_152
    • openHAB version: openHAB 2.5.0~M4-1
  • Issue of the topic:
    Is there a way to se if an event change is based from the actual physical device or if it comes from openhab/node-red/basicui.

Item <item> received command [<command>]
Item <item> received update [<state>]
Item <item> changed [from <state>] [to <state>]
  • Example:
    I have multiple rules that controls the house based on time, lux, presence. Sometimes I manually trigger a wall switch (zwave) that changes the ceiling light. Now the ceiling is lit but the other ‘house’ rules will turn it off again.

I would like to know where the ‘change event’ is originated from. This would e.g. allow me to set a timeout trigger to ‘do not change this light in x time from auto rule set’. Or ‘turn off full automation mode for this device until house mode is changed’ in the rest of my setup.

  • Suggestion:
    Have an origin property with the value from who is changing the value.
rule "Change walltrigger"
when
    Item MyDevice received update
then
   if ( MyDevice.origin == "zwave:device:3ae30707:node20" ) {
      // from actual device
   } else if ( MyDevice.origin == "node-red" ) {
       // from node-red
   } else if ( MyDevice.origin == "paperui" ) {
       // from paperui
   } else {
      // external source that is not mapped correctly yet
   }
end
1 Like

I don’t really understand your point.
You know and have configured all of your items, so you know which device (and channel, i.e. functionality) an item translates to, don’t you ?

If you carefully read the docs, there’s quite a number of triggers available on things, channels etc, too.

I understand the issue.

At the simplest, if a remote device reports a change of state shortly after a command, you might consider that to an “openHAB originated event”.
If a device reports a change of state unexpectedly, you might call that a “manual originated event” - someone pressed a button.

There are variables - how long is that “soon after”? 10mS? 100? ten seconds? Depends on tech and devices and installation.
There are exceptions to deal with - what should happen if an issued command results in no change? Is that a problem to be highlighted? Or was the device just already in the required state?
What about if a device reports a stream of changes in response to a command - roller position, say?

There are ways to do all this in the existing rule system. It’s unlikely that a one-size-fits-all solution is practical in openHAB’s huge world of “devices”. There might be features that could be added to make it easier to implement.

Maybe only me having these issue due to over complexed logic that makes basically not using any manually adjusting of my home :crazy_face:

thanks @rossko57 for clarification. Would be nice in future to have that extra data of what system originated the call. To simplify maybe openhab can’t get the unique device id but instead the id of zwave hub, zigbee hub, mqtt, openhab and so on that told openhab to do something. In the future :slight_smile:

To solve this now I’m probably are going to do something like this. Not perfect but should help with device from different hubs.

  1. set a ‘flag’ when my ‘house logic’ are manipulating values.
  2. when ‘house logic’ changes devices, before setting value it checks if ‘device last timetamp < x time I want to ignore’.
  3. delay x seconds to remove the flag

  1. when a device is changed, check 'if not house logic running then ‘save device time timestamp’

I think it’s a very useful feature to have in your system - put the users in control.

Stop turning that bloody light on for 20 seconds every time I walk through the hall - just press the off wall switch.
Behind the scenes, openHAB notes the “manual override” and stops making auto actions for some time - a few hours, or until next time the house is empty, etc.

I think your issue is addressed in this DP:

Approach 3 is what I’m after. If the origin value would have solved this easy. But code workarounds will solve the problem I want to solve. Cheers

Your “origin” idea is difficult to implement, if you think about it. It would require the device itself to report “who asked for what I just did” when reporting an event. Many devices won’t even know.

It’s not the origins or source of the command that you are actually interested in.

It’s the previous origins of an event that is now being reported, when we (openHAB) are not aware of everything that might have caused it.

So we have to make best guesses and assumptions, tailored to the particular situation.

For zwave devices that have SCENE_ACTIVATION, the scene_number Channel is updated after the device is manually controlled. This can be used to activate/deactivate automation for those devices.

2 Likes

@rossko57 don’t know about the backbone of OpenHAB, but the brief idea would be when openhab gets a call to do something with e.g, Item/Thing. Add the external source tag. Would that be an zwave usbstick, mqtt broker, gui. Not the actual device call itself. It just getting tagged with more metadata when piped thru openhab.

But as I said, do not know about the structure of OpenHAB. I’m usually just simplifying stuff when architecting systems :smiley:

Then get to know it before trying to be cleverer than the OH architects, else things won’t work out in the long run.
OH is event driven, the message bus is the backbone. OH does not get any calls. UI actions as well as devices create events, and all you can and should do is to create rules to trigger upon events.

Those rules can of course choose to “remember” what happened, storing in variable, Item, or database. That’s not a property of the target Item/device.