Description:
I am using a rule to start a pump at minutes 0, 20 and 40 between 06:00 and 13:59, Monday to Friday, and a similar rule to stop the same pump 5 minutes later. The pump is connected through a Shelly Plug-S.
I used the cron expressions: “0 0,20,40 6-13 ? * MON-FRI” and “0 5,25,45 6-13 ? * MON-FRI” to trigger the rules to start and stop the pump (send ON and OFF commands to the plug), and the result was that the starting and stopping of the pump was irregular (sometimes the pump did not start, others it would not stop).
Changing the cron expressions to “0-3 0,20,40 6-13 ? * MON-FRI” and “0-3 5,25,45 6-13 ? * MON-FRI” solved the problem.
This solution may send 1 or more commands in the 3 second period. Repeating the commands to the plug seems to be acceptable (to the plug) and the result is the expected sequence of start/stop actions.
Any hint on what is wrong?
Thanks
Do i understand it correctly, that you have a simple rule and you want to:
start the pump on 0,20,40 minutes
stop the pump everytime 5 mins later
There’s a more elegant solution to this: using “expire”, so you can define on an item, what should happen to a specific time after the last value change.
in OH3 you can do this also conveniently within the GUI. Go to the item, click on “Add Metadata” and “Expiration timer”. There you can chose, what should happen after a specific period of time.
As I said, the more elegant solution would be to work with the “Expiration”-Metadata.
Apart from that, your two-rule solution should still work.
But to fully assess your setup, please open the two rules, switch to “Code” on top of the rule and paste both rules here (be sure to use code fences for better readability - one of the icons at the top here if writing)
The pump as an “Auto Mode” and a “Manual Mode”. The state of the “WaterPumpAutoMode” item is used the allow/block the action of the rule.
The pump can also be controlled using the OpenHAB UI (remote control of the Shelly Plug, without using the rule). I did not notice any failures when using the “manual” control.
I will try to insert some logs to check the triggering if the rule.
Thanks for the help.
I checked the logs and I found several lines like this:
2022-04-22 13:20:15.692 [WARN ] [y.internal.handler.ShellyBaseHandler] - shellyplug-s-881b5f: ERROR: Unable to process command ON for channel shelly:shellyplugs:881b5f:relay#output - Device unreachable or API Timeout ()
I moved the AP, the plug is connected to, closer to the Shelly Plug and changed the cron expression to “0 0,20,40…”.(no retries)
I got no more “ERROR” messages and the pump starts and stops at the expected times.
Thanks for your hints.
I would use the auto off function on the shelly himselve and only send the pump on cmd. That way you would prevent that the pump stays on if the plug is not reachable anymore after you send the switch on cmd.