Hi,
I’ve just flashed a Ankuoo NEO that control a light with hfeasy that provide an MQTT Client that successfully connects to my MQTT Server. Here you can find the setup of the plug:
Server IP: 192.168.XX.XX /
Server Port: 1883
usr: username
psw: ****
sub_topic: cmnd/abatjour/POWER
pub_topic: stat/abatjour/POWER
QOS: 2
ON value: 1
OFF value: 0
Furthermore I’ve been able import that switch through MQTT to Home Assistant and even to control it. Here’s my HA setup:
The issue is that if the light it’s OFF and I toggle it ON actually it does but the switch, on HA, after few seconds switch back to OFF position whereas the light stay ON.
To switch it OFF I need to press twice the toggle, the first touch is needed to make the toggle matching the plug state and the second to send the MQTT command to turn it OFF.
Someone already came across this issue? Or can someone help me figure out the issue?
The payload consists of two consecutive single quotes (not one double quote). It represents an ‘empty string’.
That’s the standard behavior when the state_topic fails to receive the expected value. You turned the switch on, Home Assistant published 1 to the command_topic and then expected to receive 1 via the state_topic. It didn’t so it put the switch (in the UI) back to off.
Try this version without the lone double-quote at the start of each topic.
Then you need to confirm that the state_topic is receiving a 1 when you turn the switch on.
Ensure the switch and the physical light are off.
Go to Developer Tools > MQTT > Listen to a topic
Enter stat/abatjour/POWER then click Start Listening
Go the the UI and turn on the switch.
Go back to Developer Tools > MQTT and see what was reported. It should indicate it received a 1. If it didn’t, or reported something else, then that’s information we need to know in order to continue debugging this problem.
I have had this problem trying to test the MQTT in python. I had to set the state from the client with:
# callback for received messages
def on_message(client, userdata, msg):
if msg.topic == "homeassistant/switch/myswitch/set" :
print("SWITCH is being set to " + str(msg.payload))
data = msg.payload
client.publish(switchstatetopic, data)
Also, I had to delete as already mentioned the old states using MQTT EXplorer as mentioned.