Hue motion sensors + remotes: custom component


#487

I see @marthocoo activity has paused on Github, sometimes life gets in the way of dev, but I’m sure he will be back! I’m moving house and getting married in next month so not much free time, but it’s on my radar.

@Aephir something like:

if button[0] == '1':
  then something

#488

I figured it out; there was a problem was in the automation.

- alias: Hue remote 1 automation
  trigger:
  - entity_id: sensor.hue_dimmer_1_updated
    platform: state
  - entity_id: sensor.hue_dimmer_1_button
    platform: state
  action:
  - service: python_script.hue_remote_1

didn’t work, but:

- alias: Hue remote 1 automation
 trigger:
 - entity_id: sensor.hue_dimmer_1
   platform: state
 action:
 - service: python_script.hue_remote_1

works fine.

- alias: Hue remote 1 automation
 trigger:
 - entity_id: sensor.hue_dimmer_1
   platform: state
 - entity_id: sensor.hue_dimmer_1_updated
   platform: state
 action:
 - service: python_script.hue_remote_1

also works, but not if I remove the '- entity_id: sensor.hue_dimmer_1'. If I add ‘- entity_id: sensor.hue_dimmer_1_button’, then it fails regardless of what else is in the automation.

I also have in the python script:

button = hass.states.get('sensor.hue_dimmer_1').state
if button[0:3] == '1_c':
      hass.services.call('light', 'turn_on', { 'entity_id' : 'light.living_room_lightstrip' })

instead of the two lines with button_obj == and button ==.
I was using if button[0:3] == '1_c':, so it won’t matter if it catches the '1_click' or '1_click_up' (not sure if this is an issue?).

Thanks again!


#489

wow, nice announcement! congrats!
hope to see you back again in a year or so :wink: all the best!


#490

I’ve experienced exactly the same behavior.
Once I add the custom components to my HA config folder (0.75.2) all my sensors are gone and the log file shows the following error:

ERROR (MainThread) [homeassistant.setup] Error during setup of component sensor
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/setup.py", line 148, in _async_setup_component
    component.setup, hass, processed_config)  # type: ignore
AttributeError: module 'custom_components.sensor' has no attribute 'setup'

I have not found any way to get this CC up and running. Any advice?

UPDATE: It seems that was my own fault, wrong indent in config. Now I run into the following on startup.

[custom_components.sensor.hue] Cannot setup Hue sensors, check your config

The good news is all my other sensors are there, so this might help @spdustin.


#491

It seems that the error:

[custom_components.sensor.hue] Cannot setup Hue sensors, check your config

results in getting a new api_key as suggested in this blog which is referenced in the readme.
If you allready have a phue.conf file in your config folder, just use the api_key from there and you should be fine.


#492

Hello, just reporting that I have tried the REST version and now converted to this component and it works great! Just one question, the motion sensor is reported as a sensor but behaving as a binary_sensor. That makes the icon not glow yellow on motion. Could the sensor be a binary_sensor like for instance the AEOTEC Multisensor 6. If it is binary you would get the glow “free of charge”.

If anyone has a suggested template setting that could be done as-well, but personally I think the component should add it as a binary_sensor. Just my two cents!

I installed it to be able to use the wireless remote to control a z-wave dimmer and I it works great!! Thanks helping me increase the WAF of my automation!


#493

try:

sensor.corridor_motion_sensor:
  show_last_changed: true
  templates:
    icon_color: >
      if (state === 'on') return 'rgb(192, 39, 30)';
      return 'rgb(54, 95, 140)';
    icon: >
      if (state === 'on') return 'mdi:run-fast';
      return 'mdi:exit-to-app';
    _stateDisplay: >
      if (state === 'on') return 'Alert';
      return 'Clear';

using custom-ui.


#494

Hello, does this only work in Lovelace? I have not converted yet… :stuck_out_tongue:

Thanks for the tip!


#495

No, regular Hassio/Hassos . No Lovelace here yet either :wink:


#496

Ok, I tried it in customize-yaml but could not make it work. Not sure what I am doing wrong.

