Philips Hue: Light Group

I have configured my Philips Hue bridge to assign a first group for my two floor lamps and I want Home Assistant to show a group instead of two floor lamps. Is this possible? I need to be able to control the brightness and color temperature for both two floor lamps. I can only toggle the group’s switch.

And one last question I have is can I do the same with LIFX? Hide both of the bulbs but show only the group’s name?

group: Living_Room_Lights: name: Floor Lamps entities: - light.living_room_left - light.living_room_right Living_Room_Devices: name: Entertainment entities: - media_player.shield Living_Room: view: yes name: Living Room entities: - group.Living_Room_Lights - group.Living_Room_Devices Bedroom_Lamps: name: Bedroom Lamps entities: - light.bedroom_lamp_l - light.bedroom_lamp_r Bedroom: view: yes name: Bedroom entities: - group.Bedroom_Lamps

And lastly, how do I tags in “choose optional tags for the topic” so that my post can be searched easily?

Update after a few minutes later: I guess the search result did not return a thread found in Feature Request when I search for “philips hue group” (without quotes). My bad.

Okay. Instead of the group that executes two API calls:

group: Living_Room_Lights: name: Floor Lamps entities: - light.living_room_left - light.living_room_right

I simply wrote a small shell script in ~/shell_script/philipshue/group_livingroom:

#!/bin/bash curl -X PUT -H "Content-Type: application/json" -d $1 http://philipshue1/api/yourapikey/groups/1/action

Where “philipshue1” is your bridge’s hostname or IP address, “yourapikey” can be your name or something random, and “1” is the group ID.

In configuration.yaml:

shell_command: hometheater_playing: ~/shell_scripts/philipshue/group_livingroom '{"on":true,"ct":370,"bri":127,"transitiontime":150}' hometheater_paused: ~/shell_scripts/philipshue/group_livingroom '{"on":false,"transitiontime":50}'

And now the automation part:

[code]automation:

  • alias: “Kodi paused/stop”
    trigger:
    • platform: state
      entity_id: media_player.kodi
      from: “playing”
      action:
      service: shell_command.hometheater_playing
  • alias: “Kodi playing”
    trigger:
    • platform: state
      entity_id: media_player.kodi
      to: “playing”
      action:
      service: shell_command.hometheater_paused[/code]

I hope this helps everyone who use Philips Hue. Happy home automating! :slight_smile:

Actually, I’ve written shell scripts which I put them to use in crontab about a year and a half before I try out Home Assistant, since I plan to expand my home automation setup with multiple devices.

2 Likes

Thank you for sharing!

I have a lot of hue groups or “Rooms” which makes it a pain to maintain all the different shell scripts for each room/group.

I’ve extended your shell script to take an additional argument: FNAME (friendly name). Now I can setup all the groups and lights in a single bash script (phue_control.sh):

#!/bin/bash

# INPUT: hue IP & api key
HOST=192.168.10.12
APIKEY=<your_key>
# group/light friendly name
FNAME=$1
# hue command
COMMAND=$2
# INPUT: specify hue type ("groups" or "lights") and ID
case $FNAME in
	bedroom)
		TYPE="groups"
		ID=2
		;;
	livingroom_sofa)
		TYPE="groups"
		ID=1
		;;
	livingroom_table)
		TYPE="lights"
		ID=3
		;;
	*)
esac


if [ "$TYPE" == "groups" ] ; then
	AS="action"
else
	AS="state"
fi

curl -X PUT -H "Content-Type: application/json" -d $COMMAND http://$HOST/api/$APIKEY/$TYPE/$ID/$AS

In configuration.yaml:

shell_command:
  hometheater_playing: ~/shell_scripts/phue_control.sh livingroom_sofa '{"on":true,"ct":370,"bri":127,"transitiontime":150}'

I used the instructions given here to create an API key and to find the ID’s for my hue groups and lights which I have created in the hue iPhone app.

(this is my first bash script, so its probably not perfect)

3 Likes

And thank you for sharing the modification! It would be nice if Home Assistant could support Philips Hue groups right out of the box. The use of shell scripts is only a work around for the delay between API calls to the Hub.

I am planning to get rid of my starter kit as I have switched over to LIFX for that reason: to control multiple lights at once without a delay between API calls.

But at least I have something to contribute for those who need the script.

   Yes!! !!!!!!!!!!!            +1
1 Like

See https://github.com/home-assistant/home-assistant/pull/4744

I ran into similar timing issues, but instead implemented the ability to run Hue scenes directly from Home Assistant - https://home-assistant.io/components/light.hue/#using-hue-scenes-in-home-assistant - does this solve your issue, or are you still trying to expose arbitrary brightness settings from the HA ui?

Brightness settings as well, but then I don’t use Philips Hue anymore. A scene is only a hack with preset brightness and color and that’s about it.