Items - determine source of change (binding, internal, button...)


is there a possibility to get the source of change of a item in a rule?

e.g. is the rollershutter item changed by binding (push button at the wall …)
or by a OH internal rule or by a button of the item in sitemap or …

There are a lot of switches to bindings there are “manually” reachable, too.
In most cases I want to override the automatic control for these switches for a certain time, if the item was manually changed.
Without knowing the source, this works actually fine for me. With additional local items for auto active/deactive for each switch and as a release for the automatic rules. Controlled by 2 rules to get timestamps for last change and reset the auto switches after x minutes/hours. But every change of other rules that affects the item sets the auto to off…

For this case I need a possibility to decide: is the change caused by a “person” or automatic.
(assume that the binding has no other “intelligent” controls)

Do you have any ideas?


I’ve solved this for my lighting by creating a “WhoCalled” Item. When a rule fires it sets WhoCalled to something like “RULE”, executes the rule, then sets it back to “MANUAL”. Then I have another rule which triggers on changes to those switches. This rule can then determine who triggered the switch and take action accordingly. In my case it overrides one of the rules. You can see my example here.

1 Like

Great, it’s a good idea.
But a lot of work ;-(
(I started this implementation for some switches (for each it’s own automatic observer), but you can do a lot of mistakes, by forgetting some rules those touch the sepcific item…)

I’m looking for a simpler way, like

Item NameofLightSwitch(or group) changed _internal_
Item NameofLightSwitch(or group) changed _external_
Item NameofLightSwitch(or group) changed _buttonInSitemap_

That means external for a change from outside of the event bus -> binding
or internal by changes of OH or caused by a direct button for the item in sitemap.

Can you imagine there is a possibility to get this?
As a feature request or something?

You can probably greatly reduce the amount of work if you combine things using Groups and process based on that. For example, all of my lighting is run off of three rules (not counting the rules to set a time of day state) and behavior is controlled by Groups.

The event bus does not preserve the origin of the events that are placed on it, by design I think. Providing that simple amount of labeling would actually be pretty challenging as it would require a major overhaul of the event bus logic I suspect.

And, now that I’ve thought about it a bit I’m not sure it would save you any work in most cases.

You want to know whether a switch was triggered from the UI, from a rule, or externally to OH. If you have a device that reports external changes how do you handle this case: you switch a light from the UI which changes the state of the switch Item (sitemap). This gets sent to the binding which goes out to the device and turns on the light. The device then reports its new state back to the binding and the new state gets put on the event bus (external). In this case you only want to process the sitemap event so you need to add logic to ignore this particular external event as redundant. But you can’t ignore all external events because someone may physically flip the switch. You still have to add the logic to keep track so you haven’t saved any work.

You can head over to the Eclipse SmartHome project and post is as a topic for discussion there. If anything were to be implemented that is where it would take place. Development on core OH 1 is frozen.