enesbcs / shellyteacher4domo

Shelly device teacher for Domoticz MQTT Autodiscovery hardware
Apache License 2.0
10 stars 4 forks source link

Dimmer devices does not change state #30

Closed enesbcs closed 8 months ago

enesbcs commented 11 months ago

In case anyone added Shelly Dimmer devices with an old (before Oct. 2023) ShellyTeacher and Dimmer devices does not change its states under latest Domoticz beta, please download a fresh ShellyTeacher, delete Dimmer devices from Domoticz and re-teach them.

It is necessary as configuration object changed in 2023.10.11 and "state_on" and "state_off" property is used to detect current state.

See https://github.com/enesbcs/shellyteacher4domo/issues/26

Xavier82 commented 11 months ago

Hi Alexander,

So I want to test this with new version of ShellyTeacher4Domo, do I only need to delete the device "shellydimmer-XXXX-Light-0" or do I need to delete the all the devices of "shellydimmer-XXX" ?

Xavier82 commented 11 months ago

tested in Beta and works, when using slider on gui of Shelly then the slider in Domoticz is being updated. So seems to work, thanks! btw: I only removed the shelly XXX light-0 device not al the devices of the dimmer.

enesbcs commented 11 months ago

tested in Beta and works, when using slider on gui of Shelly then the slider in Domoticz is being updated. So seems to work, thanks! btw: I only removed the shelly XXX light-0 device not al the devices of the dimmer.

Yes you are right, only the 'light-0' devices are dimmer devices, switches and other sensors dont need to be deleted as only the light scheme changed.

Xavier82 commented 11 months ago

So I ran into an other issue for all Shelly Dimmers (1 and 2). After upgrading to new Shellyteacher4Domo files and removing the old light device, Domoticz was creating new lioght devices for the dimmers as mentioned in previous post. But now when doing more test I come to the conclusion that the device works different.

I still have old shelly python hardware with a shelly 2 dimmer device called "Spots kitchen"of the type "Light/Switch, Switch, Dimmer" and I have the new created device (based on new shellyteacher4Domo) called "Spots Kitchen - Lights 0". When sliding the dimmer slide of the device "Spots Kitchen - Lights 0" the lamp in the kitchen actually goes on and goes to the position of the slider (25% or 40% of 67% or whatever). The device of the old Shelly python scripts moves along with the same %, but there is 1 big difference!

When pressing the "on/off" button of the device "Spots kitchen" (which is from the old Shelly Python script) the lamp goes on or off (whatever the state and/or the position of the slider is) but the "on/off" button from the device "Spots Kitchen - Lights 0" only seems to know the position of "On", when pressing the button for a second time of the device "Spots kitchen" then the lamp goes back on but the button of the device "Spots Kitchen - Lights 0" remains "on". When pressing the on/off button of the device "Spots Kitchen - Lights 0" the device "Spots Kitchen" goes off but the "Spots Kitchen - Lights 0" stays on, just like it reacts like only a push on button function.....

Any ideas about this?

enesbcs commented 11 months ago

So I ran into an other issue for all Shelly Dimmers (1 and 2). After upgrading to new Shellyteacher4Domo files and removing the old light device, Domoticz was creating new lioght devices for the dimmers as mentioned in previous post. But now when doing more test I come to the conclusion that the device works different.

I still have old shelly python hardware with a shelly 2 dimmer device called "Spots kitchen"of the type "Light/Switch, Switch, Dimmer" and I have the new created device (based on new shellyteacher4Domo) called "Spots Kitchen - Lights 0". When sliding the dimmer slide of the device "Spots Kitchen - Lights 0" the lamp in the kitchen actually goes on and goes to the position of the slider (25% or 40% of 67% or whatever). The device of the old Shelly python scripts moves along with the same %, but there is 1 big difference!

When pressing the "on/off" button of the device "Spots kitchen" (which is from the old Shelly Python script) the lamp goes on or off (whatever the state and/or the position of the slider is) but the "on/off" button from the device "Spots Kitchen - Lights 0" only seems to know the position of "On", when pressing the button for a second time of the device "Spots kitchen" then the lamp goes back on but the button of the device "Spots Kitchen - Lights 0" remains "on". When pressing the on/off button of the device "Spots Kitchen - Lights 0" the device "Spots Kitchen" goes off but the "Spots Kitchen - Lights 0" stays on, just like it reacts like only a push on button function.....

Any ideas about this?

