Set_value_template help

Hello,

I’m trying o setup a simple mqtt based FAN connected to a Sonoff tasiota switch. I know I could use switch but I would like to match my objects with HA semantic.

The problem I’ve is the state detection of the FAN.

This is what I’ve from my mqtt server

stat/fan/POWER which can be ON or OFF (capital Letter)

or

stat/fan/RESULT which can be { “POWER”: “ON”} or {“POWER”: “OFF”

This is my mqtt fan

fan:

  • platform: mqtt
    name: “FAN”
    unique_id: fan
    command_topic: “cmnd/fan/power”
    payload_on: “1”
    payload_off: “0”
    state_topic: “stat/fan/RESULT”
    state_value_template: “{{value_json.POWER | lower }}”
    speeds: off
    retain: “false”
    optimistic: false
    qos: 0

I also tried with

state_topic: “stat/fan/POWER”
state_value_template: " {{value | lower }}"

with no luck.

Could somebody tell me what I’ doing wrong?

Thanks,
Raffaele.