stas-demydiuk / domoticz-zigbee2mqtt-plugin

zigbee2mqtt plugin for domoticz
MIT License
136 stars 98 forks source link

Create device upon zigbee group creation #111

Closed kireque closed 4 years ago

kireque commented 5 years ago

Not sure if this has been asked before...

It would be neat if a switch is being created within Domoticz when a group is created in the Zigbee2Mqtt configuration.

Also the state of a group member is not updated when a command has been sent to the group (or is this a zigbee2mqtt issue?)

salopette commented 5 years ago

Hi, I do not have a solution for you, but how do you create a group? Can you explain that to me?

HJKLMN commented 5 years ago

http://www.zigbee2mqtt.io/information/groups.html

stas-demydiuk commented 5 years ago

@kireque it looks like currently it is isn't possible to receive group list from zigbee2mqtt gateway, so I don't see how support can be implemented

kmccor commented 5 years ago

Hi, would you consider looking at this again? I've just been reading up on the current state of group support and the capability to query for group lists has been added. I've done some manual testing with MQTT commands on a light group I have configured and it works well.

https://www.zigbee2mqtt.io/information/mqtt_topics_and_message_structure.html

"groups": a list of all groups, this message can be triggered by sending a message to zigbee2mqtt/bridge/config/groups (payload doesn’t matter).

jstam84 commented 4 years ago

Any status update on this? Better user experience if this is implemented :)

Luigi8723 commented 4 years ago

+1 I like also to see the groups as a device in Domoticz since Domoticz is not capable of creating a group dimmer. This way its possible to set multiple Ikea Tradfri GU10 spots to the same setting, i hope.

Anjerlaan commented 4 years ago

Here the same problem with the IKEA GU10 Spots 1537R6 and an IKEA Remote 1524/1810 in domoticz/zigbee2mqtt. I can pair the bulbs in Z2M and add them to a group I can pair the IKEA Remote 1524/1810 in Z2M and bind it to the bulbs GroupID

The problem is with the remote that it has no converters according to Z2M, therefor Z2M can't set the remote to a certain a state, it only receives a state when one of the physical buttons of the remote are pressed. The only thing that works in Z2M is to set a state to the group of bulbs, the remote also gets the info to what state the group was set.

This is the same in domoticz, when I click on the domoticz IKEA remote ON/OFF button which was created by your plugin, there is no respond, but when i click on the ON/OFF button of the remote itself the ON/OFF button in domoticz does respond to ON or OFF.

So the only way to let is work correctly is to get a Z2M group into Domoticz as a device or something. Or to set a Z2M state with a JSON command when a vitual switch is turned ON/OFF (Is this possible?)

Anjerlaan commented 4 years ago

For people who are interested, a programmer on the Domoticz site created an example dzVents script which controls a zigbee2mqtt group of (dimmable) bulbs with a domoticz virtual dimmer switch. Works like a charm! https://www.domoticz.com/forum/viewtopic.php?f=4&t=30077&start=40#top

stas-demydiuk commented 4 years ago

Basic support (get current state, on/off) for zigbee groups was added to plugin. I wonder if someone could test and provide feedback.

Anjerlaan commented 4 years ago

Basic support (get current state, on/off) for zigbee groups was added to plugin. I wonder if someone could test and provide feedback.

I updated the plug-in and restarted Domoticz. Here is my Feedback:

Since I could not find a description, I assume Z2M groups are automatically discovered and linked to an on/off switch? Anyway, domoticz did not automatically discover a new (Group) ON/OFF switch in the devices tab.

I noticed in the branch devices_manger.py....filename typing error. Renamed it to devices_manager.py, restarted Domoticz, but still no auto discovery

Log: 2020-02-03 18:32:35.645 Error: Zigbee hardware (14) thread seems to have ended unexpectedly

stas-demydiuk commented 4 years ago

Could you please rename file back and check what is in Domoticz log?

Anjerlaan commented 4 years ago

Okay renaming devices_manger.py to devices_manager.py, and restart domoticz caused the error.

I renamed it back to devices_manger.py, deleted all existing zigbee devices in the devices list and restarted Domoticz.......and the group on/off switch popped up in the devices list:

afbeelding

I added the switch but it does not respond when using the switch ON/OFF button The Wall Outlet icon (A) does not change state when clicking on it The Switch Icon (B) can switch ON/OFF but does not change the state.

afbeelding

...it only changes state (On/Off) when the zigbee2mqtt group is set to ON or OFF (when using my old script)...looks like the same problem as with the Remote?

stas-demydiuk commented 4 years ago

Didn't expect that someone will use '_' in group name :) Fixed

Anjerlaan commented 4 years ago

Well I am from the DOS generation: in file and directory names no spaces and special characters ;-)

Anjerlaan commented 4 years ago

Working!

Anjerlaan commented 4 years ago

Nice work!.....euhm...Virtual Dimmer Switch? ;-)

I posted a link a few posts up here. This guy created a dzVents script based on my Keuken_Spots Group example. My Group has these attributes {"state": "ON", "brightness": 200, "color_temp": 350} It only uses state (ON/OFF) and brightness value to dim, the color_temp is fixed and the script has an initial brightness value...

