Help with OpenMqttGateaway and HA Configuration.yaml

Hallo all,
I am using OpenMQTTGateaway on a ESP8266 MCU Board.
Everything is install well. Thanks to the Programmer ! Very nice Programm.
I have a RF 433 Mhz Wall-Switch. The codes for this wall switch is
4523285 for ON
4523284 for OFF
So far so good. If I send the ON Code Manualy over Publish MQTT to the Topic home/OpenMQTTGateway/commands/MQTTto433

{ “value”:4523285,“protocol”:1,“length”:24,“delay”:313}

The Wallswitch turn ON. Nice :slight_smile:

If I send the OFF Code Manualy over Publish MQTT to the Topic home/OpenMQTTGateway/commands/MQTTto433
The Wallswitch turn OFF. Also Verry Nice :slight_smile:

{ “value”:4523284,“protocol”:1,“length”:24,“delay”:313}

In my HA configuration.yaml I put this lines.
switch:

  • platform: mqtt
    name: test1
    state_topic: home/OpenMQTTGateway/commands/MQTTto433
    command_topic: home/OpenMQTTGateway/commands/MQTTto433
    value_template: ‘{{ value_json.state }}‘
    payload_on: ‘{ “value”:4523285,“protocol”:1,“length”:24,“delay”:313 }‘
    payload_off: ‘{ “value”:4523284,“protocol”:1,“length”:24,“delay”:313 }‘
    state_on: “on”
    state_off: “off”
    optimistic: “true”
    qos: 1
    retain: true

Then I checked the Config in HA and I got no Errors. Then Reboot HA.
Create a Card in HA. like this.

But it is not working…
So I read the Docs so many time. But I can’t find a solution.
Reading here in the Forum, trying so many Configuration in the Configuration.Yaml
nothing helpt me.
Now I am living under the Rock. :frowning:

Maybe someone can help me. Sorry for the Pain but im only a Electronik Engineer but not
a good Programmer. If someone have question about Electronik, No Problem for me. Working more than 42 Years now, for the biggest Elektronik Company. But now I’m giving up, with that stupid Configuration.Yaml. So please give me a clue…
Best regards
Juergen

First of all, never ever use retain: true in a switch definition in HA. That causes the COMMAND to be retained, causing all kinds of unpredictable behavior.

Second : remove your value_template. There is nothing to template, as you use the full received json in the payload_xx

Third: the state_xx can be removed too.

Hallo @fancisp
Yes you are right… Many , Many thanks for your verry good support.
Now it is up and running perfect.
Sorry but as I said Programming is not for me. But it is good to know where to ask Questions.
Thank you so much. Now I can going on to implement more of the cheap Switches , Sensors and so on.
For those who have the same Problem. Here are the correct entr. in Configuration.Yaml
as @francisp said.


switch:

  • platform: mqtt
    name: test1
    state_topic: home/OpenMQTTGateway/commands/MQTTto433
    command_topic: home/OpenMQTTGateway/commands/MQTTto433
    payload_on: ‘{“value”:4523285,“protocol”:1,“length”:24,“delay”:313}’
    payload_off: ‘{“value”:4523284,“protocol”:1,“length”:24,“delay”:313}’
    optimistic: “true”
    qos: 0
    retain: false

Best Regards
Juergen

1 Like