hi,
i m unable to get something as i activate the state_value_template config line. even the elese condition never returns anything.
the device is a sonoff dual , driving my extraction fan at home.
here the config :
if i just select a state_topic containing a string that is on or off, it just works, but i would like to use the templating to have a more standardized config on the device.
note the condition itself is just for testing purposes
i also have the same issue for the preset mode i think.
appart testing in the jinja template , is there anywhere else to find logs ? i activated mqtt logs but dont get anything about that.
fan:
- name: "bathroom-fan"
unique_id: "fan.bathroom-fan"
command_topic: 'cmnd/vmc/event'
#availability:
# - payload_available: 'Online'
# - payload_not_available: 'Offline'
# - topic: 'tele/vmc/LWT'
availability_topic: 'tele/vmc/LWT'
payload_available: 'Online'
payload_not_available: 'Offline'
state_topic: 'tele/vmc/STATE'
state_value_template: >
{%- if "OFF" in value_json.POWER1 and "OFF" in value_json.POWER2 -%}
"off"
{%- else -%}
"on"
{%- endif %}
preset_mode_command_topic: 'tele/vmc/STATE'
preset_mode_command_template: >
{%- if 'off' in value -%}
speed0
{%- elif 'low' in value -%}
speed1
{%- elif 'high' in value -%}
speed2
{%- else -%}
speed1
{%- endif %}
#percentage_command_topic: 'cmnd/vmc/event'
#percentage_command_template: >
# {% if value < 10 %}
# speed0
# {% elif value < 80 %}
# speed1
# {% else %}
# speed2
# {% endif %}
#percentage_state_topic: 'tele/vmc/STATE'
preset_modes:
- "off"
- "low"
- "high"
preset_mode_value_template: >
{%- if "OFF" in value_json.POWER1 and "OFF" in value_json.POWER2 -%}
"off"
{%- elif "ON" in value_json.POWER1 and "OFF" in value_json.POWER2 -%}
"low"
{%- elif "OFF" in value_json.POWER1 and "ON" in value_json.POWER2 -%}
"high"
{%- endif %}
#percentage_value_template: >
# {% if value_json.POWER1 == "OFF" and value_json.POWER2 == "OFF" %}
# 0
# {%- elif value_json.POWER1 == "ON" and value_json.POWER2 == "OFF" -%}
# 50
# {%- elif value_json.POWER1 == "OFF" and value_json.POWER2 == "ON" -%}
# 100
# {%- endif %}
payload_on: "on"
payload_off: "off"
the payload in tele/vmc/STATE :
{"Time":"2023-08-23T18:02:06","Uptime":"32T06:02:37","UptimeSec":2786557,"Heap":24,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":37,"POWER1":"ON","POWER2":"OFF","Wifi":{"AP":1,"SSId":"ouinouin_Nicol","BSSId":"A4:2B:B0:A5:A0:48","Channel":11,"Mode":"11n","RSSI":58,"Signal":-71,"LinkCount":2,"Downtime":"0T09:56:14"}}