So my main floor inside lights currently turn on 15 minutes before sunset, which is fine when the sun is out and shining but when there is cloud coverage, it’s dim inside and the lights aren’t on yet. So I thought about using OpenWeatheMap Cloud coverage (which is a percentage) to adjust that offset. Here’s my current Automation, how would you adjust the offset so it varies from -45 minutes to -15 minutes (100% cloud coverage to 0% cloud coverage)?
alias: At sun set
description: Turn on the inside light on the main floor
trigger:
- event: sunset
offset: -0:15:00
platform: sun
condition: []
action:
- scene: scene.main_floor_at_sunset
Error:offset 00:{{ ((state_attr('weather.openweathermap', 'cloud_coverage') / 100 * 30 + 15) | int | string) }}:00 should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F' for dictionary value @ data['offset']. Got None.
If you have a weather station, you could try using the solar radiation as a trigger. That acts as a reasonable proxy for cloud cover in my use case to trigger a roller blind.
A long, long time ago (over 30 years), I added a photocell on the celing of my covered porch (so no direct sunlight) connected to an opamp that would trigger a relay when a voltage threshold was reached. That opamp is long gone, replaced by an automation but that photocell is still there. I could repurpose it, but for now, using OWM would do a ‘good enough’ job.
Yeah, I do. It’s a Acurite 5-in-1 weather station so it lacks that sensor. It does have a solar panel (two, actually) but it’s just use to power a fan that ‘cools down’ the temperature sensor when hit by the sun so it gives an accurate outside temperature.
For now, all I need is fixing that automation so it would work relatively well, better than it currently does, at least.
but can’t figure out how to use it (if even possible) in the offset field in my automation (I get the same error as above) I don’t meddle with Home Assistant often enough to remember from time to time how I did things lol.
Based on my test, the offset option doesn’t support templates. That’s why the error message reports the value is not in HH:MM or HH:MM:SS.F format.
I used the Automation Editor to create a new automation with a Sun Trigger and with a very simple template in its offset option. Upon attempting to save the new automation, it reported the following error message.
Message malformed: offset {{00:15:00}} should be format 'HH:MM', 'HH:MM:SS' or 'HH:MM:SS.F' for dictionary value @ data['offset']
Thanks. I guess I’ll try to get the sunset time, subtract the offset from it and use that, with a real offset set to 0. Weird that it can’t be templated. It’s such a obvious one that could use a variable…
A Numeric State Trigger’s below (and above) option supports a hard-coded elevation value or the entity_id of a sensor that reports an elevation value. You can make a Template Sensor that calculates an appropriate elevation based on cloud coverage.
The condition might be unnecessary but it’s to make sure the automation doesn’t fire again if the cloud condition has changed and the lights have been dimmed to a value other than the default for the scene.