Please show me the "Spots Kitchen - Lights 0" device retained config object from MQTT Explorer. It must be under homeassistant/light/shellydimmer-xxxx-0/config

Xavier82 commented 11 months ago

Sure here is the retained config: { "name": "shellydimmer2-XXXX Light 0", "cmd_t": "~light/0/set", "stat_t": "~light/0/status", "payload_on": "{\"turn\":\"on\"}", "payload_off": "{\"turn\":\"off\"}", "value_template": "{{value_json.ison}}", "stat_tpl": "{%if value_json.ison==true%}ON{%else%}OFF{%endif%}", "brightness_command_topic": "~light/0/set", "brightness_state_topic": "~light/0/status", "brightness": true, "color_mode": true, "supported_color_modes": [ "brightness" ], "brightness_scale": 100, "bri_val_tpl": "{{value_json.brightness}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shellydimmer2-XXXX-light-0", "qos": 0, "~": "shellies/shellydimmer2-XXXX/" }

enesbcs commented 11 months ago

Sure here is the retained config: { "name": "shellydimmer2-XXXX Light 0", "cmd_t": "~light/0/set", "stat_t": "~light/0/status", "payload_on": "{\"turn\":\"on\"}", "payload_off": "{\"turn\":\"off\"}", "value_template": "{{value_json.ison}}", "stat_tpl": "{%if value_json.ison==true%}ON{%else%}OFF{%endif%}", "brightness_command_topic": "~light/0/set", "brightness_state_topic": "~light/0/status", "brightness": true, "color_mode": true, "supported_color_modes": [ "brightness" ], "brightness_scale": 100, "bri_val_tpl": "{{value_json.brightness}}", "avty_t": "~online", "pl_avail": "true", "pl_not_avail": "false", "uniq_id": "shellydimmer2-XXXX-light-0", "qos": 0, "~": "shellies/shellydimmer2-XXXX/" }

Sorry this is an old config object, state detection will not work in newer Domoticz, exactly as you wrote, without the state_on / state_off.

Please download a current ShellyTeacher, delete dimmer devices from Domoticz and reteach them, until you see "state_on" and "state_off" in the config object.

Xavier82 commented 11 months ago

ok, so I remove again the dimmer light-0 devices in Domoticz then?

I already did that last time and with current version ShellyTeacher the were recreated again....

I will try again.

Xavier82 commented 11 months ago

There's something strange going on with the shellyteacher4domo script. My ShellyPro4PM isn't found anymore and neither different types of shelly dimmer 1 and/or 2 are not found after reboot of the Shelly devices. Something else strange is that other shelly dimmer 2 are found after reboot. Any idea why this could happen? I double checked the MQTT setup on the Shelly devices and they are equal to those who are found.

I think this is the problem why I didn't rediscovered the shelly dimmer2 light-0 device....

For those devices who were re-found it now works.

enesbcs commented 11 months ago

Any idea why this could happen? I double checked the MQTT setup on the Shelly devices and they are equal to those who are found.

Try to enable debug mode in ShellyTeacher (also you can force it to console mode with -c parameter in command line) and see if you got any announce messages from Dimmer devices. (In the meantime you can double check these messages with MQTTExplorer)

Gen1 devices should announce itself into shellies/announce topic (maybe you can try to disable MQTT on devices which not found, than enable it again)

Gen2 devices like ShellyPro4PM needs "RPC over MQTT" settings to be enabled, otherwise it wont respond to RPC getinfo commands. They send its online state into deviceID/online topic and if RPC works they will send their informations into shellies_discovery/rpc topic.

If this announcement is not arrived, there is nothing the Teacher can do for you.

Did you delete ShellyPro4PM? It was unnecessary as its not a dimmer device, at least i do only switch templates to them which did not changed.

Xavier82 commented 11 months ago

UPDATE!!!

I restarted the raspberry in total. I think something didn't work anymore as it should be. After restart even MQTT Explorer now catches all devices and ShellyTeacher4Domo (CLI and GUI) now also get all devices. I think something happened to the MQTT Mosquito broker..... Accept the ShellyPro4PM still doesn't show up in ShellyTeacher4Domo. The other devices seem to work now.

SO I removed entire directory and reinstalled shellyteacher4domo. When using CLI the app only fetches the shellyplus2pm, not the dimmer2 nor the shellypro4pm.

Even after reboot of the devices nothing is fetched in shellyteacher4domo (CLI and GUI!).

