Using an idea from another post I wanted to create an automation based on the percentage level of a virtual light. I cannot seem to get the action to work. I’ve tried light_level, brightness, brightness_pct, but always am getting a value of “unknown”. I’m sure I’m just doing something wrong. Anyone have any ideas
- alias: "Alexa Report"
trigger:
- platform: state
entity_id: light.alexa_virtual
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 1
action:
- service: script.audio_notify
data_template:
tts_msg: >-
{% if states('light.alexa_virtual.attributes.brightness') | int == 1 %}
ME is away and is approximately {{ states('sensor.my_time_to_home') }} minutes from home.
{% elif states('light.alexa_virtual.attributes.light_level') | int == 2 %}
YOU is away and is approximately {{ states('sensor.my2_time_to_home') }} minutes from home.
{% elif states('light.alexa_virtual_brightness_pct') | int == 3 %}
Something other than what you've already said
{% else %}
{{ states('light.alexa_virtual.attributes.brightness') }}
{% endif %}
mplayer: "living_room_echo"
- service: light.turn_off
entity_id: light.alexa_virtual
And my configuration yaml for the light
light:
- platform: template
lights:
alexa_virtual:
friendly_name: "Alexa Dummy Light"
turn_on:
turn_off:
set_level:
I keep getting the ELSE results, with a return of “unknown”