-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Hi,
first of all, thanks for the amazing component. It's exactly what I was looking. No extra docker dontainer like AppDaemon but also based on Python. Finally it is possible to properly compute in automations thanks to the type-stable store and retrieval of state attributes!
My current use-case is to have the brightness of a light be changed, depending on the time of day and state of the sun.
The ugly way:
binary_sensor:
- platform: tod
name: morning
after: '08:00'
before: '10:00'
- platform: tod
name: day
after: '10:00'
before: '18:00'
- platform: tod
name: evening
after: '18:00'
before: '21:00'
sensor:
- platform: command_line
name: light_brightness_cmd
command: 'python3 /config/shell-scripts/set-brightness.py' # extreme customization needed for control
value_template: "{{ value_json.info.brightnessValue|default('unavailable', false) }}"
scan_interval: 30
- platform: template
sensors:
light_brightness:
value_template: "{{ states('sensor.light_brightness_cmd')|float }}"
attribute_templates:
brightness: "{{ states('sensor.light_brightness_cmd')|float }}"
brightness_scaled: "{{ (states('sensor.light_brightness')|float * 100)|int }}"
And on top of that, there is an automation to determine the current time of day, assign and rescale the brightness value and, using another py-script, adjusting it. It's way to complicated for the result.
My idea was now to a time_trigger like
@time_trigger("once(08:00:00)", "once(10:00:00)", "once(18:00:00)", "once(21:00:00)", "once(sunrise)", "once(sunset)"
put whatever fancy logic and calculations in a set_daytime()
function and store the results as state&attributes in a dummy entity.
My problem now is, I would need set_daytime()
also be executed at reload&restart for proper initialization.
Any idea?