I am not usually one for releasing stuff I write because I am my own worst critic and usually self destruct before putting anything out into the general public (I’ve revised this post more times than I’d like to count). I am trying to change that behaviour…
Although I am a software engineer by trade, I am not a Java/Groovy developer so I may not have written some of the code in the most efficient way. I expect this to change from feedback and as my knowledge grows.
I tend to find I use the app to control a lot of things more than anything else so this is useful for that. I have only used this on an Android phone and can’t be sure how it’ll behave on an iOS device due to the parity issues between Android and iOS apps so give no guarantee of how well it’ll work for you.
If people actually want to use this SmartApp, I will attempt to maintain it and add additional features when I can. I am generally quite busy and was fortunate enough to have some time to work on this to get it to where it is. Pull requests are welcome.
Anyway, I’ve been putting off posting this long enough. I hope this is of use to someone or that someone will tell me that what I’ve done is pointless and there is a better solution Either way, it was a good learning experience.
Trend Setter is a SmartApp for grouping together devices for synchronised control and/or data aggregation using virtual devices that act as a controller device and interface for other devices in the group. At present there are 4 group types:
- Switch - Group switch control
- Dimmer - Group level/switch control
- Colorful Light - Group colour/level/switch control
- Power Meter - Averaged total power usage for group with High/Medium/Low usage indicator based on previous data (Experimental, unfinished and probably very inaccurate)
This started when I got my first couple of Osram Lightify bulbs. I have 2 lamps in my lounge and wanted to be able to control the lights in a group. I tried using other solutions where a master device dictates to the other devices but wasn’t really happy with that and wanted to try something else. Technically this does the same thing except the master device is not a physical device and also gives another degree of control and state reporting.
I have tried my best to make it as easy as possible to add new group device types. Most of the behaviour is contained within the device type itself. The only thing the SmartApp knows specifically about the device is a device definition so it knows what to subscribe to and how to build the UI.
I understand that this doesn’t solve a problem that doesn’t already have a solution but I am getting some use out of this so thought I’d see if anyone else could too.
A simple switch really. Only difference is it’ll give you a percentage of how many devices in the group are turned on and give you a different state depending on if they are on, mostly on, half on, mostly off, or off.
Almost the same as a switch group, but has the ability to adjust the light level. If a device in the group is not in sync with the rest of the group - a button to synchronise the devices in the group to the most common light level can be tapped. If all the devices in the group are different levels then an average of all light levels will be used. These are reflected in the slider value.
Again almost the same as switch and dimmer but with colour control. The hue and saturation sliders behave in a similar way to the Level slider on the dimmers except that it won’t average the values across the groups as that might produce a colour you weren’t expecting. Instead it’ll use the hue/saturation last set in the group. This may not work for all RGB/Hue lights - I only have Osram Lightify RGBW bulbs at the moment
Power Meter (Experimental)
This is a work in progress and quite experimental. What it does is adds up the power usage in the group, aggregates the last 5 totals and then averages them. The reason for this is because there might be a large number of events being thrown out due to the number of devices in the group, I suspect that it makes the numbers somewhat inaccurate and I may change how this works. Maths are not my strong suit so I’ll see what happens
Using the previous totals some upper and lower average boundaries are calculated so we can classify the current usage as Low, Medium or High - with the maximum value used as a trigger to recalculate the boundaries if the current average power usage goes over the last recorded maximum value.
This power usage classification isn’t really of much use except for something to look at in the app as there isn’t a capability for it.
Note: I’m in the UK and Github integration in the IDE doesn’t work as yet so I may not have put these files in the right place.
Add the following device types to My Device Types
Add the Group child SmartApp to My SmartApps (no need to publish)
Add the Trend Setter SmartApp to My SmartApps (Publish → For me)
- I have attempted to aggregate changes to group devices as much as possible to prevent strange UI behaviour that I was witnessing. This does incur a slight delay on updates to the group device
- You CAN make sub-groups by adding a group device to another group but behaviour might be a bit odd if you also include the same devices in the parent group that are in the sub-group
- Inheritance for device types would have made this a lot easier to maintain
- Local processing would likely make a big difference as sometimes latency can cause strange behaviour
- Being able to allow device selection by specifying multiple capabilities (as if to say, ‘devices must have all these capabilities’) would be a big bonus for making a more specific list of selectable devices.
- Being able to filter out specific devices from a list of devices to be selected would also make things easier.