Thanks for this. Very helpful. I will definitely use this option if my current plan fails.
I’m in the process of modifying @pnbruckner’s python script to use open weather map. I was going to just include a open weather map (OWM) sensor in my config but I believe that sensor calls the four hour summary. I’m not sure that will produce fine enough results.
Instead I’ve created a rest sensor that calls the OWM API for current cloud percentage every 15 minutes, the free api account allows 60 calls per minute. I’m thinking cloud percentage is the best attribute to monitor for estimated ambient luminance. All weather conditions that affect light levels involve clouds right? I’m assuming fog counts towards cloudiness data??
An API call for current conditions at my longitude and latitude returns this:
{"coord":{"lon":MY_LONG,"lat":MY_LAT},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01d"}],"base":"stations","main":{"temp":291.92,"feels_like":291.75,"temp_min":290.93,"temp_max":293.15,"pressure":1020,"humidity":80},"visibility":10000,"wind":{"speed":2.68,"deg":13,"gust":7.15},"clouds":{"all":2},"dt":1600599431,"sys":{"type":3,"id":2021002,"country":"GB","sunrise":1600580794,"sunset":1600625214},"timezone":3600,"id":2641429,"name":"MY_COUNTY","cod":200}
I used this in a rest sensor and extracted the cloud percentage
- platform: rest
# open weather map api call to my longitude and latitude for current weather conditions
resource: http://api.openweathermap.org/data/2.5/weather?lat=MY_LATITUDE&lon=MY_LONGITUDE&appid=MY_SUPER_SECRET_API_KEY
name: OWM Clouds
# template to extract the cloud percentage
value_template: '{{ value_json["clouds"]["all"] }}'
unit_of_measurement: '%'
# check every 15mins (open weather map updates every ten minutes)
# free api account allows 60 calls per minute
scan_interval: 900
Does anyone know if adding this line in @pnbruckner’s python script will return the OWM rest sensor’s state correctly?
from homeassistant.components.darksky.sensor import (
ATTRIBUTION as DSS_ATTRIBUTION)
# I added this line to import cloud percentage from a rest sensor polling OWM API
from homeassistant.components.rest.sensor.owm_cloudiness import ATTRIBUTION as OWM_ATTRIBUTION
from homeassistant.components.yr.sensor import ATTRIBUTION as YRS_ATTRIBUTION
I will then add an extra mapping section for OWM in the script.
If I wanted to migrate to weather_data
how would I import that into @pnbruckner’s script, would this work?
from homeassistant.components.weather_data.sensor import ATTRIBUTION as YRS_ATTRIBUTION
I guess this would work without any other modification of the script as weather_data
sensor returns the yrs symbol just like the yrs sensor did.