Mqtt switch not recognizing correct state

Hi All :slight_smile:
New to home assistant, floorplan, mqtt etc.
Sorry if posted in the wrong forum.

I just migrated from Z-wave to zwave2mqtt
I have a switch configured

switch:
  - platform: mqtt
    name: "Porch Light Switch"
    state_topic: "homeassistant/frontdoor/switchporch_light/37/1/0"
    command_topic: "homeassistant/frontdoor/switchporch_light/37/1/0/set"
    payload_on: "true"
    payload_off: "false"
    state_on: "true"
    state_off: "false"
    qos: 0
    optimistic: false
    retain: true
    value_template: '{{ value_json.value }}'

which works and turns on / off the device when triggered.

BUT neither in floorplan nor in lovelace the state is reflected correctly.

As part of troubleshooting, I added the state_on/off and value_template but they did not resolve the issue either.

As example in Lovelace UI, I can trigger the switch and it turns the switch on, but immediately afterwards it reverts the state to off/false although the switch is still on.

I don’t understand / can’t find what I have configured wrong that the state is not recognized correctly.

I am using Mosquito and the state topic is published correctly -->

Topic: homeassistant/switchporch_light/37/1/0

image

Any help very much appreciated.

:wink:

I use the discovery option and all my switches are handled automagically

ARGHGHGH. Feeling sooo stupid.

Let me check and get back.

Ok, removed the “new Name” from the MQTT setup.
Used the switch created by discovery and works fine now.

THANK YOU

1 Like