[BETA] Hue & Improved - Support for multiple Hue bridges!

hue
smartapp_lighting

(Alan Penner) #1

Yes, it’s another Hue controller. The main reason for this is support for multiple Hue bridges. All the existing apps I’ve seen only support one bridge, and the code for that is deeply entrenched throughout the entire app. It took a lot of reworking of the app structure to support multiple bridges. The app supports bulbs, scenes, and groups.

I will update this post with better instructions later, but if you’ve used a Hue app for SmartThings before, this mostly should be pretty self-explanatory.

Installation instructions

  1. Remove any Hue app and devices you may already have installed.
  2. Install the app in the IDE. Code
  3. Install the devices in the IDE: Code
    Optionally, you may use github integration to install. It’s probably easier that way.
  4. Go to Marketplace -> SmartApps -> My Apps and install “Hue & Improved”. On initial installation, it directs you do just tap Done and then proceed to Menu->SmartApps->Hue & Improved to set up.

THERE WILL BE BUGS
This is Beta. I’m sure there will be plenty of bugs to be found.
One issue that exists right now: If you go to Things, and tap on the Hue Bridge, it causes the Android SmartThings app to crash. This does not seem to affect the iOS app.
I develop with Android and don’t have regular access to an iOS device. Some of the display options on iOS probably look wrong. If so, please send me screenshots.

I’m sure there’s a lot left to do, so don’t hesitate to offer suggestions.
Planned additions:

  1. A way to change transition time of state changes.
  2. The ability to add an “all bulbs” group to control them all at once.
  3. SuperGroups and SuperScenes: Ability to combine groups and scenes from multiple bridges and have them act just like the standard Group and Scene devices.

ST + Multiple Philips HUE Bridges?
[BETA] Hue (Re)Connect - with scene handling
[UPDATED SEPT 2018] Hue B Smart (Groups & Scenes) - Remove Popcorn Effect!
(Martin Verbeek) #2

Hi Alan, thanks for this, needed it. i am getting an error though when i create a light automation that does a setlevel, it gives an error on the bridge device debug log and sets the lamp to off…

Error: [[error:[address:/lights/5/state/bri, description:parameter, bri, is not modifiable. Device is set to off., type:201]]]


(Martin Verbeek) #3

the solution is in the device handlers, you also need to set the light to ON:TRUE together with the bri…then it works.

        body: [on: true, bri: lvl]

EDIT: actully you might need to do it for all changes in bri, color etc. i have put an on:true on most commands that changed something. Works OK.


(Alan Penner) #4

Yeah. I noticed this yesterday. I’ve made all those changes, just making sure on:true is in all the commands except turning it off.


(Alan Penner) #5

@dudz40 Are you still using this? How’s it working for you? Any suggestions?

I made some changes today with how you choose which bulbs, scenes, and groups to add. Instead of using settings and then running into the 20 second time limit if you choose too many, you now add them one at a time. It probably takes a little longer, but it’s still pretty quick.


(Martin Verbeek) #6

Yes, in use. No issues, i could live with the 5 at a time. I will add some bulbs in the near future so will update to ew code and will let you know how it went.

Thanks, martin.


(Martin Verbeek) #7

Additions of new new devices work great! found something that you might want to change. I am doing a setcolor and level through the smartthings automation app. the device code is setting the bri to 254 always if a setcolor is detected. did a small change to include the bri… c below.

def setColor(value) {
def hue = parent.scaleLevel(value.hue, true, 65535)
def sat = parent.scaleLevel(value.saturation, true, 254)
def bri = parent.scaleLevel(value.level, true, 254)
log.debug “Setting color to [${hue}, ${sat}, ${bri}]”

def commandData = parent.getCommandData(device.deviceNetworkId)
parent.sendHubCommand(new physicalgraph.device.HubAction(
	[
    	method: "PUT",
		path: "/api/${commandData.username}/lights/${commandData.deviceId}/state",
        headers: [
        	host: "${commandData.ip}"
		],
        body: [on : true, hue: hue, sat: sat, bri: bri]
	])
)    

}


(Eug) #8

How’s this coming along… Should I buy that 2nd bridge yet? Or hold off


(Alan Penner) #9

All the basic functionality is there and working. You can add lights, scenes, and groups from multiple bridges and use them in SmartThings.


