SOLVED! Strange light issue - Light Switching on, but sliding to off on HA dashboard

Morning all.

Yesterday I found that I was unable to turn off two of my lights via Home Assistant.
I can control them (on and off) with Alexa (via home assistant) and turn them on with the HA dashboard, However, the “switch” after sending the “on” command doesn’t stay in the “on” position.

I’m assuming that I still have voice control as it doesn’t care about the current state, but the dashboard will not send an “off” command unless it knows the light is on?

The rest of the switches work fine, and the config is the same for all the lights (below) it is “six” that isn’t working correctly. I have tried to change the “QoS” setting, but the same behaviour persisted.

Any ideas what I’ve done wrong? Thanks in advance.

  - platform: mqtt
    name: "Six"
    state_topic: "stat/Sonoff-7535/POWER"
    command_topic: "cmnd/Sonoff-7535/POWER"
    availability_topic: "tele/Sonoff-7535/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

  - platform: mqtt
    name: "Diningroom_Light"
    state_topic: "stat/Sonoff-2325/POWER"
    command_topic: "cmnd/Sonoff-2325/POWER"
    availability_topic: "tele/Sonoff-2325/LWT"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: false

Additional info from the Sonoff in question.:

Sonoff Basic Module

Sonoff-7535

Program Version 6.2.1
Build Date & Time 2018-09-09T16:50:26
Core/SDK Version 2_3_0/1.5.3(aec24ac9)
Uptime 0T11:31:37
Flash write Count 288 at F9000
Boot Count 48
Restart Reason Software/System restart
Friendly Name 1 Sonoff-7535
AP1 SSId (RSSI) Wan17 (94%)
Hostname Sonoff-7535
IP Address 192.168.50.104
Gateway 192.168.50.1
Subnet Mask 255.255.255.0
DNS Server 192.168.50.1
MAC Address REMOVED
MQTT Host 192.168.12.201
MQTT Port 1883
MQTT Client &
Fallback Topic Sonoff-7535
MQTT User homeassistant
MQTT Topic Sonoff-7535
MQTT Group Topic sonoffs
MQTT Full Topic cmnd/Sonoff-7535/
Emulation None
mDNS Discovery Enabled
mDNS Advertise Web Server
ESP Chip Id 6864229
Flash Chip Id 1327198
Flash Size 1024kB
Program Flash Size 1024kB
Program Size 471kB
Free Program Space 532kB
Free Memory 15kB

When you switch the light on from the HA frontend, does it ACTUALLY turn the light on?

Yes the light actually turns on, but doesn’t show as on.

I’ve changed the name of the name of the sonoff, along with the mqtt settings, and update the yaml files.

looking at the console on the switch in question i can see:

19:01:41 DNS: Initialized
19:01:47 DNS: Initialized
19:01:50 WIF: Connect failed as no IP address received
19:01:50 WIF: Connecting to AP1 Wan17 in mode 11N as Sonoff-6758...
19:01:54 WIF: Connected
19:01:54 DNS: Initialized
19:01:56 MQT: Attempting connection...
19:01:57 MQT: Connected
19:01:57 MQT: tele/Sonoff-6758/LWT = Online (retained)
19:01:57 MQT: cmnd/Sonoff-6758/POWER = 
19:02:00 MQT: tele/Sonoff-6758/UPTIME = {"Time":"2018-09-13T19:02:00","Uptime":"0T00:47:00"}
19:05:20 MQT: tele/Sonoff-6758/STATE = {"Time":"2018-09-13T19:05:20","Uptime":"0T00:50:20","Vcc":3.176,"POWER1":"ON","Wifi":{"AP":1,"SSId":"Wan17","RSSI":94,"APMac":"78:8A:20:2A:7B:D8"}}
19:10:20 MQT: tele/Sonoff-6758/STATE = {"Time":"2018-09-13T19:10:20","Uptime":"0T00:55:20","Vcc":3.175,"POWER1":"ON","Wifi":{"AP":1,"SSId":"Wan17","RSSI":92,"APMac":"78:8A:20:2A:7B:D8"}}
19:15:20 MQT: tele/Sonoff-6758/STATE = {"Time":"2018-09-13T19:15:20","Uptime":"0T01:00:20","Vcc":3.175,"POWER1":"ON","Wifi":{"AP":1,"SSId":"Wan17","RSSI":88,"APMac":"78:8A:20:2A:7B:D8"}}
19:20:20 MQT: tele/Sonoff-6758/STATE = {"Time":"2018-09-13T19:20:20","Uptime":"0T01:05:20","Vcc":3.176,"POWER1":"ON","Wifi":{"AP":1,"SSId":"Wan17","RSSI":90,"APMac":"78:8A:20:2A:7B:D8"}}
19:25:20 MQT: tele/Sonoff-6758/STATE = {"Time":"2018-09-13T19:25:20","Uptime":"0T01:10:20","Vcc":3.174,"POWER1":"ON","Wifi":{"AP":1,"SSId":"Wan17","RSSI":96,"APMac":"78:8A:20:2A:7B:D8"}}

