Hue motion sensors + remotes: custom component

OK I can now see the devices on the overview tab, but how do I use them for Automation? I would like the dimmer to turn on the light then also trigger a Tuya switch.

How to I allow a double click with automation? I have no FROM command only TO = 4_click but when I press my tap switch button twice it doesn’t work. I have to click another button like 2_click and then press the 4_click button for it to trigger. Is there a way around this?

- id: '1573025769685'
  alias: Bedroom Tap Switch - 4 - Alexa "Sleep"
  description: ''
  trigger:
  - entity_id: sensor.bedroom_tap_switch
    platform: state
    to: 4_click
  condition:
  - after: '19:00:00'
    before: 06:30:00
    condition: time
  action:
  - data:
      entity_id: light.every_light_zone
    service: light.turn_off

full code: https://hastebin.com/udoqimopox.pl

thanks!

Hi,

Just installed HA on my Pi3B+ and got it all running in a very basic fashion.

The first automation I thought I’d try is to get my Hue Dimmer to trigger some TP-Link HS100 plugs on and off.

I installed this custom component, and setup the automation via the UI, and got the buttons to work ONCE. As in the lights went on and off on separate button presses as expected, but then they’ve stopped.

If I look at my list of devices, the switches are no longer visible although I can still select then as triggers when creating new automations. I can also see that the automations have been triggered via the automations screen, but the plugs are definitely not being activated.

Is this the instability between releases that I’ve heard so much about? Do I need to just wait for the next update to fix this?

TIA.

EDIT: Ok I think I figured it out.
First of all, I think I must have been confusing ‘devices’ with ‘entities’. The dimmer switches only appear in ‘entities’ - I never see them under 'devices.
Secondly, ‘1_click’ doesn’t seem to work reliably. Sometimes it works, but other times I have to hold down the button for a second or so for it to trigger. I’ve actually had better luck binding the automation to 1_click_up, but this brings me to my new discovery:
The Hue bulbs that are connected to the same dimmer will activate as soon as the button goes down. So even with the ‘1_click_up’ workaround, there’s a slightly jarring user experience where the bulbs go on/off as soon as the button is pressed, but the plugs only activate when the button is released.

Is the N_click event supposed to be this unreliable?
Is there a way to detect N_click_down?

I just included a “Hue Smart Button” and it’s working fine so far. However, it only registers “1_click_up” and “1_hold_up”. Is it possible to have “2_click_up” etc. as well?

And is this trigger and condition the correct way to react on a button press?

  trigger:
    platform: state
    entity_id: sensor.hue_smart_button_1
  condition:
    - condition: state
      entity_id: sensor.hue_smart_button_1
      state: '1_click_up'
1 Like

Hello all -

Following a recent update to 2.2 (though that may be coincidence?), I notice that a lot of my sensors have vanished from Lovelace.

It appears, looking at core_entity.registry, that they’ve been given new unique_ids and, I guess because of this, new names?

So my entity that was called sensor.coffee_table_dimmer and had the entry:

{
    "config_entry_id": null,
    "device_id": null,
    "disabled_by": null,
    "entity_id": "sensor.coffee_table_dimmer",
    "name": null,
    "platform": "huesensor",
    "unique_id": "00:17:88:01:03:e7:8b:23"
},

is now sensor.coffee_table_dimmer_2 and has the entry

{
    "config_entry_id": null,
    "device_id": null,
    "disabled_by": null,
    "entity_id": "sensor.coffee_table_dimmer_2",
    "name": null,
    "platform": "huesensor",
    "unique_id": "RWL_00:17:88:01:03:e7:8b:23-02"
},

I can edit this by hand and rename the couple of dozen devices affected, but I thought I should check whether this was expected behaviour?

Follow-up: I’m guessing this may have something to do with this commit?

Quentin

OK - found the related issue in github and am working through it. I expect this will sort it out:

Apologies for multiple posts.

Had the same with v2.2 for al my sensors and remotes, do I deleted the originals (rthey were unavailable) , renamed the new _2 devices and restarted HA, everything worked again.

I’ve installed the component via HACS (in HassIO) in order to get my FoH switches into Hass. However, I might miss something, but the switches are nowhere to be found, also not in the entity registry (all other hue lights + motion sensors do appear).

The installation instructions are very concise, so am I missing something?? :S

Did you add the hue_sensor to your configuration.yaml

I installed the first dimmer in November last year, and got it set up correctly. Now I’m trying to set up a second one (since updating HA) and I can’t find how to set the room for the dimmer. The only place HA seems to support doing this is from Integrations, but the dimmer doesn’t show under the Hue integration, and the component doesn’t seem to have its own integration. (I’ve managed to rename the device from the list of entities under Developer Tools > States, so at least it’s not sensor.hue_dimmer_switch_2 any more :⁣)

I must be missing something, but how can I assign the dimmer to a room in HA?

The only place you can assign the dimmer to a room is in the hue app ?

The huesensor doesn’t do that
You have to setup automation based on buttons pressed

Upgraded to latest release version of Home-Assistant (Hassio v0.104.2). HA v0.104.1 was still working for me. Official integration still don’t work properly: remotes are not available.