But I guess users with Color Bulbs have different attributes, which is more difficult to implement? In Home Assitant they work with a config file to setup groups Maybe Domoticz "user variables" can be used here?

The dimmer switch I prefer to use, because now I can also dim the group switch in Google Home with my voice

stas-demydiuk commented 4 years ago

I can't come up with script how to get user an ability to choose what device should be created depending on particular group. That's why only On/Off is implemented because I guess it is available for all groups.

Anjerlaan commented 4 years ago

Maybe Domoticz "user variables" can be used here?

https://github.com/kungknut/Domoticz-MQTT-Translator

stas-demydiuk commented 4 years ago

Or maybe define some naming convention for group, for example "dimmer" keyword in the group name will force plugin to create Dimmer

Anjerlaan commented 4 years ago

Can't you assume that if there is a "brightness" attribute in the Group or Device of the group, that the user wants a dimmer switch? The Initial "brightness" value could be set/modified with a "user variable"

If the user still wants the Group to be used as an ON/OFF switch: change the switch type to ON/OFF switch-->=condition in the py script to select the ON/OFF type

stas-demydiuk commented 4 years ago

Unfortunately group should be created before plugin receive first message from it

Anjerlaan commented 4 years ago

And if the created group is created, write a "user variable" in domoticz, with info something like this:

[["Zigbee Group Name 1", "Switchtype": "Dimmer/OnOff",{"idx": "xxx"}, "GroupDevices": "bulb1, bulb2,etc.", "detected group attributes: ", "initial brightness value"],
["Zigbee Group Name 2", "Switchtype": "Dimmer/OnOff",{"idx": "xxx"}, "GroupDevices": "bulb1, bulb2,etc.", "detected group attributes: ", "initial brightness value"],
["Zigbee Group Name 3", "Switchtype": "Dimmer/OnOff",{"idx": "xxx"}, "GroupDevices": "bulb1, bulb2,etc.", "detected group attributes: ", "initial brightness value"]]

Which can be modified afterwards to the users needs?

Anjerlaan commented 4 years ago

Or maybe define some naming convention for group, for example "dimmer" keyword in the group name will force plugin to create Dimmer

Well if Home Assistant users have to modify a config file first to make groups work, then it is not strange to make a helpfile for your domoticz plugin with an "add Z2M groups" section, which explains how to name friendly_name zigbee2mqtt Groups in order to set the correct switchtype

stas-demydiuk commented 4 years ago

@Anjerlaan I've extended groups support and added recognition of 2 additional suffixes: _dimmer for dimmer switches _ct for dimmer + color temperature switches

For example in your case, group name should be Keuken_Spots_ct

I wonder if you could update plugin and check it.

Anjerlaan commented 4 years ago

I will...but if I rename the group in Z2M, I have to bind the remote and add the bulbs again I guess? Can't find anything in the Z2M topics & message structure docs

stas-demydiuk commented 4 years ago

I'm not sure about this. Devices are bound to group_id not to its name

Anjerlaan commented 4 years ago

But binding is using friendly name, also adding bulbs use friendly name

Anjerlaan commented 4 years ago

@Anjerlaan I've extended groups support and added recognition of 2 additional suffixes: _dimmer for dimmer switches _ct for dimmer + color temperature switches

For example in your case, group name should be Keuken_Spots_ct

My group dimmer (dzVentz script) only changes state and brightness color_temp is set to a fixed value, since the color_temp buttons (right-left) on the IKEA remote are not recognized in zigbee2mqtt...

should i call the group _dimmer or _ct then? (otherwise i may have to setup the group and binding twice ;-)

Anjerlaan commented 4 years ago

Works!:

  1. Stop zigbee2mqtt

  2. Rename zigbee2mqtt group friendly name in configuration.yaml to group_name_ct

  3. Start zigbee2mqtt

  4. Group is successfully renamed...everything still works, also bounded remote

  5. Remove all Zigbee devices in domoticz

  6. Stop Domoticz

  7. Update domoticz-zigbee2mqtt-plugin

  8. Start Domoticz

  9. afbeelding

  10. Add Switch to domoticz

  11. afbeelding

Anjerlaan commented 4 years ago

Nice Work!

Any ideas yet to set an initial brightnes/color_temp value when turned on? In my case I probably only want a _dimmer

Anjerlaan commented 4 years ago

What is the idea of this?:

afbeelding

Anjerlaan commented 4 years ago

Domoticz-->Controlicz-->Google Home (voice commands) also work like a charm

Anjerlaan commented 4 years ago

I notice one thing compared to my dzVents Script, that the dimming of the group in the dzvents script is smoother and more evenly

Anjerlaan commented 4 years ago

Maybe it is also nice to create a group icon (e.g. 3 bulbs) for this type of switch?

Bulbs

stas-demydiuk commented 4 years ago

It is very strange as algorithm of calculating brightness is the same. What do you mean by smoother?

Anjerlaan commented 4 years ago

The transition between brightness levels in your algorythm is slower and a bit hiccuping...and the bulbs are not in sync during transition

stas-demydiuk commented 4 years ago

Groups support is available starting from plugin v.0.1.0