This would be my first post on HA forums, hope I get some assistant. OK here is the scenario. This is a bit wierd issue and I have no idea where I am wrong. First let me make you understand the scenario …
HASSbian Installed on RPI 3 : working perfectly
HUE emulation done on yaml file and my z wave switch works perfectly (this is just FYI nothing to so with the actual problem)
Now I wanted to go a step further … wanted to make sonoff module work with HA. So
Loaded custom firmware tasmota on sonoff device, that works perfectly, as I can toggle the light on off from the tasmota web interface.
Installed MQTT on Hassbian Rpi3, works good. MQTT is also connected, as I can see in the tasmots web console also MQTT is working connected to Home Assistant. I did the test as well (by going to HA page services, domain MQTT publish and was able to send message to RPI3 Console …It was a success. so MQTT working perfectly.
Now adde the below lines to ymal file to be able to make HA recoganize the sonoff device
mqtt:
broker: 192.168.88.101 (ip of HA Rpi where MQTT is running)
port: 1883
client_id: home-assistant-1
username: myusername
password: mypasswor
discovery: true
discovery_prefix: homeassistant
Rebooted HA/Rpi3 and now I DO see my device sonoff listed on HA webpage, BUT here is where it gets weird, I CAN SWITCH ON THE DEVICE BUT CANNOT SWITCH IT OFF. When I click on the toggle switch, it switches on the lamp (connected to sonoff device), but the switch does not stay there, it automatically returns to off position, while the lamp is still switched on. I have to switch the lamp off via tasmota web interface or by manually clicking on the switch on the sonoff device. Then if I go to HA web interface and again click on the toggle switch the same thing happens, it switches on the device BUT toggles back to off position automatically and I cannot switch off the device from there.
I knwo strange issue and I have no idea where this might have gone wrong. If anyone has any idea please do assist.
That behavior sounds like your state topic in HASS config is wrong - check the spelling of it and for any missing characters. Is POWER really in uppercase in the actual mqtt topic?
It sounds like the command is being received but HASS is not receiving the confirmed updated state back and hence is reverting the switch status to the prior state in the HASS state machine.
Especially with QOS 1 - which I think requires acknowledgement from the MQTT server that message is received. I typically use QOS 0 without issue.
In my configuration using MQTT and Tasmota, the command_topic has “power” in upper case:
command_topic: “cmnd/sonoff102/POWER”
Otherwise looks the same except the MQTT definition on mine has two extra lines
protocol: 3.1
keepalive: 60
My MQTT is all (there’s more than Home Assistant in my network) done on another box using Mosquitto.
HTH
Nicholas
Many Many Thanks, sorted, I just changed QOS to 0 and I was able to retain the state and all working good. This is what happens when you do not know what these attributes do. Changing QOS to 0 did the trick. Thank you again for the time and assistance.
One QUICK question. I use Imperihome on my Android for my z wave devices. ImperiHome does not find these sonoff even with custom firmware, I was hoping Imperihome to find them after the firmware change., but it didnt. Maybe I am missing some basic understanding here.
Anyway what I am requesting is if you can suggest an Android App to use as an HomeAutomation HUB to control all these sonoff devices, that would be great. I am sure there must be one out there. What do yu suggest?
Thanks again for all your assistance and advice
regards
Sammy
I assume you want some simple buttons on the screen rather than opening the HASS API?
For simple buttons on screen to turn on a light or pause a media player, I use home remote on ios to make calls to the HASS HTTP API (ie post JSON to HASS for the action I want performed) - not sure if it is also on android.
I explored into HTTP API and I was very impressed by it. There is a tiny issue I am facing and I am sure its a small thing as was with above request. I have opened a new thread for it. If you can have a look and assist I would be highly grateful.