My car returns a state of “heating”, “cooling” or “off” for climatisation, which I am trying to pull into a switch. However, it doesn’t seem to be working. I have:
mqtt:
switch:
- name: "Climatisation"
command_topic: weconnect/vehicles/XXX/controls/climatisation_writetopic
payload_off: stop
payload_on: start
state_topic: "weconnect/vehicles/XXX/domains/climatisation/climatisationStatus/climatisationState"
value_template: "{% if ((value == 'heating') or (value == 'cooling')) %}on{% else %}off{% endif %}"
state_on: on
state_off: off
json_attributes_topic: "weconnect/vehicles/XXX/domains/climatisation/climatisationStatus/climatisationState"
json_attributes_template: "{'value': {{value|to_json}}}"
In theory, this config should provide a switch which:
I can toggle to turn climatisation on/off.
Shows on / off based on the current climatisation state (“heating” and “cooling” are both considered to be the “on” state).
Adds a “value” attribute to the entity, containing the original “heating”, “cooling” or “off” value.
(1) is working fine, but the entity’s state is always “unknown” and there is no “value” attribute.
I’m not sure where to go with debugging this. No errors relating to this seem to be logged anywhere.
Adds quotes around on or off which must always be quoted anywhere in YAML
Simplify the value_template so that on and off don’t appear outside of a template unquoted. I can’t confirm if what you had would cause issues, but I’m confident what I’ve provided will work.