So the mqtt server is being told about the status. It just seems that HA isnt getting updates on this (and one other) switch. -

Just looking at HA errorlog and I’ve noticed i’m getting the following errors too!

2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_1: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 19:49:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_1: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_1: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 19:59:48 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_1: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_1: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_2: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_2: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_3: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_3: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_4: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_4: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_5: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_5: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_6: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_6: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_7: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_7: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_8: 
2018-09-13 20:00:19 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-9215_8: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_1: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_1: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_2: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_2: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_3: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_3: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_4: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_4: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_5: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_5: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_6: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_6: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_7: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_7: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_8: 
2018-09-13 20:01:09 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-8760_8: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_1: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_1: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_2: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_2: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_3: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_3: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_4: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_4: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_5: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_5: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_6: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_6: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_7: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_7: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_8: 
2018-09-13 20:01:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7733_8: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_1: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_1: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_2: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_2: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_3: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_3: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_4: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_4: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_5: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_5: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_6: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_6: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_7: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_7: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_8: 
2018-09-13 20:02:38 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-1940_8: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_1: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_1: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_2: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_3: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_4: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_5: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_6: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_7: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 20:03:11 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-7372_8: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_1: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_1: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_2: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_2: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_3: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_3: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_4: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_4: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_5: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_5: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_6: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_6: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_7: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_7: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_8: 
2018-09-13 20:03:32 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_8: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_1: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_1: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_2: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_2: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_3: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_3: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_4: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_4: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_5: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_5: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_6: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_6: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_7: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_7: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_8: 
2018-09-13 20:03:56 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-5055_8: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_1: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_1: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_2: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_2: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_3: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_3: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_4: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_4: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_5: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_5: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_6: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_6: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_7: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_7: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_8: 
2018-09-13 20:04:21 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-2325_8: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_1: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_1: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_2: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_2: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_3: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_3: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_4: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_4: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_5: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_5: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_6: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_6: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_7: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_7: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_8: 
2018-09-13 20:04:53 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON Sonoff-6758_8: 
2018-09-13 20:05:27 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_1: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_1: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_2: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_2: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_3: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_3: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_4: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_4: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_5: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_5: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_6: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_6: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_7: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_7: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_8: 
2018-09-13 20:05:28 WARNING (MainThread) [homeassistant.components.mqtt.discovery] Unable to parse JSON serverextractor_8:

I’ve cleared those errors, and enabled debug logging for mqtt.

I toggled the switch on the tasmota webui and can see that HA is receiving the mqtt commands, but doesn’t look like it’s acknowledging them

2018-09-14 21:07:51 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:08:05 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/TazGu101/POWER: b'ON'
2018-09-14 21:09:14 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:15 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:15 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:15 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:16 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:17 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:18 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:18 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:18 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'
2018-09-14 21:09:18 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'OFF'
2018-09-14 21:09:18 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on stat/Sonoff-6758/POWER: b'ON'

I’m so confused at why it is doing this!

ok, just an update! Managed to fix the issue. I changed one line in lights.yaml to match the information that was recieved from the mqtt server. odd as it isnt different from the other switches, but hey. done!

payload_on: ‘ON’
payload_off: ‘OFF’

seems to have done the trick!

I’m using hassio and have the same problem. Did you restart HA after changing the Payload? Mine still does not work after restart. This is my lights.yaml:

  - platform: mqtt
name: "FAN"
command_topic: "cmnd/sonoff/sonoffFAN/"
state_topic: "cmnd/sonoff/sonoffFAN"
qos: 1
payload_on: "OFF"
payload_off: "ON"
retain: true

