[SOLVED] Hue motion sensors in HASSIO

I have seen the guide to add the Hue motion sensors into HASSIO (https://github.com/robmarkcole/Hue-sensors-HASS) but I am wondering if there are any plans to add this natively to HASSIO in the future. I have tried to follow the guide but i could not get this to work, either way, I would prefer this to be supported natively and was wondering if anyone knowsw whether this will be added in the future?

2 Likes

I asked this 7 months ago and was told it was ‘on the roadmap’ after the PR that I was commenting on…

https://github.com/home-assistant/home-assistant/pull/13043

Haven’t seen anything since.

Robmarkcole’s custom component is working well though, give it another shot.

Hi Mark,

Thank you for the info, seems it is planned; but “not today” :slight_smile:

I have given Robmarkcole’s custom pomponent another go, but I do not see the sensors displayed at all, here is what I have done, maybe you can give it a once over and see where I have gone wrong:

Got my API code, and can confirm that I can see (a rather large) JSON values being returned from http://HUE_IP/api/VERYLARGESECRETSTRINGGOESHERE

In my configuration.yaml file:

sensor:
  - platform: hue
    ip_address: 192.168.0.xx
    token: VERYLARGESECRETSTRINGGOESHERE

sensor:
  - platform: template
    sensors:
      dining_room_temperature:
        friendly_name: 'Dining room temperature'
        value_template: '{{states.sensor.dining_room_motion_sensor.attributes.temperature}}'
        unit_of_measurement: °C
      dining_room_light_level:
        friendly_name: 'Dining room temp'
        value_template: '{{states.sensor.dining_room_motion_sensor.attributes.lx}}'
        unit_of_measurement: lux

In my groups.yaml file I have:

default_view:
  view: yes
  entities:
    - group.Hue

Hue:
  entities:
    - sensor.dining_room_motion_sensor
    - sensor.dining_room_temperature
    - sensor.dining_room_light_level

I checked the config and all valid, then rebooted and I can see nothing added, no entities added at all. Id I do a search in the developer tools/entities for ‘dining’ I can only see the light, not the sensor.

Any ideas?

First, ensure that you have the custom component hue.py in your .homeassistant/custom_components/sensor directory.

To verify your key is correct, have a look in the .config_entries.json file in your homeassistant directory, it should be there under the key “username”

Then check the logs on restart to make sure there are no errors.

Then go around and activate all your motion sensors by walking past them and press a button on all your switches.

Then have a look in your dev states tool at all the entities that start with sensor.

With mine the actual names of the sensor are not quite as obvious as sensor.dining_room_motion_sensor and ended up being like sensor.dining_room_motion_motion or similar.

Then update your temple sensors with the correct entity_id’s.

Hope this helps :slight_smile:

Yes, I copied the hue.py file into the custom_components/sensor directory (had to create both folders)

First issue is the .config_entries.json file, cannot find it at all. Attached is a screenshot of my directory structure, showing all hidden files and folders. Note that I am not using the HomeBridge component.

Checked the logs at HAssio/System and nothing in there at all.

It is as if all the config I entered is completely ignored.

Is your normal hue component working for your lights? If so the file must’ve been moved to .storage or somewhere, I’m not at home atm so I can’t check mine, but somewhere there is a config_entries.json file that contains your hue api_key so that the normal hue component can communicate with the hub.

That said, if you’re relatively happy you have the correct api_key it’s not essential to double check it.

Do you have your configuration on GitHub so I can have a look at it and see if anything jumps out as to why this isn’t being picked up?

Thank you for your help - much appreciated!

I am pretty sure the API key is correct because I get info back when browsing to http://hue_IP/api/APIKEY (all in JSON format)

unfortunately I do not have my config on GitHub - getting that done would be a task and a half, but it is being planned.

I have HASSIO 0.80.3 running on a RPi 3 (fresh install)
I can see all my hue lights in HomeAssistant, works fine
Added the emulated hue bridge to iOS Home app (homekit: in the configuration.yaml file)

All working fine (wife approved!) – I do not have access to it at the moment, will PuTtY to it tonight and see if I can find the file and report back.

1 Like

Hi Mark,

I have found the file, it is stored in \\192.168.0.xx\config.storage and called ‘core.config_entries’

In this file I found this:

{
    "data": {
        "entries": [
            {
                "connection_class": "local_poll",
                "data": {
                    "bridge_id": "001788FFFE2A213F",
                    "host": "192.168.0.30",
                    "username": "M9QQw7iJcFPWgrXYMZL9i6ppqKS4Kj5Kz8yxxxxx"
                },
                "domain": "hue",
                "entry_id": "cd0507d8bab842eda78581721000f4b5",
                "source": "user",
                "title": "Philips hue",
                "version": 1
            },…. And it goes on…..

In my ‘groups.yaml’ file I have the following:

default_view:
  view: yes
  entities:
    - group.Hue

Hue:
  entities:
    - sensor.hallway_motion_sensor
    - sensor.hallway_temperature
    - sensor.hallway_light_level

In my ‘configuration.yaml’ file I have this: (Added extras that could possibly cause an issue?)

# --- Creagan - Makes HASSIO an emulated Hue Bridge
emulated_hue:

# --- Creagan - Example for Z-Wave (See automation.yaml that starts this when Z-Wave network is up)
homekit:
  auto_start: False
  filter:  
    exclude_entities:
      - light.hallway

# --- Creagan - Hue Sensor things from https://github.com/robmarkcole/Hue-sensors-HASS
sensor:
  - platform: hue
    ip_address: 192.168.0.xx
    token: M9QQw7iJcFPWgrXYMZL9i6ppqKS4Kj5Kz8yxxxxx
    #token: m2xXe6vh8ZRE-X3FdaYHYQOS-KvxY693sdIxxxxx <- this was obtained from http:Hue_IP/api/ stuff – the above obtained from HASSIO config file in .storage
  - platform: template
    sensors:
      hallway_temperature:
        friendly_name: 'Hallway room temperature'
        value_template: '{{states.sensor.hallway_motion_sensor.attributes.temperature}}'
        unit_of_measurement: °C
      hallway_light_level:
        friendly_name: 'Hallway room temp'
        value_template: '{{states.sensor.hallway_motion_sensor.attributes.lx}}'
        unit_of_measurement: lux

I have checked the ‘home-assistant.log’ file and cannot see anything mentioned other than these error:

2018-10-23 19:10:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 242, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp\_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2018-10-23 19:10:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 242, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp\_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method
2018-10-23 19:10:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 242, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp\_http_parser.pyx", line 523, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadStatusLine: invalid HTTP method

Sure there must be something I am missing somewhere, but cannot find it at all, tearing hair out at this stage!

it’s the core.config_entries in the .storage folder.

13

btw @creagan, not sure if your key is a true key, but you might want to redact that here in your posts on the forum…

Thanks Marius - now redacted.:smirk:

OK, the token should definitely be the one with M9QQ at the start, and the ip address should be the one ending in 30.

That error is not from the custom component.

Have you looked in your dev panel for all your sensors since restart?

Thank you - at least I have the right key - thak you for confirming.

If I go to Developer Tools | States (the one with <>) and do a filter in ‘Filter entities’ and type in ‘hallway’, I can only see ‘light.hallway’ and ‘light.hallway_light’ (I suspect the ‘light.hallway’ is the room itself ported from the hue hub)

At the end of the ‘configuration.yaml’ file I have this:

group: !include_dir_merge_list groups

and in the \config folder I have a directory called ‘groups’ and in that is ‘groups.yaml’

It is as if it does not pick up anything?

Don’t filter for hallway, scroll down to all your sensors and see what you have. It might be called something different.

even without any configuration file but the

sensor:
  platform: hue
  ip_adress: xxxx
  token: etcetc

the CC should create sensor.name_motion_sensor for all you motion sensors.

you should be able to filter on motion_sensor in the dev-state page and find them all listed. If not, the component isn’t configured correctly.

OK, tried something different, and broke it - sigh

I removed this in ‘configuration.yaml’ file:

group: !include_dir_merge_list groups

Replaced it with this after I moved the ‘groups.yaml’ file into \config directory:

group: !include groups.yaml

Rebooted… Anxious wait

And now, on the main screen/Overview, I can see a list of stuff - BUT only that! All other devices missing:

Any thoughts? rolling eyes but excited something showed up!!!

OK, so your hue custom component is working, that’s progress :wink:

Show us your complete groups directory.

yes, and we see the sensors with name temp should really be named lx or lux, which ever you prefer… hence the 2 temp sensors in the group for each motion sensor.

hallway_light_level:
friendly_name: ‘Hallway room Lux’ # or light level , to be in line with the entity name
value_template: ‘{{states.sensor.hallway_motion_sensor.attributes.lx}}’
unit_of_measurement: lux

if and when you’ re ready for it, you could rewrite that template as follows:

value_template: >
  {{state_attr('sensor.hallway_motion_sensor', 'lx'}}

which is easier on the eye and a bit safer for when the value isn’t computed yet.

In the \config directory, there is a single file in the groups sub folder called groups.yaml

Path is: \config\groups\groups.yaml

The content of this file is the same as the one I copied into the root \config folder :slight_smile:

 default_view:
   view: yes
   entities:
     - group.Hue
 
 Hue:
   entities:
     - sensor.dining_room_motion_sensor
     - sensor.dining_room_temperature
     - sensor.dining_room_light_level
     - sensor.hallway_motion_sensor
     - sensor.hallway_temperature
     - sensor.hallway_light_level

Maybe the include I have is completely wrong?

no it is correct, (with the exception of the dining_room_motion_sensor which isn’t showing) but if this is the only content of the file, the frontend won’t show anything else :wink:

what other groups do you have, and in which file did you configure them?

I do not have any other files in the \config\groups directory other than the groups.yaml file with exact content:

default_view:
  view: yes
  entities:
    - group.Hue

Hue:
  entities:
    - sensor.dining_room_motion_sensor
    - sensor.dining_room_temperature
    - sensor.dining_room_light_level
    - sensor.hallway_motion_sensor
    - sensor.hallway_temperature
    - sensor.hallway_light_level