(Eug) #10

Trying in on bridge number 1…standby


(Eug) #11

Can’t find bulbs :frowning: reinstalled the devices twice. Am I doing something wrong?


(Alan Penner) #12

Probably not. Can you paste some logs? Do you have a v1 or v2 SmartThings hub? I haven’t tested at all on v1.


(Eug) #13

Hue Bridge (192.168.2.153) (Device) Events — displayed | all | from device
Date Source Type Name Value User Displayed Text
2016-06-05 4:09:59.296 AM SGT
30 minutes ago DEVICE username nsvQvISjxcGEoZUvyVUtp3wgywgrt… Hue Bridge (192.168.2.153) username is nsvQvISjxcGEoZUvyVUtp3wgywgrtKTJ0jyEqRfV
2016-06-05 4:09:59.257 AM SGT
30 minutes ago DEVICE serialNumber 00178824eb0e Hue (192.168.2.153) serial number is 00178824eb0e
2016-06-05 4:09:59.218 AM SGT
30 minutes ago DEVICE networkAddress 192.168.2.153 Hue Bridge (192.168.2.153) network address is 192.168.2.153


(Eug) #14

Settings
Name Type Value
Event Subscriptions
Name Handler Filter Source
locationHandler false house!!! (Location)
itemDiscovery itemDiscoveryHandler true Hue Bridge (192.168.2.153)
Application State
Name Value
bridgeRefreshCount 55
creatingDevices false
doingSync false
inItemDiscovery 305A3ACAED64
installed true
itemDiscoveryComplete false
itemRefreshCount 5
linkRefreshcount 14
linked_bridges {uuid:2f402f80-da50-11e1-9b23-00178824eb0e={ssdpUSN=uuid:2f402f80-da50-11e1-9b23-00178824eb0e, itemsDiscovered=false, networkAddress=C0A80299, ssdpNTS=null, serialNumber=00178824eb0e, bulbs={}, deviceAddress=0050, mac=305A3ACAED64, hub=4778acfe-b120-452e-8ae1-acb8f21e7093, ssdpPath=/description.xml, ssdpTerm=urn:schemas-upnp-org:device:basic:1, stringCount=04, scenes={}, verified=true, name=Philips hue (192.168.2.153), devicetype=04, groups={}}}
numDiscoveryResponses 0
params {id=494688c6-f5d0-49df-8b4b-451fc11234eb, name=manageBridge, mac=305A3ACAED64}
subscribed true
unlinked_bridges {}


(Eug) #15

its a v2 hub, and a v2 bridge. I’ve not nothing showing on the live logging


(Alan Penner) #16

Is this MAC correct? Is that what it says on the bridge? On mine (v1 Hue bridge) the MAC and serial number are the same. If the MAC is not right, remove the app, reboot your ST hub, and try again.

I ran into an issue once where the ST hub ARP table was mapping IP addresses to the wrong MAC addresses.

Edit: Looks like that MAC is for an Asus device, so that looks like the problem. Restarting the ST hub should fix your problems.


(Eug) #17

I should have seen it. The mac was not correct. i was running the bridge of a asus wifi extender and it was picking up the mac of the extender not the bridge. I have moved the bridge over to the same router and now the mac is correct.

I’ve rebooted everything twice, and now running discovery on the devices, but still no dice.
Thanks for the quick help so far btw… I’m sure once i get this running it’ll be awesome.

