Skip to content

Instantly share code, notes, and snippets.

@dale3h
Last active April 26, 2018 01:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dale3h/86b7323630d313338c78f417625d799e to your computer and use it in GitHub Desktop.
Save dale3h/86b7323630d313338c78f417625d799e to your computer and use it in GitHub Desktop.
Light Toggle w/ Brightness (@MattW)
################################################################
## Packages / Light Toggle with Brightness
##
## @description Toggle lights with a brightness based on time
## @component automation, binary_sensor, light
## @license MIT
## @author @mattlward, Dale Higgs <@dale3h>
################################################################
automation:
- alias: "Single Click 21 to Toggle Stair Lights"
trigger:
- platform: event
event_type: click
event_data:
entity_id: binary_sensor.switch_158d0001f3de21
click_type: single
action:
- service: light.toggle
data:
entity_id: light.stair_top, light.stair_bottom
- condition: template
value_template: "{{ is_state('light.stair_top', 'on') or is_state('light.stair_bottom', 'on') }}"
- service: light.turn_on
data_template:
entity_id: light.stair_top, light.stair_bottom
brightness: >-
{% if 6.00 < now().strftime('%H.%M')|float < 22.00 %}
255
{% else %}
64
{% endif %}
@mattlward
Copy link

So, it is close but not there...

When the lights are off and I press the switch they turn on to the correct brightness. But, if they are on and I press the switch they turn off and then right back on.

Also, is this acceptable to add?

 data_template:
          entity_id: light.stair_top, light.stair_bottom
           kelvin: >-
            {% if 6.00 < now().strftime('%H.%M')|float < 22.00 %}
              5000
            {% else %}
              2700
            {% endif %}
          brightness: >-
            {% if 6.00 < now().strftime('%H.%M')|float < 22.00 %}
              255
            {% else %}
              64
            {% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment