Background: we have a couple ChromeCasts in our network. When they are connected to a 5GHz Wi-Fi they are quite unstable and often loose the network connection. Usually the openHAB binding reconnects the device quickly, but it happens that the device stays offline. It might have something to do with the router, but nevertheless I want to know when things go offline.
When the ChromeCast goes offline, this Switch is updated in a rule with the current time:
However resetting the DateTime switch when the item comes back online proved to be a small challenge, the documentation is unclear. People write online about
UnDefType.NULL and a couple more.
In the end it’s quite easy:
Just update the Item with
NULL. Don’t use sendCommand() here, you only want to update the Item, not send a new command to a virtual switch.