Date Source Type Name Value User Displayed Text Changed
2016-06-05 3:47:38.737 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:47:38.669 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:47:23.267 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:47:23.211 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:47:07.821 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:47:07.752 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:46:52.639 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:46:52.587 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:46:37.219 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:46:37.154 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:46:21.896 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:46:21.821 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:46:06.443 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:46:06.347 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:45:50.973 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:45:50.903 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:45:35.506 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:45:35.442 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:45:20.026 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:45:19.957 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:45:04.603 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:45:04.530 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:44:48.931 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:44:48.859 PM SGT
moments ago APP_COMMAND discoverItems true
2016-06-05 3:43:21.215 PM SGT
moments ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:43:21.159 PM SGT
5 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:43:05.771 PM SGT
5 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:43:05.698 PM SGT
5 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:42:50.092 PM SGT
6 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:42:50.021 PM SGT
6 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:42:34.218 PM SGT
6 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:42:34.140 PM SGT
6 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:42:18.406 PM SGT
6 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:42:18.335 PM SGT
6 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:42:02.996 PM SGT
6 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:42:02.938 PM SGT
6 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:41:47.093 PM SGT
7 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:41:47.025 PM SGT
7 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:41:31.808 PM SGT
7 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:41:31.726 PM SGT
7 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:41:16.220 PM SGT
7 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:41:16.155 PM SGT
7 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:41:00.035 PM SGT
8 minutes ago COMMAND discoverItems discoverItems command was sent to Hue Bridge (192.168.2.153) true
2016-06-05 3:40:59.962 PM SGT
8 minutes ago APP_COMMAND discoverItems true
2016-06-05 3:40:53.933 PM SGT
8 minutes ago DEVICE ENTITY_UPDATE DeviceCreated false
2016-06-05 3:40:53.917 PM SGT
8 minutes ago DEVICE username FwSM5owZgf8bZSz1kAl7hyX8Og4TV… Hue Bridge (192.168.2.153) username is FwSM5owZgf8bZSz1kAl7hyX8Og4TV1Smx6WfQQv3 true
2016-06-05 3:40:53.869 PM SGT
8 minutes ago DEVICE serialNumber 00178824eb0e Hue Bridge (192.168.2.153) serial number is 00178824eb0e true
2016-06-05 3:40:53.818 PM SGT
8 minutes ago DEVICE networkAddress 192.168.2.153 Hue Bridge (192.168.2.153) network address is 192.168.2.153 true

Current States
serialNumber: 00178824eb0e
networkAddress: 192.168.2.153
username: FwSM5owZgf8bZSz1kAl7hyX8Og4TV1Smx6WfQQv3

vent Subscriptions
Name Handler Filter Source
locationHandler false house!!! (Location)
itemDiscovery itemDiscoveryHandler true Hue Bridge (192.168.2.153)
Application State
Name Value
bridgeRefreshCount 7
creatingDevices false
doingSync false
inItemDiscovery 00178824EB0E
installed true
itemDiscoveryComplete false
itemRefreshCount 0
linkRefreshcount 4
linked_bridges {uuid:2f402f80-da50-11e1-9b23-00178824eb0e={ssdpUSN=uuid:2f402f80-da50-11e1-9b23-00178824eb0e, itemsDiscovered=false, networkAddress=C0A80299, ssdpNTS=null, serialNumber=00178824eb0e, bulbs={}, mac=00178824EB0E, deviceAddress=0050, hub=4778acfe-b120-452e-8ae1-acb8f21e7093, ssdpPath=/description.xml, ssdpTerm=urn:schemas-upnp-org:device:basic:1, stringCount=04, scenes={}, verified=true, name=Philips hue (192.168.2.153), devicetype=04, groups={}}}
numDiscoveryResponses 0
params {id=f9dbe80c-93d1-4fa5-9c15-ddb412ca6412, name=manageBridge, mac=00178824EB0E}
subscribed true
unlinked_bridges {}
Scheduled Jobs
None


(Eug) #18

I did some tinkering since this morning and got a new hue v2 bridge.

Sorry for all the trouble but I’m not at all familiar with programming, just tinkering.

I was suspecting it might be network related with the way I have set thinks up with wireless repeaters and what not in my house.

Firstly the brand spanking new bridge fired right up on the hue and improved app. Connected to the main router. It added bulbs and scenes. No problems.

The old bridge was moved to the router and it too was found - but again I couldn’t add lights and scenes. Multiple tries and correct Mac addresses were displayed but nothing found on the old hue bridge.

The old hue bridge fired right up with hue connect and found the lights- but not in hue and improved.

I’m pretty stumped.

Now I’m quite sure it’s not network. Perhaps the bridge?


(Eug) #19

Solved somewhat.

I have reset the problematic bridge to factory settings and it has worked.

What an adventure:)

Thanks for the support. Will continue to monitor


(Alan Penner) #20

Glad you got it working. I wonder what the bridge was doing that was causing problems. Maybe some incompatible bulb? Do you only have Hue bulbs or do you have others added to it as well?