In MQTT Explorer I can see al my shellies, they are all announced. This is the data for the ShellyPro4PM: Topic: shellypro4pm-XXXXX/debug/log

Value of log: shellypro4pm-XXXX1346 1698963558.373 1|shos_rpc_inst.c:230 Shelly.GetStatus via HTTP_in GET 192.168.0.197:7901 user admin I didn't delete anything in Domoticz.

enesbcs commented 11 months ago

UPDATE!!!

I restarted the raspberry in total. I think something didn't work anymore as it should be. After restart even MQTT Explorer now catches all devices and ShellyTeacher4Domo (CLI and GUI) now also get all devices. I think something happened to the MQTT Mosquito broker..... Accept the ShellyPro4PM still doesn't show up in ShellyTeacher4Domo. The other devices seem to work now.

Please show me the console log of ShellyTeacher of this ShellyPro4PM, and config objects if they are created.

In MQTT Explorer I can see al my shellies, they are all announced. This is the data for the ShellyPro4PM: Topic: shellypro4pm-XXXXX/debug/log

Value of log: shellypro4pm-XXXX1346 1698963558.373 1|shos_rpc_inst.c:230 Shelly.GetStatus via HTTP_in GET 192.168.0.197:7901 user admin I didn't delete anything in Domoticz.

In case the Teacher finds a Gen1 device, and unable to decide its model, it tries HTTP Getstatus command... but should never happen on a Gen2 device.

Xavier82 commented 11 months ago

I don't know what u mean by showing the console log of ShellyTeacher, ShellyPro4PM is not being recognized so not visible by ShellyTeacher so nothing in consolelog.

Xavier82 commented 11 months ago

Lets split this topic.

For now the issue "Dimmer devices does not change state" can be closed since this is working now and has nothing to do with the issue of the ShellyPro4PM.

I will continue in issue "Issue with MQTT energy value on ShellyPro4PM"

Xavier82 commented 11 months ago

this ticket can also be closed. State is updated correctly now in new beta release from 15621. Remove old "light" device in Domoticz and rerun shellyteacher4domo.

enesbcs commented 11 months ago

Thank you for your feedback! This ticket is barely informational, pinned to top and remains for 2 month for other users,

TheLion commented 10 months ago

I do have a slightly different issue with both my Dimmer 1 devices. The devices are created in Domoticz and work as intended when switched manually, but strangely enough they don't switch on or off when switched through a LUA event with

commandArray ['Light'] = "On"
commandArray ['Light'] = 'Set Level 50'

Nothing happens and no errors are displayed in Domoticz log.

With the old ShellyMQTT plugin, this worked/works just fine.

Xavier82 commented 10 months ago

@TheLion Which version of Domoticz are u using? And which version of ShellyTeacher4Domo are u using?

enesbcs commented 10 months ago

commandArray ['Light'] = "On" commandArray ['Light'] = 'Set Level 50'

Tested your code above with Domoticz 2023.2 (build 15601) after using ShellyTeacher 0.5 and works without problem. Test device: Shelly Bulb in White mode, as a dimmer.

Also tested and works dzVents below:

domoticz.devices('Light').switchOn()
domoticz.devices('Light').dimTo(50)
TheLion commented 10 months ago

@TheLion Which version of Domoticz are u using? And which version of ShellyTeacher4Domo are u using?

Using Domoticz v2023.2 and ShellyTeacher4Domo v0.5

TheLion commented 10 months ago

commandArray ['Light'] = "On" commandArray ['Light'] = 'Set Level 50'

Tested your code above with Domoticz 2023.2 (build 15601) after using ShellyTeacher 0.5 and works without problem. Test device: Shelly Bulb in White mode, as a dimmer.

Also tested and works dzVents below:

domoticz.devices('Light').switchOn()
domoticz.devices('Light').dimTo(50)

Interesting.

Will check and/or delete and re-create the devices. It puzzles me why it does work when switching manually and not from a LUA script. Other (Shelly and other) devices work just fine from the same script.

enesbcs commented 10 months ago

Will check and/or delete and re-create the devices. It puzzles me why it does work when switching manually and not from a LUA script. Other (Shelly and other) devices work just fine from the same script.

I do not know how Domoticz handles the devices internally, but i can tell you that if your dimmer teached using a template file older than 2023.10.11 and misses "state_on" and "state_off" from its MQTT config object, than it stays in permanent "off" state. However it seems working when you click manually on it, but does not sync with incoming values as it is in "off" state.