SmartThings Community

[RELEASE] Trend Setter

smartapp_misc
smartapp_lighting
dth_lighting

(Chris) #1

Trend Setter - A SmartApp for grouping devices

Read First

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 :smiley: Either way, it was a good learning experience.

What is Trend Setter?

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)

Why did I make this?

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.

Group Types

Switch
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.

Dimmer
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.

Colorful Light
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 :smiley:

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.

Installation

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)


Notes

  • 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.

Group dimmer that actually works with v2 hub?
How to create a virtual dimmer?
Single button for numerous bulbs in one room?
Advice on dimming groups of CREE led bulbs
Is there anyway to assign groups of lights within the app?
New App: Control lighting in great detail with button devices (Aeon Minimote, Enerwave ZWN-SC7)
An idea - Power monitor compiler
Lighting Group Creation
Cree connect
[RELEASE] HomeSeer Dimmer and Switch (HS-WD100+ / HS-WS100+) Device Handlers
Setting up BR30 bulbs
Anyway to group 3 lightify bulbs together?
Lightify Firmware Updates?
[RELEASE] Fibaro RGBW Controller (FGRGBWM-441) - Advanced DTH
Using webCore With virtual dimmer confusion
Lightgroups
Osram / Sylvania Lightify Strip - Smart Lighting Mirror Switch Behavior
Switch to switch ( Big Switch for Dimmers?)
One lamp to controll others
[UPDATED] Osram Lightify RGBW A19/BR30 US version (HA) DTH
Is there an easy way to set lighting for various moods?
OSRAM RGBW Bulbs Group & Virtual Control
DTH to sync muliple lightify flex strip lights?
[UPDATED] Osram Lightify RGBW A19/BR30 US version (HA) DTH
What is in your smartapp arsenal?
Anyone write code to create a virtual device that uses a in-wall switch module and smart bulb into 1 virtual device?
Any Way of Merging 2 Separate Sets of 3-Way Switch Instances?
Sync z-wave dimmer status to cree zigbee bulb?
IKEA Trådfri - Synchronize dimmer and colour
Sync garage door
IKEA Trådfri
Grouping Bulbs togther for IFTTT Toggle On/Off?
Group things?
CoRE - Get peer assistance here with setting up Pistons
Hue lights turning on and off in a parallel
Linking Two Z-Wave Dimmers?
Linking 4 bulbs?
Smart Lighting weirdness with LIFX bulbs
Combine Multiple Smart bulbs into one Switch for ActionTiles
Need to be able to edit Trend Setter thread
How are light groups not supported yet?
Switch to turn on Alexa Group
Device naming?
1 light switch to control 2 wifi lightbulbs
Trend setter
[RELEASE] SmartLife (H801) RGBW LED Strip Wifi Controller & Bulb
Who designed this UI?
CoRE and Piston Rules Engine, first design steps
Combine Multiple Smart bulbs into one Switch for ActionTiles
IKEA Trådfri
Groups to use in Alexa?
App for color control with a group of lights
Group Lighting Devices and Control Them as a Single Device?
How can you group devices so one command turns on multiple lights at the same time without a popcorn effect?
Group ge link bulbs
Switched from WEMO app....what I'm finding
Multiple Switch Control
CoRE? SceneMachine? Other? Looking for Synchronized Dimmer
Link Cree LED bulbs
Hue Room/Group Support
Hue Room/Group Support
Help after searching the forums. Google Home -> IFTTT -> Simulated Switch -> Multiple Lights
Upcoming Visual Updates
CoRE - Get peer assistance here with setting up Pistons
List out your SmartThings automations
Error occurred in trend setter
Using Virtual Switch to turn on and off multiple lights issue
I know there's no grouping but
Old question, looking for current answer...grouping similar items
Set of Lights DeviceType
Virtual Switch created - how to attach 3 smart lights in hallway? Stumped
Best SmartApp to sync two switches?
[Release] Z-Wave.me, Popp, & Devolo Wireless wall Controller & Key Fob (EU), with button controller dimming apps and CoRE integration
Lightify RGBW Spots
Phillip hue lights grouping?
(Brian) #2

Awesome. I was considering building an aggregate device for HEM’s (energy), this looks very interesting for all devices. Nice.


(Tim Slagle) #3

Awesome work man!



(Bobby) #4

This is awesome! And works well with my Hue Bulbs. Thank you!


(James) #5

This is exactly what I was looking for. I also tested this with my Hue bulbs and it worked as expected.

I did notice that when adjusting the level sometimes the slider will bounce back to the previous level setting before returning to the new level. I’m assuming this happens when you are syncing the lights in the group. Is this the expected behavior?


(Chris) #6

:smiley:

It’s not quite what I’d expect no. Is there anything in the Recent Activity that shows the original value being set then the value you were changing it to? If that’s the case then it’s likely the Hue has sent out a level change event before changing the level to what was requested. If not, it might be a quirk of the mobile app :confused:

Difficult to know without being able to see it myself.

Glad it works otherwise though :smiley:

I get a few strange bits of behaviour sometimes with my lights where one will just stop changing colour for a few times but the other keeps up fine but I’m putting that more down to the fact that it’s running in the cloud and my connection to it may not always be that reliable.


