rule "set number_openhab2operatingmodus sunrise"
when
Channel "astro:sun:astro_sun_smarthome:rise#event" triggered START
then
if ((number_openhab2operatingmodus.state as Number) > 0){
number_openhab2operatingmodus.postUpdate(3)
logInfo("set number_openhab2operatingmodus sunrise", number_openhab2operatingmodus.state.toString())
}
end
rule "set number_openhab2operatingmodus day"
when
Channel "astro:sun:astro_sun_smarthome:rise#event" triggered END
then
if ((number_openhab2operatingmodus.state as Number) > 0){
number_openhab2operatingmodus.postUpdate(1)
logInfo("set number_openhab2operatingmodus day", number_openhab2operatingmodus.state.toString())
}
end
rule "set number_openhab2operatingmodus sunset"
when
Channel "astro:sun:astro_sun_smarthome:set#event" triggered START
then
if ((number_openhab2operatingmodus.state as Number) > 0){
number_openhab2operatingmodus.postUpdate(4)
logInfo("set number_openhab2operatingmodus sunset", number_openhab2operatingmodus.state.toString())
}
end
rule "set number_openhab2operatingmodus night"
when
Channel "astro:sun:astro_sun_smarthome:set#event" triggered END
then
if ((number_openhab2operatingmodus.state as Number) > 0){
number_openhab2operatingmodus.postUpdate(2)
logInfo("set number_openhab2operatingmodus night", number_openhab2operatingmodus.state.toString())
}
end
You have defined two Things, but have you also defined the channels? Because that is what you are waiting for, for the Event Channel to trigger a START or END.
Please see the examples here:
Next point, in general, are you always sure the rule isn’t triggered? It might also be related to your if statement.
So could you add a logInfo() directly after each then?
rule "Set switch_systeminit"
when
System started
then
switch_systeminit.postUpdate(OFF)
createTimer(now.plusSeconds(10), [ | switch_systeminit.postUpdate(ON) ])
number_openhab2operatingmodus.postUpdate(1)
logInfo("Set switch_systeminit", switch_systeminit.state.toString())
end
and i tested the rule with a switch before used the event
That channel definition gives you "astro:sun:astro_sun_smarthome:rise#start", not "astro:sun:astro_sun_smarthome:rise#event".
And importantly, the former is not an event that will trigger a START or END
Just kidding, you can trigger the START and END manually via the console/Karaf:
smarthome:things trigger astro:sun:astro_sun_smarthome:rise#event START
smarthome:things trigger astro:sun:astro_sun_smarthome:rise#event END