emontnemery / domoticz_mqtt_discovery

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

dimmers or discovered as switches #9

Closed cobradevil closed 5 years ago

cobradevil commented 5 years ago

Hi,

i have a magichome led dimmer which is configured with tasmota latest firmware (6.1.1). When i set the topic for the device and setoption15 1 and then enable homeassistant discovery i get a switch within domoticz.

07:38:06 CMD: setoption19 1 07:38:06 MQT: homeassistant/light/rgb-tasmota_1/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_1/config = {"name":"rgb-tasmota","command_topic":"cmnd/rgb-tasmota/POWER","state_topic":"stat/rgb-tasmota/RESULT","value_template":"{{value_json.POWER}}","payload_off":"OFF","payload_on":"ON","availability_topic":"tele/rgb-tasmota/LWT","payload_available":"Online","payload_not_available":"Offline","brightness_command_topic":"cmnd/rgb-tasmota/Dimmer","brightness_state_topic":"stat/rgb-tasmota/RESULT","brightness_scale":100,"on_command_type":"brightness"," ... (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_2/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_2/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_3/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_3/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_4/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_4/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_5/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_5/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_6/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_6/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_7/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_7/config = (retained) 07:38:06 MQT: homeassistant/light/rgb-tasmota_8/config = (retained) 07:38:06 MQT: homeassistant/switch/rgb-tasmota_8/config = (retained) 07:38:06 MQT: stat/rgb-tasmota/RESULT = {"SetOption19":"ON"}

Did i configured this one wrong?

Best regards, William van de Velde

emontnemery commented 5 years ago

This looks like exactly the same issue as #8, please make sure you have the latest version of the plugin.

cobradevil commented 5 years ago

@emontnemery I did the checkout yesterday.

The other issue looks the other way around where a switch is found as a dimmer but in my case it should be a dimmer and gets recognized as a switch.

emontnemery commented 5 years ago

Ah, I see! Please try to change row 571 of domoticz_mqtt_discovery/plugin.py from: if devicetype == 'light' and ('brightness_command_topic' in config or 'color_temp_command_topic' in config or 'rgb_command_topic' in config): To: if (devicetype == 'light' or devicetype == 'switch') and ('brightness_command_topic' in config or 'color_temp_command_topic' in config or 'rgb_command_topic' in config):

cobradevil commented 5 years ago

That seems to work. I will test a wemos d1 mini as a switch tonight.

Also this brings me to another question: I have added the magichome device as a dummy device in domoticz as a rgb dimmer but i couldn't control it within domoticz. Therefore i created an issue within the tasmota project for not being able to control the colors. But with the above line changed and the plugin adds the device it now seems to work (changing the colors e.g.), any idea why that would be? https://github.com/arendst/Sonoff-Tasmota/issues/3547

Best regards, William

emontnemery commented 5 years ago

Did you have time to test yet?

cobradevil commented 5 years ago

I did test the plugin with the above change and this solve the issue for both a wemos d1 mini with a relay configured to be recognized as a light switch and a magichome rgb device recognized as a rgb dimmer. Best regards, William

emontnemery commented 5 years ago

Thanks for confirming!

emontnemery commented 5 years ago

Fixed in 3ff47f1