emontnemery / domoticz_mqtt_discovery

MQTT discovery plugin for Domoticz
MIT License
40 stars 27 forks source link

Switches discovered as dimmers #8

Closed mvveelen closed 6 years ago

mvveelen commented 6 years ago

Hi,

I've been using this plugin for a few months now, but suddenly some of the devices are set as a dimmer. When I correct this and restart Domoticz, theses switches are discovered as dimmers again. I'm using the latest Beta from Domoticz (v4.9822) and the latest firmware for the Sonoff switches (6.11).

When I compare the Sonoff devices (some are still 'switches'), I see no settings which explain why one is discovered as an on/off switch and some others as dimmers. Is this due to the Domoticz version (no others have reported this)? Or due to the Tasmota firmware version (I tried older versions, but the issue stays the same)? Or does the plugin needs some tweaking?

emontnemery commented 6 years ago

This sounds strange..

Can you please follow this sequence to debug:

  1. On domoticz hardware page, change debug to "True" for the plugin
  2. Press "Update" to restart the plugin
  3. Remove one of the devices incorrectly identified as dimmer
  4. On domoticz hardware page, press "Update" to restart the plugin and rediscover the removed device

Then attach resulting log here.

mvveelen commented 6 years ago

Well, I did exactly follow these steps, but that didn't work to get the device back.

I had to go to the device (console) and enter 'setoption19 1' to force the discovery of the device. Just updating the MQTT hardware from Domoticz didn't do anything. Ofcourse the device is back as a dimmer....

The logfile is attached. At 12:16:10pm I entered the 'setoption19 1' in the console. The result is in the logfile.

Naamloos.txt

I hope it's something stupid I do wrong, but I just can't seem to find what it might be.

Edit:

this is what the console of the device tells me:

12:16:10 CMD: SetOption19 1 12:16:10 MQT: homeassistant/switch/sonoff42_1/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_1/config = {"name":"CV Ketel (Sonoff TH16)","command_topic":"cmnd/sonoff42/POWER1","state_topic":"stat/sonoff42/RESULT","value_template":"{{value_json.POWER1}}","payload_off":"OFF","payload_on":"ON","availability_topic":"tele/sonoff42/LWT","payload_available":"Online","payload_not_available":"Offline"} (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_2/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_2/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_3/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_3/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_4/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_4/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_5/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_5/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_6/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_6/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_7/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_7/config = (retained) 12:16:10 MQT: homeassistant/switch/sonoff42_8/config = (retained) 12:16:10 MQT: homeassistant/light/sonoff42_8/config = (retained) 12:16:10 MQT: stat/sonoff42/RESULT = {"SetOption19":"ON"} 12:16:12 MQT: tele/sonoff42/STATE = {"Time":"2018-08-12T12:16:12","Uptime":"0T18:19:00","Vcc":3.264,"POWER1":"ON","Wifi":{"AP":1,"SSId":"FiFi","RSSI":26,"APMac":"F0:9F:C2:27:8D:F6"}} 12:16:12 MQT: domoticz/in = {"idx":57,"nvalue":0,"svalue":"24.6","Battery":66,"RSSI":2} 12:16:12 MQT: tele/sonoff42/SENSOR = {"Time":"2018-08-12T12:16:12","Switch4":"ON","DS18B20":{"Temperature":24.6},"TempUnit":"C"}

Actually: when I enter the "SetOption19 1" to the console, without deleting the device first in Domoticz, the device changes into a dimmer too ! Other settings stay the same, but the device is changed from an on/off switch into a dimmer. Huh?

emontnemery commented 6 years ago

Thanks for the log!

I think your problem is that your device is announcing itself as a "light" instead of as a "switch". The plugin is assuming that a "light" can always be dimmed, it seems Tasmota code has changed and that's no longer true

I think you have set SetOption30 to 1, try to:

  1. Remove the device
  2. SetOption30 0
  3. SetOption19 1

If this works, I will update the plugin to handle a non-dimmable light.

mvveelen commented 6 years ago

Wow, that's it! This works like a charm.

Thank you for this solution, I'll check all my devices (the Sonoff's can only switch on/off) and use this option to force it to be just a switch. Thanks again !

emontnemery commented 6 years ago

There should now be a proper fix in 34cdf2347dad1759df3b708aaa1f181176f9e6e3. Would you mind updating the plugin, and verify that your switches now also work with option30 set to 1?

mvveelen commented 6 years ago

I followed these steps:

Overwritten 'plugin.py' in the plugin folder of Domoticz Restarted Domoticz In the console of the device: 'setoption30 1' It seems to be OK now.

emontnemery commented 6 years ago

Great, thanks for testing!