Hue-sensors-HASS
Hue-sensors-HASS copied to clipboard
please add schedule times day and night to the sensors
discussion on community:
https://community.home-assistant.io/t/hue-motion-sensors-remotes-custom-component/27176/712?u=mariusthvdb
would love to have the day and night schedule times, since creating them manually is quite a thing... created this rest sensor, which I would hope could be added to the CC, to make creation for all sensors automatic (if it would be feasible to find the correct rules, maybe on MotionSensor id? : full json response for a relevant rule
{"name":"MotionSensor 5.night-on","owner":"redacted","created":"2019-01-25T12:39:31","lasttriggered":"2019-01-26T23:59:35","timestriggered":5,"status":"enabled","recycle":true,"conditions":[{"address":"/config/localtime","operator":"in","value":"T22:45:00/T06:30:00"},{"address":"/sensors/5/state/presence","operator":"eq","value":"true"},{"address":"/sensors/5/state/presence","operator":"dx"},{"address":"/sensors/35/state/status","operator":"lt","value":"1"},{"address":"/sensors/6/state/dark","operator":"eq","value":"true"}],"actions":[{"address":"/groups/4/action","method":"PUT","body":{"scene":"qb90i7QlIWkYeG-"}},{"address":"/sensors/35/state","method":"PUT","body":{"status":1}}]}
- platform: rest
name: Master bedroom schedule rst
resource: http://192.168.1.212/api/API/rules/20
method: GET
value_template: >
{{ value_json.conditions[0].value }}
or if that would fit the CC better, a command_line sensor:
- platform: command_line
name: Control room schedule
command: curl -X GET http://192.168.1.212/api/API/rules/128
value_template: >
{{ value_json.conditions[0].value }}
and template these out like:
master_bedroom_schedule_night:
friendly_name: Master bedroom schedule night
value_template: >
{{states('sensor.master_bedroom_schedule_rst')[1:-13]}}
master_bedroom_schedule_day:
friendly_name: Master bedroom schedule day
value_template: >
{{states('sensor.master_bedroom_schedule_rst')[11:-3]}}
to use the in automations like:
- alias: 'Weekend Switch Off Masterbedroom motion sensor'
id: 'Weekend Switch Off Masterbedroom motion sensor'
# initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.now_master_bedroom_schedule_day
to: 'on'
# at: '07:00:00' # the time set in the Hue app, which has only day setting, and doesn't recognize weekend
# platform: template
# value_template: >
# {{now().time().strftime('%H:%M') == states('sensor.master_bedroom_schedule_day')}}
condition:
- condition: template
value_template: >
{{ is_state ('sensor.activity_selection', 'Slapen')}}
- condition: template
value_template: >
{{is_state('binary_sensor.workday_sensor','off') or
is_states('input_boolean.home_mode_vacation','on')}}
action:
- service: switch.turn_off
entity_id: switch.master_bedroom_motion_sensor_switch
with:
now_master_bedroom_schedule_day:
friendly_name: 'Now Master bedroom schedule day'
entity_id: sensor.time
value_template: >
{{now().time().strftime('%H:%M') == states('sensor.master_bedroom_schedule_day')}}
thanks for considering!
With the latest updates, I can't get see my motion sensors any longer. The switches work fine. I have the sensor and binary sensor py files. I just updated to hass 0.89.1.
@yottatsa
forgive me for only seeing this now (help wanted) , let me know what help do you need?
I am still using this, and after a recent reset of my Hue Hub realized how great it would be if selecting and setting those schedules could be done from within HA...natively.
right now it is a matter of: 1 finding the correct sensor id 2 finding the correct (day-on and night-on) rules for that sensor-id 3 setting all 4 rules for that sensor with the desired timings.
like this eg for my sensor 48 (note that I've taken it a bit further, and I do this fully automated, based on setting an alarmtime. Complicating factor is the Hue hub needs the full set of addresses in the api call, which can be found when looking for the correct rules:
set_hue_alarm_time_wakeup:
alias: Set Hue alarm time wakeup
sequence:
- delay:
seconds: 2
# "name":"MotionSensor 48.day-on"
- service: rest_command.set_hue_rule
data_template:
type: rules
id: 1
data: >
{% set schedule = states('sensor.master_bedroom_schedule_rst') %}
{% set alarm = states('sensor.alarmclock_wd_time') %}
{"conditions":[{"address":"/config/localtime","operator":"in","value":"T{{alarm}}:00/{{schedule.split('/')[1]}}"},
{"address":"/sensors/48/state/presence","operator":"eq","value":"true"},
{"address":"/sensors/48/state/presence","operator":"dx"},
{"address":"/sensors/83/state/status","operator":"lt","value":"1"},
{"address":"/sensors/49/state/dark","operator":"eq","value":"true"}] }
#"name":"MotionSensor 48.day-dark-on"
- service: rest_command.set_hue_rule
data_template:
type: rules
id: 2
data: >
{% set schedule = states('sensor.master_bedroom_schedule_rst') %}
{% set alarm = states('sensor.alarmclock_wd_time') %}
{"conditions":[{"address":"/config/localtime","operator":"in","value":"T{{alarm}}:00/{{schedule.split('/')[1]}}"},
{"address":"/sensors/48/state/presence","operator":"eq","value":"true"},
{"address":"/sensors/49/state/dark","operator":"eq","value":"true"},
{"address":"/sensors/49/state/dark","operator":"dx"},
{"address":"/sensors/83/state/status","operator":"lt","value":"1"}] }
# "name":"MotionSensor 48.night-on"
- service: rest_command.set_hue_rule
data_template:
type: rules
id: 3
data: >
{% set schedule = states('sensor.master_bedroom_schedule_rst') %}
{% set alarm = states('sensor.alarmclock_wd_time') %}
{"conditions":[{"address":"/config/localtime","operator":"in","value":"{{schedule.split('/')[1]}}/T{{alarm}}:00"},
{"address":"/sensors/48/state/presence","operator":"eq","value":"true"},
{"address":"/sensors/48/state/presence","operator":"dx"},
{"address":"/sensors/83/state/status","operator":"lt","value":"1"},
{"address":"/sensors/49/state/dark","operator":"eq","value":"true"}] }
# "name":"MotionSensor 48.night-dark-on"
- service: rest_command.set_hue_rule
data_template:
type: rules
id: 4
data: >
{% set schedule = states('sensor.master_bedroom_schedule_rst') %}
{% set alarm = states('sensor.alarmclock_wd_time') %}
{"conditions":[{"address":"/config/localtime","operator":"in","value":"{{schedule.split('/')[1]}}/T{{alarm}}:00"},
{"address":"/sensors/48/state/presence","operator":"eq","value":"true"},
{"address":"/sensors/49/state/dark","operator":"eq","value":"true"},
{"address":"/sensors/49/state/dark","operator":"dx"},
{"address":"/sensors/83/state/status","operator":"lt","value":"1"}]}
hope this helps, let me know if I could further assist.
So you want:
- a sensor which pulls the schedule on the Motion sensor in order to trigger actions on day/night consistently, and
- a service to update this values back to Hue.
Am I right?
yes! that would really be awesome. As you can see, I've handmade it all now, but that is rather a tedious process, and if ever the hue hub gets reset, you need to manually check all rules/sensors sets.
If that could be done from within the CC that would really be magic.
Imagine: set you alarm time in HA, and automatically adjust the wakeup schedule in Hue. I am dong that right now, and don't want to miss out on it again... thanks for considering, and please let me know if I can assist in any way
Maybe this would be best as a separate custom component? Say like Hue_Schedules or something similar. I see this component as being one to expose sensors to Home Assistant and Home Assistant doing all the automations, including night and day settings. It might over-complicate the "sensor" component for others who have Home Assistant handling all the automations. I don't use Hue Schedules as Home Assistant does that for me and if I set it in Hue App and Home Assistant it would basically be a double up. I just use the Hue bridge and this component to expose the sensors to Home Assistant and let Home Assistant handle the automations in one place.
This is just my thoughts on this and obviously everyone has there own thoughts.