I am writing an "advanced" sensor using PowerShell. The task is to monitor a scheduled event which takes place hourly from 06:00 to 20:00. Currently the sensor channel reports the time delta between "now" and the most recent event, which was a bit tricky to achieve but works fine. This is only one of 3 or 4 channels which are also under development.
I want the channel to go into error state when the most recent execution is more than 120 minutes in the past, except when the current time of day is between 20:00 and 06:00. How do I manage that? If I understand the documentation correctly:
- adding <error>1</error> to the <result> means "sensor is not working," rather than "sensor is ok but the value is bad." The actual sensor value is not displayed in this case.
- adding <LimitMaxError> has an effect only during the first sensor execution, so it is not possible to change the limit automatically, depending on the time of day.
I could subtract the "night time hours" from the time difference but that would, in my eyes, distort the measurement. Is there any other solution?
Thanks a lot