(Adam V) #7

This is brilliant - can’t wait to test out - I’ve been using color coordinator app to achieve something similar but every now and again the lights go out of sync and the behaviour gets weird - Here’s hoping that this solves all the problems!


(Chris) #8

:smile: I do get the odd occasion where my lights go out of sync for no reason but I’m putting that down to the bulbs themselves since nothing is logged to suggest ST is sending any commands to cause it. I don’t have the ability to update the firmware which apparently fixes some issues but don’t want to have to buy the hub for the sake of updating them (they are Osram Lightify bulbs).

See how you get on, if there’s a problem and a pattern you can discern when I may be able to figure out a solution.

I may make it so that when lights are turned on using the controller device it sends the level and colour to all bulbs in the group to ensure they’re all the same.


(Dean Smith) #9

i just wanted to say i have a problem now where one of my grouped devices (all colored lights) seems to crash the app when opened.


(Chris) #10

That’s is disappointing :frowning:

Sadly, debugging the app in relation to a smartapp/device type is kind of difficult as the code isnt what runs on the mobile app, it’s more of a descriptor of what the app should display and somewhat how it should behave… there’s little I can do to resolve it without it happening in a way I can replicate it… even then I doubt anything I can change would resolve the issue. I suspect a change to the mobile app may have caused this :pensive:


(Adam V) #11

I have found a bizarre error.

If I try to group 2 different kinds of light (or more) e.g. LIFX & Zigbee light in the same group the configure page fails to save


(Adam V) #12

Sorry to be the bearer of bad news!

Here is another bug:

If you have a group of LIFX lights (through the official integration) and you change the colour, it will change the colour and then just under a second later change back straight away. From the logs I can see this error:

9:29:45 PM: error groovy.lang.MissingMethodException: No signature of method: physicalgraph.device.HubMultiAction.add() is applicable for argument types: (java.util.LinkedHashMap) values: [[name:saturation, value:85.88235294117648, ...]] Possible solutions: add(java.lang.String), add(java.util.List), add(physicalgraph.device.HubAction), add(physicalgraph.device.HubMultiAction), any(), any(groovy.lang.Closure) @ line 276
Strangely - if I use the unofficial LIFX device handler (from the community - but it has some drawbacks of it’s own) - then this does not happen


(Adam V) #13

I also have a feature request:

With my old setup I used to achieve a similar thing using a virtual light that an app (in this case “color coordinator”) would assign other bulbs to copy. This worked reasonably well - and basically I’d name the virtual bulb the name of the group… for example “All Bedroom Lights”.

One of the things that I am missing, now that I have switched to this system, is the ability to turn on just one light if necessary. With the old way, I could adjust all the lights at once using the virtual group bulb, but if I just wanted to adjust one light I could still do this by going into that bulbs device in the app and adjusting it there.

I realise that it is actually a feature of Trend Setter to always try and sync the other bulbs if only one is changed, however - for different parts of the house this is either useful or obstructive. For e.g. in the lounge it makes sense that if one bulb is adjusted, all bulbs should be adjusted. Bust say in a Bedroom I may just like to have the bulbs on one side of the bed turn on, but not the other - but still retain the ability to control all with one virtual group device.

So… that was the long way of asking for an option, during the setup process (just a binary switch or something) where the on state is: “All lights stay in sync” and the off state is “All lights change on Master group change only”

What do you think about that?


(Chris) #14

Very strange the first bug you mentioned, not sure how to see what the issue is.

Second bug, it looks like they handle the colour change differently than what I would have expected. If I am able to get hold of the source code for the LIFX handler it might show the reason. I am away for the next couple of days but will have a look asap.

As for the feature request, if you change an individual bulb in a group it shouldn’t effect any of the other bulbs in the group it will just show in the controller device that not all the bulbs stakes match.

What you’re asking for should already work :confused:


(Adam V) #15

I’ll get you a log when I am home later

The LIFX device type is here
Not sure if you need it but the LIFX connect smartapp is here

Ok… that’s weird - I’ll do more tests when I’m home tonight


#16

Thanks @Kriskit!

This works great. I use it with my ZigBee bulbs, which I control directly over ZigBee with remotes I built myself. The bulbs report their status back to SmartThings and your app allows me to group them and it all stays in sync. It’s like magic!


(Joshua Rountree) #17

I’m pretty new to SmartThings but is this sort of like Routines with the exception that it’s creating a virtual device with additional feedback on the status of things and adjustments?

Btw, this isn’t criticism… I’m loving Trend Setter!
It works exactly as described! :smile:


(Chris) #18

Routines aren’t really the same as they’re designed to run multiple commands over multiple devices of potentially different types. Trend Setter is there to keep multiple devices of the same type in sync with a single control point - the virtual device (although they can still be controlled individually or even with ‘sub-groups’ but not sure how well that’ll work as have done little testing). You could even use the virtual controller device within a routine if you wanted. Hope that makes sense :smile:


(Joshua Rountree) #19

Getting issue with GE Link Bulbs not showing status correctly when toggled with the grouped virtual Device
Was working yesterday I believe but not sure


(Chris) #20

Could you elaborate? :smile: