Hi, can anyone help me write a simple automation in visual editor format, to switch a garden fountain on/off based on time of day and instantaneous weather? I would like to have the fountain on during daylight whenever the weather is good (low cloud cover and low wind).
I’m using a Shelly switch which is working fine, I’m just struggling to construct an automation using Sun and Home Forecast. Many thanks.
Below my existing automation, which checks the sun position and cloud cover every hour, then turns on the fountain only while it’s daytime and the cloud cover is below 50%. At least that’s the theory - I haven’t tested it yet.
Here’s how I would do it. The automation is completely event-based; it triggers only when specific events occur such as sunrise/sunset and when cloud coverage is above/below 50. It does not use a Time Pattern Trigger to repeatedly (and often needlessly) test if the conditions meet the desired requirements.
Thank you very much for the very detailed answer. Makes sense.
My only concern is that adding additional weather constraints will make the code rather complex. I’ve tried to simplify my version by using a default action to turn the fountain off, but also added a test of the wind speed. Still untested though.
If you don’t mind having your switch either turned on or turned off 1440 24 times a day, then use your approach.
Another approach is to create a Template Trigger that incorporates all conditions required to turn on the switch. However it involves a template and I suspect you aren’t comfortable with it just yet.
It would involve adding another trigger which isn’t more complicated than having to add another condition (as you did in your latest example). Same effort but a more efficient result.
I would post an amended example, demonstrating how it easy it is, but I get the impression you’re already sold on using polling as opposed to event-driven.
Thanks again. The trigger is the 0th minute of every hour, not the 0th second of every minute. As I understand it, the weather integration refresh interval is anyway only 30 minutes.
Right, certainly not comfortable with a Template Trigger. But something to investigate though - thanks very much for the suggestion.