Hi everybody,
I’m still pretty new to openhab, but so far thanks to a lot of tutorials and examples I’ve been able to get everything working like I wanted and the setup has been running fine for over two months now. But yesterday I stumbled upon an issue where it behaved unexpectedly.
The setup:
- raspberry pi running openhab and the mqtt server
- multiple esp8266 reporting temperatures
- esp8266 controlling a 4x relay (sonoff 4ch)
Everything is in the same wifi (Fritz.box). The ESPs get triggered and read via mqtt
What behaved unexpected is a simple cron timer:
- switch a certain port of the relay to on in the morning and to off in the evening
The situation that I found yesterday evening after the light didn’t go out:
raspberry has disappeared from the WLAN
ESPs reading temperatures disappeared from the WLAN
ESP with the relay is still connected or reconnected
Nothing found in the fritz.box .. not sure what happened? Anyway, that’s not the point of the post. So I got some connection problems. What did I do? Reboot the raspberry, power cycle the ESPs.
Everything connected back to the WLAN.
What I expected now:
The light should be switched off after the raspberry reboot.
But this didn’t happen. However, in openhab, the switch object was set to “off”
So I read about the cron job → it’s apparently a one time thing. It gets triggered one time, it’s not like the cron job is checking up on the object later, if it’s still off.
My question here: Is there any simple way to set something to “off” or “on” during a defined period of time, so that the script checks periodically if it is really switched off? I thought about doing an every 5 minute cron job and check for whether it’s night or day in the executing part of the script. but that would mean sending a trigger every 5 minutes. There sure is a more elegant way?
The other question: .. apparently openhab executed the job, that’s why the “local” switch was set to off. So mqtt should have received the off command as well, but couldn’t send it to the client due to not having network.
Why didn’t this get cached locally and sent to the ESP relay once network was back on?
Is this a configuration setting somewhere? Like thtat the mqtt message should be resent? I wouldn’t want it on the temp readings, but for the commands I’d like if they aren’t “fire and forget”.