I really like to monitor things, to catch issues early on. In our home we have a couple ChromeCasts, both Audio and Video. They are all connected to the openHAB system, Once in a while they stop working, and need to be restarted (unplugged and plugged in again). Unfortunately you usually only find that out when you want to stream something, and wonder why either the ChromeCast does not show up in the device list, or does show up but does not accept the media.
Therefore I decided to monitor the devices in openHAB.
That’s quite easy, a rule can react on a status change of the Thing:
| |
Inside of the rule any notification can be sent (email, Telegram, Pushover, …).
However more often than not the ChromeCast will only go offline for a moment. The log looks like this:
| |
There is a blib, and the rule is triggered and will send a notification. Then a couple seconds later the Binding reconnects to the ChromeCast and everything is fine again. It would be much better if the notification is only sent if the device stays offline for a certain time. This is possible by using a Timer and a Lambda function in the rule. It also requires two rules: one for triggering the timer when the device goes offline, one for canceling the timer when the device comes online.
| |
The ChromeCast Living Room offline - timer rule will create a timer and at the end of the timer execute the inline Lambda function. If the timer finishes and was not canceled before, the inline function will send the notification that the device is offline.
The ChromeCast Living Room online - timer has two jobs: if the timer is already expired, the downtime was for longer than a minute. Write this into the log. And if the timer is not yet expired, cancel the timer - because the device is online again and no notification is required.
Comments
With an account on the Fediverse or Mastodon, you can respond to this post. Known replies are displayed below:
Note: This will load data from mastodon.social.
Learn how this is implemented here.
Share: