Using cloud coverage to control lights?

Hi!

I’m trying to control the way one of my Sonoff Basic turns on or off depending on the cloud coverage. I’ve used sun up and sun down before but would like to turn on the lights if for instance the sun is covered by clouds midday.

I have installed the SMHI integration (Swedish national weather forecast) and the entity has an attribute called cloudiness (0-100; probably percentage of clouds) that might work but I can’t figure out how to use that attribute? I have tried to create an automation using a Trigger but that doesn’t work.

Any ideas or suggestions?

HA: ver 0.111.3
OS: HassOS 4.12

Please see the docs for the numeric state trigger.

for is a duration that the trigger must be true for

You’d want, since you’re not yet upgraded to 0.115, to use the value template line, like

{{ state.attributes.cloudiness }}

Thx for the reply. Just a quick question:

Would you say that using triggers is the right way to go? Or am I making it more complicated than it has to be?

Well, personally I’d invest in a lux/illuminance sensor - then you get actual light levels, not a vague guess.

The latest Xiaomi Mijia one (such as here) is really rather nice. The sensitivity is good, it reports in a sensible manner (regular reports of minor changes, instant reports when there’s big changes).

1 Like

Great! Will go for that solution instead! Sounds much better because the SMHI integration seems to give vague and estimated values that are really off.