moroen / IKEA-Tradfri-plugin

A Python plugin for Domoticz to controll IKEA Gateway
68 stars 23 forks source link

support for groups and moods #7

Closed mo8Zomo0 closed 6 years ago

mo8Zomo0 commented 6 years ago

Hi!

Besides a the GW sometimes hanging, I guess thats more a Trådfri bug and a GW restart fixes it) this tool works fine for me. So thank you! I could not find the functionality nor in the code, it looks like groups and moods are not supported?

It would be great if it would be!

moroen commented 6 years ago

Thanks for the feedback! I figured that groups and moods (=scenes) should be handled by Domoticz, but I'll look into it of you could provide me with a use-case?

mo8Zomo0 commented 6 years ago

I think it can be quite handy if you already have them and you use not only Domoticz as the master of all to have the functionality. Also when you did not start with Domoticz and you already have a bigger setup of groups and moods it gets you going quicker to have the results you want.

Also on the ikea system its quite easy to add bulbs to groups and you need groups for their switches anyhow. Now you would have to add the new device and add that to your Domoticz scene where it would already work if you could control the group.

Btw, I also have a hue bridge, the Domoticz integration supports groups there as well.

moroen commented 6 years ago

Interesting! As I don't have a hue, I have no idea how groups works from the user's perspective, but I figure that a group could be implemented as a single Device in domoticz? So that if you switch that single device, all lights in the groups get switched? And the same for moods, they could be implented as a device as well?

leejoow commented 6 years ago

Currently I have this implemented using a LUA script, but this way I don't get feedback if the devices are changed by the remote control. So group control as a single device would be really helpful.

moroen commented 6 years ago

Thank you for all feedback, I'll take a look at implementing groups as a device, I have a pretty good idea on how to do this... What about moods as a device?

mo8Zomo0 commented 6 years ago

Hi!

Yes, a group should work fine as a single device, to turn it on of, dim or set the colour temperature.

The hue implements the scenes (thats their name for what IKEA calls mood):

screen shot 2017-09-04 at 15 51 52

But I would say it might be better a scene in Domoticz if you can auto add that.

Never tried if you can subscribe to a mood, but at least on a group that should be possible, so your 5 lamp living room light is just used as one device.

I would still list the group as well as the independent lamps as devices.

moroen commented 6 years ago

Latest commit in development branch introduces support for groups as devices, with state change observation. Devices in a group also available as individual devices.

leejoow commented 6 years ago

Nice, I've added a comment to the commit, just for code cleaniness. If I'm correct, groups have moods, it might be an idea to add those, the same way as white levels are available for bulbs?

Will you evantually pull the changes in the master, which will comply to the latest stable Domoticz release? If not, I can try to make a version which works in both cases (both stable and beta).

moroen commented 6 years ago

Thanks!

I'm thinking about moods, but I must confess that it's not high on my list at the moment, since moods are "kind of" supported by scenes in domotics,. Hopefully the "official" API will be available sometime soon, and perhaps much of the work on the plugin then will be unecessary? Here's hoping it's implemented with http and json, making the whole twisted-backend obsolete...

As to updating "master" with the new functionallity is next on my list, but feel free to give it a shot if you like. It should be just a matter of changing the function signatures.

mo8Zomo0 commented 6 years ago

The question is how IKEA will implement the API. To be honest, I think COAP is not bad, especially as you can subscribe to changes. I have to try the groups functionality, thank you for your work!

moroen commented 6 years ago

I agree, COAP is not bad at all. I would prefer http/json simply because the python-plugin framwork supports those natively, eliminating the need for a "coap-adaptor", but time will tell. If the api turns out to be COAP, I guess it'll be time to judge between continuing using a service as an adaptor, or look at the possibility of implementing COAP as a protocol in the plugin-framework...

moroen commented 6 years ago

Updated master branch with support for groups.