本帖最后由 情非殇 于 2021-8-13 10:10 编辑
- platform: template
sensors:
city_phase:
value_template: '{% if is_state("sensor.youjia_city", "shandong") %}山东{% else %}未知{% endif %}'
friendly_name: '城市'
template:
- sensor:
- name: "Kettle"
state: >
{% if is_state('switch.kettle', 'off') %}
off
{% elif state_attr('switch.kettle', 'kwh')|float < 1000 %}
standby
{% elif is_state('switch.kettle', 'on') %}
on
{% else %}
failed
{% endif %}
你参考下这段代码吧, |