Hi all
I have tried many ways to get this working, but with no luck. I’m trying to set the input_text. Any ideas?
- trigger:
platform: numeric_state
entity_id: sensor.ss_battery_soc
action:
service: input_text.set_value
data:
value: >-
{% set ns = namespace(c = '') -%}
{% if states.sensor.ss_battery_soc.state | int < 40 %}
{% set ns.c = 'p20' -%}
{% elif states.sensor.ss_battery_soc.state | int < 45 %}
{% set ns.c = 'p40' -%}
{% elif states.sensor.ss_battery_soc.state | int < 65 %}
{% set ns.c = 'p60' -%}
{% elif states.sensor.ss_battery_soc.state | int < 95 %}
{% set ns.c = 'p80' -%}
{% elif states.sensor.ss_battery_soc.state | int <= 100 %}
{% set ns.c = 'p100' -%}
{% endif %}
{{ ns.c }}
target:
entity_id: input_text.ss_battery_charge_level
- trigger:
platform: numeric_state
entity_id: sensor.ss_battery_soc
action:
service: input_text.set_value
data:
value: >-
{% if states.sensor.ss_battery_soc.state | int < 40 %}
p20
{% elif states.sensor.ss_battery_soc.state | int < 45 %}
p40
{% elif states.sensor.ss_battery_soc.state | int < 65 %}
p60
{% elif states.sensor.ss_battery_soc.state | int < 95 %}
p80
{% elif states.sensor.ss_battery_soc.state | int <= 100 %}
p100
{% endif %}
target:
entity_id: input_text.ss_battery_charge_level