Mqtt Switch with logic for state

Hello, I am trying to configure a switch for activating blueIris shield.

The information I receive from state_topic is:

where signal=0 is activated

To command it I need to send signal=0 to enable it and signal=1 to disable.

I have tried multiple things, like value_templates, and so on, and no matter what I configure, always the switch is off. If I press it, it sends the proper commands, but it seems not to like whatever I try for getting that information.

This is my last switch code:

  - platform: mqtt
    unique_id: blue_iris
    name: "Activate movement detection"
    state_topic: "BlueIris/status"
    command_topic: "BlueIris/admin"
    value_template: "{{ value_json.signal }}"
    payload_on: "signal=0"
    payload_off: "signal=1"
    state_on: "0"
    state_off: "1"

Can anybody please help me?


Can you share the exact state_topic payload that you get from this component?

Thanks for answering!

Below you can see the screenshot of the HA MQTT listener.

Now i´m thinking…may this message not be a json?

:+1:Its not a json payload.

1 Like