[How to] Item <item> changed [to <state>]

Hi,
I’m currently working on a shutter rule,closing the shutters with the moving sun. Therefore I would like to use the sun azimuth value from the astro binding.

First thing I thought about was the rule trigger:

Item <item> changed [from <state>] [to <state>]

and use the “to” state only. Unfortunately the azimuth is presented as float, and so I did not find a way to trigger with eg. “larger than 110 degree”.

Is there a way to handle this problem in the rule trigger or do I have to use “received update” and handle everything else in the rule?

Regards
Peter

  • Platform information:
    • Hardware: Intel
    • OS: Debian 9
    • openHAB version: 2.3.0
  • Issue of the topic: please be detailed explaining your issue

Correct, you can’t do greater than/less than comparisons in a trigger. You’ll have to use IF/ELSE in the rule itself!

You would do something like this

rule "azimuth changes"

Item azimuth changed

then
  val = degrees = (azimuth.state) as Number;
  [...] do your thing [...]
end


Best you use changed for Azimuth.

Hi,
had prefered another answer but thanks a lot for your information.

Regards
Peter