If you would like to create automations that depend on the outdoor light level but you don’t have a real light sensor, this custom sensor platform might be what you’re looking for. It periodically polls current weather conditions from Weather Underground and uses that, and the time of day, to provide an estimate. I’ve been using this algorithm for quite some time (first with SmartThings, and now with HA) and although it’s obviously not perfect, it (usually) does a pretty good job.
E.g., here is a graph of the values it provided for the last few days for me. As you can see, yesterday was sunny all day, and the previous day there was some decreasing cloud cover. Also you will note the ramping up and down around sunrise and sunset, respectively. That is a feature of the algorithm.
To use this you will need a Weather Underground API Key. You can find details here for how to obtain a free one: https://www.wunderground.com/weather/api/d/pricing.html
NOTE: It appears that Weather Underground no longer provides free API keys. Existing ones, though, do still appear to work. (Mine does as of 5/25/2018.) I’m currently looking into using other sources of current weather conditions as an alternative to WU.
Add the following to your configuration.yaml file:
sensor: - name: Illuminance platform: illuminance api_key: !secret wu_api_key query: 'pws:XXX' scan_interval: minutes: 5
scan_interval are optional. The default scan interval is 5 minutes.
api_key is required. This is the key you get from WU per the instructions mentioned above.
query is required. See https://www.wunderground.com/weather/api/d/docs?d=data/index for your options. In my case I use a local Personal Weather Station (pws).
I welcome any feedback. (E.g., if I completely missed the fact that this information is already available via some other, existing component, please let me know! )
You can obtain the code from here:
Place it at this location:
<config> is your Home Assistant configuration directory.