Hi all,
I’ve seen a lot of threads around passing variables to a script and utilising them (which I’ve done successfully) but what I haven’t managed to do is to use that argument within a template. I simply want to the the state_attr calculation recognise the dynamic entity I’m passing through but it evaluates to None/null. Code below any help greatly appreciated (see: state_attr(states(entity)…)
Automation
service: script.1711691632906
metadata: {}
data:
entity: >-
{{
states('input_select.helper_master_bedroom_bedside_table_switch_entity_select')
}}
enabled: true
Script
alias: light_brightness_down_test
sequence:
- service: light.turn_on
metadata: {}
data:
entity_id: "{{ entity }}"
enabled: false
- choose:
- conditions:
- condition: template
value_template: >-
{{
state_attr(states('input_select.helper_master_bedroom_bedside_table_switch_entity_select'),'brightness')|int(0)*100//255
> 5}}
enabled: false
- condition: template
value_template: >-
{{
state_attr(states(entity),'brightness')|int(0)*100//255
> 5}}
sequence:
- service: light.turn_on
metadata: {}
data:
brightness_step_pct: -5
target:
entity_id: "{{ entity }}"
- conditions: []
sequence:
- service: light.turn_on
metadata: {}
data:
brightness_pct: 1
target:
entity_id: "{{ entity }}"
mode: single
fields:
entity:
selector:
text: {}
name: entity
required: true