Hi All,
I’d like to ask for your help.
I have an MQTT Sensor which gets some Air Quality information from a Thermostat as a text (Bad, Good, Excellent).
mqtt:
sensor:
- name: "Thermostat Air Quality"
state_topic: "homeassistant/thermostat/air_quality/cmd"
qos: 2
I’d like to have something similar like in this PR by @frenck (be able to set the possible options in the YAML file so as I’m creating automations, I would be able to select From and To states from a list and avoid making trouble with a typo).
What do you think, would this be possible?
Thanks in advance!
MrJelly17
(Mr Jelly17)
March 17, 2023, 10:42pm
2
Maybe this will help. Not sure
sensor:
- platform: mqtt
name: "Thermostat Air Quality"
state_topic: "homeassistant/thermostat/air_quality/cmd"
qos: 2
value_template: >
{% set options = ["Bad", "Good", "Excellent"] %}
{% if value in options %}
{{ value }}
{% else %}
Unknown
{% endif %}
json_attributes_topic: "homeassistant/thermostat/air_quality/cmd"
json_attributes_template: >
{% set options = ["Bad", "Good", "Excellent"] %}
{% if value_json.state in options %}
{
"state": "{{ value_json.state }}"
}
{% else %}
{
"state": "Unknown"
}
{% endif %}
Hi @MrJelly17 ,
Many thanks for your answer. Unfortunately the options do not pop up in the editor.