[SOLVED] Rule with Number in Channel or Thing not triggered

If I bind a item to a channel or Thing which returns a number it works fine. The problem is, I habe to much log file entries. I would like to define a rule directly to the Channel or Thing. But there is no change recognized.

test.items:
Number:Angle Azimuth {channel=“astro:sun:local:position#azimuth” }
Number Brightness {channel=“homematic:HG-HM-Sen-MDIR-WM55:77553c53:OEQ0535505:3#BRIGHTNESS”}

test.rules:
rule “ItemA”
when
Item Azimuth changed
then
logInfo(“test.rules”, “this will work” )
end
rule “ItemB”
when
Item Brightness changed
then
logInfo(“test.rules”, “this will work” )
end

rule “ThingA”
when
Thing “homematic:HG-HM-Sen-MDIR-WM55:77553c53:OEQ0535505:3#BRIGHTNESS” changed
then
logInfo(“test.rules”, “this will NOT work” )
end

rule “ChannelB”
when
Channel “astro:sun:local:position#azimuth” triggered
then
logInfo(“test.rules”, “this will NOT work” )
end

I habe tried both as Channel and Thing. As I already have rules working with switches, which are not changing automatically, I assume it is about the Numbers. Any experience with rules regarding Number changes in conditions, addressed as Channel or Thing?

You cannot do that. Items are designed for that purpose.

Items represent functionality that is used by the application (mainly user interfaces or automation logic). Items have a state and are used through events.

from Items | openHAB

The Thing won’t change in normal use. It’s working or not working. A change in data it produces is the normal working of the Thing and does not change the Thing itself.

Channels come in state types and event types. Astro binding happens to have both. You can trigger rules from event channels, like “sun rise”. But you cannot trigger rules from state channels, like “06:30” (sunrise time).
Azimuth is a state channel and cannot be used for a rule trigger. You have to go the Item changed route.

You can control how often Astro updates azimuth.

2 Likes

Just to explain, why there are event channels:

When (for example) sunrise is happening, the corresponding channel is triggered. But unlike an item there won’t be a state for this channel. So this is why there are event channels.

2 Likes

I have thought so. Thank you for the explanation.