I am using Philips hue v1. hub. When I send a message to MQTT broker (hosted on the same server as openhab2) it sometimes takes 5 seconds to react. Sometimes means every morning, so lights were not used overnight and also Openhab server restart at the night.
The first light switch press has 5 second delay and the next one goes fast. Please see logs:
2019-01-13 10:02:55.097 [ome.event.ItemCommandEvent] - Item ‘Toilet_Light_Toggle’ received command TOGGLE
2019-01-13 10:02:55.119 [vent.ItemStateChangedEvent] - Toilet_Light_Toggle changed from NULL to TOGGLE
2019-01-13 10:03:00.599 [ome.event.ItemCommandEvent] - Item ‘Toilet_Light’ received command ON
2019-01-13 10:03:00.606 [vent.ItemStateChangedEvent] - Toilet_Light changed from OFF to ON
2019-01-13 10:03:00.609 [GroupItemStateChangedEvent] - gLight changed from OFF to ON through Toilet_Light
2019-01-13 10:03:02.818 [ome.event.ItemCommandEvent] - Item ‘Toilet_Light_Toggle’ received command TOGGLE
2019-01-13 10:03:02.838 [ome.event.ItemCommandEvent] - Item ‘Toilet_Light’ received command OFF
2019-01-13 10:03:02.849 [vent.ItemStateChangedEvent] - Toilet_Light changed from ON to OFF
2019-01-13 10:03:02.854 [GroupItemStateChangedEvent] - gLight changed from ON to OFF through Toilet_Light
Because OH is restarted and the item is not persisted so the value is NULL until it receive a command.
If your OH gets restarted every night then use persistence on the item’s to avoid the NULL.
Best to use mapdb for this and make sure you have it installed in PaperUI then use the file example like below for your items.
This really interesting. Assuming that your rule can handle NULL properly without throwing an error, a change from NULL->TOGGLE shouldn’t take any longer than any other change?
I don’t know what your Item is, but it sounds like the sort of thing that responds to current events and does not need to be persisted+restored.
The usual guess about “first time rule run is delayed” is that the rule code has been rolled out of memory. First time trigger takes a while to fetch it back in. It’s difficult to see how Item state could affect that, but it is possible, perhaps through the restore process.
I figured out today’s morning that this behaviour is happening again.
2019-01-17 08:11:35.128 [ome.event.ItemCommandEvent] - Item ‘Kitchen_Light1_Toggle’ received command TOGGLE
2019-01-17 08:11:35.187 [ome.event.ItemCommandEvent] - Item ‘Kitchen_Light2_Toggle’ received command TOGGLE
2019-01-17 08:11:40.304 [ome.event.ItemCommandEvent] - Item ‘Kitchen_Light2’ received command ON
2019-01-17 08:11:40.324 [ome.event.ItemCommandEvent] - Item ‘Kitchen_Light1’ received command ON
2019-01-17 08:11:40.369 [GroupItemStateChangedEvent] - gLight changed from OFF to ON through Kitchen_Light2
Yes you are right, I have rule for each Philips Hue light (connected trough v1 philips hue hub).
rule “Toggle convert Kitchen1”
when
Item Kitchen_Light1_Toggle received command TOGGLE
then
if(Kitchen_Light1.state == ON) sendCommand(Kitchen_Light1, OFF)
else sendCommand(Kitchen_Light1, ON)
end