From my very limited experience, it looks like your alignment is out. It also looks like you’ve edited the wrong part of the command, it needs the power option. If your sonoff is called sonoffFAN, this “should” work.
It may also be that your have included an additional “/” at the end of line three. (not sure if that makes a difference.

 - platform: mqtt
   name: "FAN"
   command_topic: "cmnd/sonoffFAN/POWER"
   state_topic: "cmnd/sonoffFAN/POWER"
   qos: 1
   payload_on: 'OFF'
   payload_off: 'ON'
   retain: true

Thanks for your feedback. Unfortunately no success. I included the /POWER option and also the state_topic (to stat instead of cmnd).

Did I miss something else maybe?

Log into the WebUI for the sonoff, and go to the console.

look for a lines like this:

13:39:55 MQT: cmnd/Sonoff-6758/POWER = 
13:39:55 MQT: stat/Sonoff-6758/RESULT = {"POWER":"ON"}

and post what they say.

15:03:38 CMND: cmd/sonoff-LED-1245/POWER =
15:03:38 RSLT: stat/sonoff-LED/RESULT = {"POWER":"OFF"}
15:03:38 RSLT: stat/sonoff-LED/POWER = OFF
15:03:40 MQTT: Attempting connection...
15:03:41 mDNS: Query done with 0 mqtt services found
15:03:41 MQTT: Connect FAILED to 192.168.x.xx:1883, rc -2. Retry in 10 seconds

Hi goprojojo

Your lights.yaml needs to be edited, as the device is named sonoff-led-1245 i believe it should read, it also looks like you havent configured mqtt for that device. you can use the backlog command, or use the built-in mqtt page on the sonoff. without mqtt it isnt going to know the state or be able to publish a change.

  - platform: mqtt
  name: "FAN"
  command_topic: "cmnd/sonoff-LED-124/"
  state_topic: "cmnd/sonoff-LED"
  qos: 1
  payload_on: "OFF"
  payload_off: "ON"
  retain: true

Give that a try.

Hi All,
I’m banging my head against the wall so I thought I would call for help.
I thought I had configuration.yaml configured properly, but my Sonoff switch will not work with my MQTT setup.

switch:
  - platform: mqtt
    name: "LR Light"
    command_topic: "b2home/LR_lights/power"
    state_topic: "stat/LR_lights/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: true

And here is log file from Sonoff WebUI:

00:00:04 MQT: b2home/LR_lights/LWT = Online (retained)
00:00:04 MQT: b2home/LR_lights/cmnd/POWER = 
00:00:04 MQT: b2home/LR_lights/INFO1 = {"Module":"Sonoff Basic","Version":"6.2.1","FallbackTopic":"B2LR_lamp","GroupTopic":"sonoffs"}
00:00:04 MQT: b2home/LR_lights/INFO2 = {"WebServerMode":"Admin","Hostname":"B2LR_lamp","IPAddress":"<REDACTED>"}
00:00:04 MQT: b2home/LR_lights/INFO3 = {"RestartReason":"Software/System restart"}
00:00:04 MQT: b2home/LR_lights/RESULT = {"POWER":"OFF"}
00:00:04 MQT: b2home/LR_lights/POWER = OFF
18:01:16 MQT: b2home/LR_lights/STATE = {"Time":"2018-10-30T18:01:16","Uptime":"0T00:00:13","Vcc":3.142,"POWER":"OFF","Wifi":{"AP":1,"<REDACTED>"}}
18:01:16 MQT: b2home/LR_lights/SENSOR = {"Time":"2018-10-30T18:01:16","Switch1":"ON"}
18:02:00 MQT: b2home/LR_lights/UPTIME = {"Time":"2018-10-30T18:02:00","Uptime":"0T00:00:57"}
18:05:02 MQT: b2home/LR_lights/RESULT = {"POWER":"ON"}
18:05:02 MQT: b2home/LR_lights/POWER = ON
18:05:05 MQT: b2home/LR_lights/RESULT = {"POWER":"OFF"}
18:05:05 MQT: b2home/LR_lights/POWER = OFF
18:06:16 MQT: b2home/LR_lights/STATE = {"Time":"2018-10-30T18:06:16","Uptime":"0T00:05:13","Vcc":3.142,"POWER":"OFF","Wifi":{"AP":1,"<REDACTED>"}}
18:06:16 MQT: b2home/LR_lights/SENSOR = {"Time":"2018-10-30T18:06:16","Switch1":"ON"}

Can someone guide me what I might be doing wrong?

Thanks in Advance,
~Bryan

Hi Bryan,

Did you get this sorted? try replacing " with ’ for the load on and off.
(take a look at the post from the 14th and 21st above. that should help.

Hi,
Thank you for tip. I think overall I was doing a few things wrong – first of all were topics, and potentially underscore (I don’t know).

Here is what I did:

In Tasmota configuration:
Topic = sonoff1
Full Topic = %prefix%/%topic%

## in Configuration.yaml
  - platform: mqtt
    name: 'MBR - Bryan Light'
    command_topic: 'cmnd/sonoff1/POWER'
    state_topic: 'stat/sonoff1/POWER'
    qos: 1
    payload_on: 'ON'
    payload_off: 'OFF'
    retain: false

And Rob’s video at The Hookup was helpful. https://www.youtube.com/watch?v=31IyfM1gygo

Thanks for asking!

~Bryan

On Sonoff counsle type “PowerRetain 1”
On Hassio Config set the foloowing
qos: 1
payload_on: ‘ON’
payload_off: ‘OFF’
retain: true

Restart both and it should work :slight_smile: