Hue motion sensors + remotes: custom component

Hello

i have installed my homeassistant on Raspberry with Aio but i can t find the components Path anyone who Can help me :confused:

Quick question: will the automation fire again if the same switch action is pressed again without an intervening switch action? E.g. I short press 1 to turn my lights on, then use the iOS app to turn them off. If I press 1 again, does the automation fire?

hi, yes fires again

Hi, just tried updating the component, by downloading the latest zip from github. I have put hue.py & sensor/hue.py in custom_components folder and added the following…

hue:

sensor:
  - platform: hue

in the config, but now hass won’t start with error in the log…

2017-10-17 12:03:02 ERROR (MainThread) [homeassistant.config] Invalid config for [homeassistant]: expected dict for dictionary value @ data['packages']['hue']['hue']. Got None. (See /config/configuration.yaml, line 4).

Currently using hass 0.55

Is there something i’m missing?
Cheers,

james

Does anyone know if the Lutron Connected Bulb Remote will be discovered by this component? It’s a Zigbee remote that pairs to the hue bridge - Lutron LZL-4B-WH-L01 Connected Bulb Remote https://www.amazon.com/dp/B014STZASK/ref=cm_sw_r_cp_api_ZTE5zbPGKC8TY.

It’s a bit nicer than the hue remote IMO because it can directly integrate into a normal Decora faceplate, which solves the problem of where to stick the hue dimmer remote. I’ve been meaning to pull the trigger on one for a while and direct integration with HASS will put it over the top!

Hi James, now no longer custom component, please review readme

Great news!
Which version of hass will it get merged? I’m on 0.55 so maybe that is why it’s not working yet?

Cheers,
James

Hi James, you can follow the PR below, and see the correct location of the files. Cheers! https://github.com/home-assistant/home-assistant/pull/9796

Thanks I have had a look at that. I won’t have to put the .py files anywhere when this is merged into hass though will I? Doesn’t hass install those into the correct places automatically?

I run hass from synology docker so not sure if I can access the components directory (custom_components just went straight into the /config folder so I could do that no problem)

Just wanting to check a few things with others also testing this:

  1. I can’t seem to get an automation to trigger again if there isn’t an intervening switch press (e.g. I click 1 which turns my lights on; I turn the lights off via iOS; if I click 1 again, the lights don’t turn on since the state hasn’t changed). What does a working automation look like? For trigger I’m using state and to: 1_click, which obviously isn’t correct.
  2. If I long press a button, I also get the automation firing for the short press of that button before the long press automation triggers. Is that right? Again automation snippet examples would be appreciated :slight_smile:

Hi @marthocoo there is an example automation earlier in this thread which should help you.
I don’t see the behaviour you are describing, please post your automations so we can help.
Cheers

I have a similar problem to the one described by @marthocoo regarding state. I have two Hue Dimmers set up and I want them to act totally identically, controlling both and in the same way the lights in my living room. Here are the automations for that:

# Hue dimmer 1 in Stuen actions    
# Use the regular state_1 Button to force the Regular scene
- alias: Dimmer 1 Stuen - Force Regular
  trigger:
    platform: state
    entity_id: sensor.hue_dimmer_switch_1
    to: "1_click"
  action:
    service: scene.turn_on
    entity_id: scene.regular
# Use the regular state_4 (Off) Button to turn all lights in Stuen off
- alias: Dimmer 1 Stuen - Off
  trigger:
    platform: state
    entity_id: sensor.hue_dimmer_switch_1
    to: "4_click"
  action:
    service: homeassistant.turn_off
    entity_id: group.stuen

# Hue dimmer 2 in Stuen actions    
# Use the regular state_1 Button to force the Regular scene
- alias: Dimmer 2 Stuen - Force Regular
  trigger:
    platform: state
    entity_id: sensor.stuen_switch_2_entre
    to: "1_click"
  action:
    service: scene.turn_on
    entity_id: scene.regular
# Use the regular state_4 (Off) Button to turn all lights in Stuen off
- alias: Dimmer 2 Stuen - Off
  trigger:
    platform: state
    entity_id: sensor.stuen_switch_2_entre
    to: "4_click"
  action:
    service: homeassistant.turn_off
    entity_id: group.stuen

Each of the dimmers work fine independently. However, if I go through this sequence:

  1. Dimmer 1: Press btn 1 (to turn on lights)
  2. Dimmer 2: Press btn 4 (to turn off lights)
  3. Dimmer 1: Press btn 1 (to turn on lights)

then the last button press does not cause any automation to fire. It seems to be because the state of Dimmer 1 does not change and therefore, the automation rule does not fire.

Have I just written my automations in a poor way or is there an underlying deeper issue with the fact that - popularly speaking - the same dimmer button can only fire again if another one of that dimmer’s buttons has been pressed in between?

My automations are as follows:

- id: eight
  alias: MB Dimmer - 1 click - lights on dimmed
  trigger:
    - platform: state
      entity_id: sensor.master_bedroom_dimmer
      to: "1_click"
  action:
    - service: light.turn_on
      data:
        entity_id: light.master_bedroom_lights
        brightness_pct: 30

- id: nine
  alias: MB Dimmer - 1 long - lights on full
  trigger:
    - platform: state
      entity_id: sensor.master_bedroom_dimmer
      to: "1_hold"
  action:
    - service: light.turn_on
      data:
        entity_id: light.master_bedroom_lights
        brightness_pct: 100

Almost without fail, if I hold button 1 for a long press, the lights will first go to 30 pct before going to 100 pct. If I turn off the “1_click” automation, this doesn’t happen, so it must be that the automation is being triggered by HASS receiving a “1_click” state update before it changes to “1_hold”. It looks like this in my logbook (remember, in reverse chronological order):

4:18 PM Master Bedroom Lights turned on
4:18 PM MB Dimmer - 1 long - lights on full has been triggered
4:18 PM MB Dimmer - 1 click - lights on dimmed has been triggered

Another minor issue: my logs are being spammed with:

2017-10-23 23:26:11 WARNING (MainThread) [homeassistant.components.sensor] Updating hue sensor took longer than the scheduled update interval 0:00:01
2017-10-23 23:26:13 WARNING (MainThread) [homeassistant.components.sensor] Updating hue sensor took longer than the scheduled update interval 0:00:01
2017-10-23 23:26:15 WARNING (MainThread) [homeassistant.components.sensor] Updating hue sensor took longer than the scheduled update interval 0:00:01

I’d suggest somehow hiding that from the user - its not relevant for the user to know.

Hi Mort, I think linking the state of the two remotes using an automation could solve your issue, assuming both remotes trigger the same automations.
Cheers

Hi @marthocoo I haven’t noticed this since in my usage I have configured the short clicks for turning lights on and off, whilst the long clicks are for automations, and in this scenario repeatedly hitting the short clicks makes no difference.
Re warnings, those are generated by HA and not the Hue component code. Clearly there is an underlying issue.
Cheers

Hi Robin, thx for replying. I’m not quite sure that I follow. If the problem is that Dimmer 1 does not raise 1_click, how would automation solve that? Are you suggesting that when Dimmer 2 raises 1_click, I write that state to Dimmer 1 as well? I think that would work, but I’m not sure that you can write or push a state on the dimmers. Aren’t they to be thought of as “read-only”? And would such a state for Dimmer 1 that I manipulate through automation just be overwritten and revert to the physical state of Dimmer 1 at the next poll of the state from the Hue Bridge?

And just to clarify: It is my impression that repeated clicks on the same button on a dimmer will not cause a state change, and that is at the root of this. So that is really at the root of this: How does one make HA react to repeated clicks on the same button? Solving that would handle this issue.

Morten

I would think that it actually makes a difference if you touched another button (say btn 2) before the long press on btn 1. If another btn 2 has been pressed before btn 1 long press, btn 1 fires first 1_click and then 1_hold, whereas if it was was btn 1 that was pressed before, the long press fires only 1_hold. It is because you see only state changes and therefore, the previous state of the dimmer makes a difference to what is fired.
Morten

HI Mort
you are overwriting the state of the remote in HA, not on the Hue hub, so it should be fine. The Hue hub only report state changes it receives from the remotes after a push, and is not continually polling the remote itself.

Re point 2, I believe that your state changes aren’t registering since to have a to filter on your automations. The state of the remote is changing with each click, but it can only change to 1_click once in a series of clicks on that button. You will see in my hackster article there is no to filter for exactly this reason.

Please be aware that the remotes have an attribute last_updated so you could incorporate that in any logic you wish to add.
Cheers

Hi Robin,
Thx. Here is a lot to go on. I’ll start investigating and get back when I’m wiser :slight_smile:
BRG Morten

Is there a way to set the state of the remote in an automation? This could help solve @Morten_Elk’s problem. Basically, the action would be to do whatever the automation is intended to do and then update the state of the remote to “None” for example. This may require using a python script instead.