sensor.stua_motion_sensor:
  show_last_changed: true
  templates:
    icon_color: >
      if (state === 'on') return 'rgb(192, 39, 30)';
      return 'rgb(54, 95, 140)';
    icon: >
      if (state === 'on') return 'mdi:run-fast';
      return 'mdi:exit-to-app';
    _stateDisplay: >
      if (state === 'on') return 'Alert';
      return 'Clear';

I get this up in the UI if I click the sensor like this:

But the icon does not flash… (status updates just fine). Am I doing something wrong :blush:?


#497

Have you installed @andrey 's custom-ui? https://github.com/andrey-git/home-assistant-custom-ui/blob/master/docs/installing.md


#498

Ahem … no… :open_mouth:

Let me try that then!


#499

If anyone was interested in converting C to F in the temperature sensors, instead of breaking out a template sensors, I simply adujsted the value template in a rest sensor to do the maths in one go.

value_template: '{{ value_json.state.temperature | float / 100 * 9 / 5 + 32 | round(2) }}'


#500

Hi Robmarkcole,

I’m trying to install your component which seems to be exactly what i’m looking for instead of using my rest API which dont respond very well. My problem is as soon as I load up your component I lose all access to my hue lights. I have been going trhough the forums and havent seen anyone else with this issue.

I run my Home assistant within a docker container, could this be the issue ?


#501

I’m on 0.74.0 and I had attempted to upgrade a few releases back and that broke this sensor. I had to restore to 0.74 to get things working again. Is there something special needed to be done to get sensor.Hue working on the latest release?

I see the following in the logs every start-up of Hass.io

2018-09-12 15:07:19 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.hue which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

2018-09-12 15:07:19 WARNING (MainThread) [homeassistant.loader] You are using a custom component for variable which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

Has anyone moved to zigbee2mqtt to replace this component?


#502

I’m on 0.74.0 and I had attempted to upgrade a few releases back and that broke this sensor. I had to restore to 0.74 to get things working again. Is there something special needed to be done to get sensor.Hue working on the latest release?

I see the following in the logs every start-up of Hass.io

2018-09-12 15:07:19 WARNING (MainThread) [homeassistant.loader] You are using a custom component for sensor.hue which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

2018-09-12 15:07:19 WARNING (MainThread) [homeassistant.loader] You are using a custom component for variable which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do experience issues with Home Assistant.

Has anyone moved to zigbee2mqtt to replace this component?


#503

dont worry, its a generic warning issued for each Custom Component. The dev’s merely waver their responsibility for issues possibly caused by these CC’s, since they’re not ‘official’ HomeAssistant code.


#504

Cool, figured that. Thank you.

Are you on the latest hassio? and everything works?


#505

No I am on 75.3.
1 Pi on Hassos and 1 on Hassio.
there are many issues with the Hue integration on my Hassio system (and a lot of other users)…And that all started since Hue integration became Asyncio.
Its about the main pain in the system, HA losing connection with the Hub all the time, switching the lights between unavailable and available.

I’ve tried all for the last few months, and it somehow seems to be a timing issue, havent pinpointed it yet.
search the forum and GitHub for ‘Flapping’, or ‘lights becoming unavailable’ and you’ll read all about it.

What I do know, though the CC has it’s influence, it isn’t the main cause for the issue. Ive especially installed the second system to test that, and the CC is running just fine there (as on the Hassio btw) making all sensors available in a whif. which is really cool.

Ive been forced to live with it, and rewrite all other logic and sensors to not use the timer attributes of the lights (last_changed) because thats completely unreliable:

HassOs (correct):

56

HassIo (just reconnected as I write this…):

47

flapped:

14


#506

So I upgraded and no issues, or I should say I still have the same light issues I had prior.

Most of my issues happened after moving to the new NodeRed… Life hasn’t been the same, but it’s nice that it’s being maintained.

As for Hue, this is why I was asking about the zigbeeqmqtt. Was trying to determine if the overall stability is better or worse.

Thanks!