Hi,
I’m trying to use sunset events in OH2 as described here by @ThomDietrich. However, it is not working as intended.
house.sitemap
sitemap house label="House" {
Frame label="States" {
Text item=NightState label="Night" icon="moon"
}
Frame label="Times" {
Text item=SunElevation label="Sun Elevation" icon="sun"
Text item=SunriseTime label="Sunrise" icon="sunrise"
Text item=SunsetTime label="Sunset" icon="sunset"
}
}
astro.items
Group Astro
DateTime SunsetTime "Sunset [%1$tH:%1$tM]" <sunset> (Astro) { channel="astro:sun:local:set#start" }
DateTime SunriseTime "Sunrise [%1$tH:%1$tM]" <sunries> (Astro) { channel="astro:sun:local:rise#end" }
Number SunElevation "Elevation [%.1f °]" <sun> (Astro) { channel="astro:sun:local:position#elevation" }
Switch NightState "Night" <moon> (Astro)
astro.rules
rule "Update NightState"
when
Item SunElevation changed
then
if(SunElevation.state > 0){
// if(NightState.state != OFF) postUpdate(NightState, OFF)
postUpdate(NightState, OFF)
} else {
// if(NightState.state != ON) postUpdate(NightState, ON)
postUpdate(NightState, ON)
}
end
rule "Night has started"
when
Item NightState received update ON
then
sendCommand(Light1, ON)
end
rule "Night has ended"
when
Item NightState received update OFF
then
sendCommand(Light1, OFF)
end
Obviously, I’m excluding some parts of my sitemap and items for this example. I’m using the UPB binding, and it’s working 100% fine. I’m also aware of #640, which I have been experiencing.
The issue is that NightState
does not keep its state. If I am rapidly reloading the page, whenever the elevation changes but before BasicUI “reformats” or whatever, it will show ON or OFF, but after that it just goes blank. HABmin says that it is set to NULL
or ON
seemingly depending on what mood it’s in. However, HABmin never formats the times or elevation (is that related)? I can never see the state in ClassicUI. My events to turn on or off Light1
never seem to fire.
It seems that something is happening with the UIs format the state. I can see the state (sometimes) in HABmin, and it never touches the times or elevation formatting. However, ClassicUI and BasicUI seem like they’re looking for a format, and when they don’t find one, they just show it as blank.
What’s going on?