Hue motion sensors + remotes: custom component

Great, thanks for confirming that :+1:t3:

of course thats very nice! Although: cant you set that in the hue app itself? Maybe much simpler.
What i like about this is the option to trigger something else than light.turn_on. One could trigger anything available in HA for that matter, from a switch, door to complete scenes?

Very nice indeed.

interesting read: https://www.howtogeek.com/244803/how-to-re-program-the-hue-dimmer-switch-to-do-anything-with-your-lights/

or this one by a certain author :wink:

Thank you. Of course I don`t use that automation to control my hue lights, that would be stupid :stuck_out_tongue: The service there was just an example, it was the trigger and condition set up that was of interest. I use the remote to turn off all my lights, which is 433 Mhz devices and hue lights, my tv, stereo etc. What I like about the remote is that it is seems more stable than my previous 433 Mhz remote, and is 3 times cheaper than a z-wave remote :slight_smile:

I dont`t use iphone, so I wouldn’t know about the app.
The link you referring are just setup using rest sensor instead of the custom component? Since the custom component register the remote anyways, that is the old way of doing it, as the link refers to the custom component?

Btw, if you want to use both long click and click function, you need to do one of the following, since when you long click, you first send a click command, then the hold command:

1: Set longer update interval for all your sensor, so homeassistant don`t register the click command when you long press.

or

2: Add delay and condition in action:

 - alias: "Lys Spotter Kjokken På 2"
   trigger:
    - platform: state
      entity_id: sensor.dimmer_hue_template_last_updated
   condition: 
    condition: template
    value_template: '{{ states.sensor.hue_dimmer_switch_gang.last_updated.strftime("%H:%M:%S") == utcnow().strftime("%H:%M:%S") and states.sensor.hue_dimmer_switch_gang.state == "4_click" }}'   
   action:
    - delay: 00:00:01
    - condition: state
      entity_id: sensor.hue_dimmer_switch_gang
      state: '4_click'
    - service: light.turn_on
      data:
        entity_id: light.lys_spotter_stue 
        brightness_pct: 100    

You just need to add that to the automation you want when you use the click as trigger condition. The hold state won’t be triggered unexpected.

Thanks again @robmarkcole for this great custom component! Just hope in the future it would be possible to get rid of all the error messages in the log. Then everything would be perfect :slight_smile:

Edit: Can of course do it a little easier:

 - alias: "test"
   trigger:
    - platform: state
      entity_id: sensor.dimmer_hue_template_last_updated
   condition: 
    condition: state
    entity_id: sensor.hue_dimmer_switch_gang
    state: '4_click'
    for:
      seconds: 1
   action:
     - service: switch.turn_on
       entity_id: switch.lys_taklys_kjokken 

 - alias: "test2"
   trigger:
    - platform: state
      entity_id: sensor.dimmer_hue_template_last_updated
   condition: 
    condition: state
    entity_id: sensor.hue_dimmer_switch_gang
    state: '4_hold'
   action:
    - service: light.turn_on
      data:
        entity_id: light.lys_spotter_kjokken  
        brightness_pct: 100

I’m struggling a bit to get this working, and I’m wondering if there’s a step I’m missing.

platform: rest
resource: http://[ipaddress]/api/[key]/sensors/5/config
method: put
name: Movie Room Sensor
body_on: '{"on": true}'
body_off: '{"on": false}'

I’m using Hassio and connecting via Duckdns. The ip address is in the internal network (192.168.x.x). To run it, I’m simply doing the following:

  - alias: "Movie Room Sensor On"
    trigger:
      - platform: state
        entity_id: input_boolean.movie_room_sensor
        to: 'on'
         
      
    action:

        - service: switch.turn_on
          entity_id: switch.movie_room_sensor
     
  - alias: "Movie Room Sensor Off"
    trigger:
      - platform: state
        entity_id: input_boolean.movie_room_sensor
        to: 'off'
         
      
    action:
   
        - service: switch.turn_off
          entity_id: switch.movie_room_sensor

Is anything jumping out to you? It’s working when I use the hue debugger, so I know I got the syntax and URL correct.

Hi @Litrecola have you got it working with requests or Postman?
I can’t see anything obviously wrong but I would certainly debug with one of those tools.

I was able to get the GET REST working from the sensor without a problem (for the temperature). My syntax must just be off. Luckily another user got around the issues they were having through CURL:

1 Like

Hey there! I just got a pi and home assistant to trigger wemo lights with hue motion sensor and remotes.

I followed the instructions in https://github.com/robmarkcole/Hue-sensors-HASS
but it replaced all of my discovered devices with my sensors plus some weird attributes.

Do you see any obvious mistake I made?

Hi Rob!

When I try to create a binary sensor out of this sensor’s attributes, I always get errors. Any idea why this may be?

config:

- platform: template
  sensors:
    kitchen_is_lit:
      friendly_name: 'Kitchen Is Lit'
      device_class: light
      value_template: {{ is_state_attr('sensor.kitchen_motion_sensor', 'dark', false) }}

result:

ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while parsing a flow mapping
  in "/config/binary-sensors.yaml", line 24, column 32
expected ',' or '}', but got '<scalar>'
  in "/config/binary-sensors.yaml", line 24, column 79

Any help would be appreciated!

Appears you have not specified an attribute (Lux) the example config in the github repo should help

The temperature and light level work nicely. I wanted to do a binary_sensor here, but no matter what I tried, I never got on/off from the true/false of the attributes.

Please use the dev-template tool to check what your template is returning, as to me your config looks fine.

I must be overlooking something obvious! Currently trying

    kitchen_motion:
      friendly_name:          Kitchen Motion
      device_class:           motion
      value_template:         {{ states('sensor.kitchen_motion_sensor') == 'on' }}

when in the config file

ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: invalid key: "OrderedDict([("states('sensor.kitchen_motion_sensor') == 'on'", None)])"
  in "/config/binary-sensors.yaml", line 24, column 0

but in dev-template the same template {{ states('sensor.kitchen_motion_sensor') == 'on' }} returns true/false as expected.

Try putting the value template inside string quotation marks as others have done on this thread

Yes, using both single and double quotes solved it.

binary_sensor: 
- platform:                    template
  sensors:
    kitchen_motion:
      friendly_name:           Kitchen Motion
      device_class:            motion
      value_template:          '{{ states("sensor.kitchen_motion_sensor") == "on" }}'

    kitchen_sensor_reachable:
      friendly_name:           Kitchen Sensor Reachable
      device_class:            connectivity
      value_template:          '{{ states.sensor.kitchen_motion_sensor.attributes.reachable }}'

Thanks!

1 Like

I have a strange issue (strange since nobody reported the same it looks). Since I deployed this custom components I can nicely see (and use) my hue remotes in HA but I lost the ability to have my Hue lights reporting correctly their status (meaning the allow_unreachable does not work properly anymore …). When non powered (because the physical switch is off) lights do show are “unavailable” now instead of “off”. Did I miss something while deploying the components ? Thanks !

This component performs read only of the sensor data, so I think your issue is unrelated. If you can dig up any error messages that would help diagnose the possible cause.
Cheers

I can only see in the logs this
2018-03-15T17:07:44.908039281Z [32m2018-03-15 18:07:44 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=light.couloir, old_s
tate=None, new_state=<state light.couloir=unavailable; friendly_name=Couloir, supported_features=43 @ 2018-03-15T18:07:44.907683+01:00>>

To validate my assumption I went ahead and deleted your custom components and indeed I still have the same issue so it seems not to be related … Thanks a lot and sorry for my stupid question then …

1 Like

Been bugging me for a while. Inset this up and then added in some other scenes so it appears to have changed the virtual sensor or links to the real sensor. Anyone know the best way to relink to correct one so it shows in front end?

Not even sure it’s an issue with sensors actually as I can still see when last motion occured by clicking on the sensor but doesn’t show ‘0’ ‘1’ ‘Off’ or ‘on’

Does anyone know why my other discovered devices do not appear on the dashboard anymore after doing this?