Something is off, not with this custom component, but with HA. They did change something. Can’t figure it out yet.

In summary and for reference purposes. I got the following error:

Error while setting up platform hue_custom
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 158, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/hue_custom/binary_sensor.py", line 145, in async_setup_platform
    await data.async_update_info()
  File "/config/custom_components/hue_custom/binary_sensor.py", line 202, in async_update_info
    bridges = get_bridges(self.hass)
  File "/config/custom_components/hue_custom/binary_sensor.py", line 125, in get_bridges
    for entry in hass.data[hue.DOMAIN].values()
KeyError: 'hue'

I think it has something to do with not finding the bridges (last couple of lines) vs the given source code of binary_sensor.py (lines 120 - 128):

def get_bridges(hass):
    from homeassistant.components import hue
    from homeassistant.components.hue.bridge import HueBridge

    return [
        entry
        for entry in hass.data[hue.DOMAIN].values()
        if isinstance(entry, HueBridge) and entry.api
    ]

And (‘new feature’ newly discovered bridges)

Also I added to configuration.yaml (see https://www.home-assistant.io/integrations/hue/#examples )

# Example configuration.yaml entry specifying optional parameters
hue:
  bridges:
    - host: DEVICE_IP_ADDRESS
      allow_unreachable: true
      allow_hue_groups: true

Didn’t work out.

Do I need to re-configure the bridges from scratch?
Utterly reluctant to do, because of https://github.com/home-assistant/home-assistant/issues/30864

Did somebody find a solution perhaps?

Same here, custom integration used to work, but not anymore in 104.2

Sat Jan 18 2020 18:34:28 GMT+0100 (CET)

Error while setting up platform huesensor
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity_platform.py”, line 158, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 442, in wait_for
return fut.result()
File “/config/custom_components/huesensor/sensor.py”, line 167, in async_setup_platform
await data.async_update_info()
File “/config/custom_components/huesensor/sensor.py”, line 224, in async_update_info
bridges = get_bridges(self.hass)
File “/config/custom_components/huesensor/sensor.py”, line 147, in get_bridges
for entry in hass.data[hue.DOMAIN].values()
KeyError: ‘hue’

Same here. This error ballooned logs to 3GB overnight and (obviously) made HA unresponsive this morning. Similar logging issue going on with the SmartThings integration as of 104.2, but I’m not sure if these two issues are related.

HI, I removed the files from the custom_components/huesensor directory and uploaded the most recent files from github. Now it works again.

@bkonijn Thanks alot. You got me triggered! And solved it.

For reference:

Unfortunately, just deleting and copying the correct files over again didn’t work out for me… no error messages anymore though.

So, I tried the HACS version now (long time overdue):
Hue sensor HACS

Keep getting:

  1. Motion: Unavailable
  2. Temp: None
  3. Battery status: None
  4. Switches: Unavailable

Those are all based on the following code:

## Zolder
    attic_temperature:
      friendly_name: 'Zolder'
      value_template: '{{state_attr("binary_sensor.zolder_motion_sensor", "temperature")}}'
      unit_of_measurement: °C

    attic_light_level:
      friendly_name: 'Zolder'
      value_template: '{{state_attr("binary_sensor.zolder_motion_sensor", "lx")}}'
      unit_of_measurement: lux
      device_class: illuminance

    attic_battery_status:
      friendly_name: 'Zolder'
      value_template: '{{state_attr("binary_sensor.zolder_motion_sensor", "battery")}}'
      unit_of_measurement: "%"
      device_class: battery
# switch
    attic_switch_battery_status:
      friendly_name: 'Zolder afstandsbediening'
      value_template: '{{state_attr("sensor.zolder_switch", "battery")}}'
      unit_of_measurement: "%"
      device_class: battery

Could it be that the mentioned entities in the code above somehow during the update/upgrade of HA are either renamed or rediscovered?

Yep:


and

So that is exactly what has happened in my case. Sometimes I don’t appreciate the Home-Assistant ecosystem…

Thus removed numerous obsolete Hue entities and renamed the existing ones.

After restart of HA finally succes!

Anyone else seeing issues with upgrading to v2.4 & HA 0.104.3? Did both at the same time, and now my dimmer remotes don’t show up. I see invalid sensor type in the logs. Tried deleting the HACS files and re-installing, HA restarts, and also tried removing the 'platform: huesensor" configs from configuration.yaml as someone noted above.

Anyone else seeing this? I didn’t see any newer entries in the entity database, either, through any of this.

EDIT: Nevermind. Missed that the update moved the dimmers to their own ‘remote’ class. Removed it as a sensor and added as a remote and back up.

1 Like

Apologies if this has already been answered here but I’m not sure what to search for :woozy_face:

I’ve just started with this component and the initial test is very very promising - currently bursting with automation possibilities for my dimmer switch! My question is - how to prevent the dimmer controlling lights? I don’t want it to act on Hue lights any more, I’d like to drive everything from HA using this component…but I’ve not found a way in the app to have it not control anything.

Thank you!!

I believe you’ll have to use a 3rd party Hue app or just connect to the debug page of the bridge directly to remove control from lights and keep them connected for Home Assistant.