After implementing the turn lights on 20 minutes before sunset automation in hass.io, I was quite happy to see our evening lights come on and off automatically each night. But we encountered a few cloudy days in the past week, and it troubles me that the house gets too dark much earlier, so… need to look for a better solution.
Question, how to detect when it is getting too dark in the house?
The obvious answer will be using some photoelectric sensor that can monitor when it is too dark inside the house. There are probably some smart sensor available in the market, and there are also light or light bulb that has photoelectric sensor built in. But for now, I just can’t justify the additional cost for them.
Let’s look at the problem from a different perspective. So the house tends to get darker earlier if it is a cloudy day or when the weather is bad.
💡Maybe I can build an automation based on the current weather?
And yes, there are lots of weather info and forecast available online. One actually comes by default with Hass.io, yr.no. This weather forecast is delivered by the Norwegian Meteorological Institute and it free. You can monitor a dozen or so weather related items, such as temperature, precipitation, windspeed, humidity, cloudiness, … etc.
There is one item specifically called yr_symbol, which indicate the current weather condition. Clear sky, Partly cloudy, Cloudy, Rain showers, Heavy rain,… and so on. Maybe we can use this to drive when to turn on the evening lights?
Ok, let’s go for it.
Below is the configuration added to automations.yaml file. The automation is triggered by a time relative to sunset, in this case it is set to 40 minutes before sunset. Condition is when the yr.symbol is above 4. Confused? here is the explanation, the yr.symbol is a numeric value that maps to a weather condition. It goes from 1 to 50, as the number increase, the weather condition gets worst. a number 4 means that it is cloudy. For your reference, I will provide the more extensive list at the end of this post. Please note that I also added a second condition to check if lights are already on, in that case, there is no need to turn them on again.
- id: 'turn lights on earlier if it is cloudy' alias: Turn lights on earlier if it is cloudy trigger: - event: sunset offset: -00:40:00 platform: sun condition: - condition: numeric_state entity_id: sensor.yr_symbol above: 4 - condition: state entity_id: group.evening_lights state: 'off' action: - service: homeassistant.turn_on data: entity_id: - group.evening_lights - service: notify.mypushbullet data: message: Turn light on earlier if it is cloudy.
For your reference:
- please refer to the previous article, turn lights on 20 minutes before sunset, on how to configure the evening lights group.
- Documentation on how to integrate YR.no to hass.io
- Number mapping for yr_symbol
1;Clear sky 2;Fair 3;Partly cloudy 4;Cloudy 5;Rain showers 6;Rain showers and thunder 7;Sleet showers 8;Snow showers 9;Rain 10;Heavy rain 11;Heavy rain and thunder 12;Sleet 13;Snow 14;Snow and thunder 15;Fog 20;Sleet showers and thunder 21;Snow showers and thunder 22;Rain and thunder 23;Sleet and thunder 24;Light rain showers and thunder 25;Heavy rain showers and thunder 26;Lights sleet showers and thunder 27;Heavy sleet showers and thunder 28;Lights snow showers and thunder 29;Heavy snow showers and thunder 30;Light rain and thunder 31;Light sleet and thunder 32;Heavy sleet and thunder 33;Light snow and thunder 34;Heavy snow and thunder 40;Light rain showers 41;Heavy rain showers 42;Light sleet showers 43;Heavy sleet showers 44;Light snow showers 45;Heavy snow showers 46;Light rain 47;Light sleet 48;Heavy sleet 49;Light snow 50;Heavy snow
2,683 total views, 1 views today