Update on sensor.sensitivity:
attribute sensitivity has been added to the Hue CC https://raw.githubusercontent.com/robmarkcole/Hue-sensors-HASS/master/custom_components/sensor/hue.py
following our discussion on Hue motion sensors + remotes: custom component
and Github https://github.com/robmarkcole/Hue-sensors-HASS/pull/108
so now this template sensor is possible based on the binary_sensor created by the Hue CC:
corridor_motion_sensor_sensitivity:
friendly_name: 'Corridor sensitivity'
value_template: >
{{state_attr('binary_sensor.corridor_motion_sensor','sensitivity')}}
UPDATE
Added a HA interface to the selection of daylight threshold of the motion sensor in the Hue App, using the same rest command I use for the sensitivity. Which is possible because of the templatable format of the command which takes its variable from a script.
for completeness sake, here’s the (almost) full package:
##############################################################################################################
# Package Hue Sensitivity and Threshold by @mariusthvdb
#
# see community discussion on https://community.home-assistant.io/t/map-values-for-an-input-select/94354/5
# and https://community.home-assistant.io/t/hue-motion-sensors-remotes-custom-component/27176/687?u=mariusthvdb
# big help by @pnbruckner @Martso @cicero222 and @petro.
# https://community.home-assistant.io/t/input-select-enhancement-support-maps-key-value-pairs/94391
# jan 25 2019
##############################################################################################################
homeassistant:
customize_glob:
sensor.*_motion_sensor_sensitivity:
templates:
icon: >
if (state === '0') return 'mdi:numeric-0-box-multiple-outline';
if (state === '1') return 'mdi:numeric-1-box-multiple-outline';
return 'mdi:numeric-2-box-multiple-outline';
icon_color: >
if (state === '0') return 'grey';
if (state === '1') return 'blue';
return 'red';
sensor.*_motion_sensor_threshold:
icon: mdi:altimeter
templates:
icon_color: >
if (state > 25000 ) return 'rgb(85, 0, 0)';
if (state > 20000) return 'rgb(255, 0, 0)';
if (state > 15000) return 'rgb(255, 165, 0)';
if (state > 10000) return 'rgb(0, 128, 0)';
if (state > 7500) return 'rgb(255, 211, 30)';
if (state > 5000) return 'rgb(255, 255, 0)';
if (state > 25000) return 'rgb(30, 144, 255)';
if (state > 1000) return 'rgb(30, 255, 255)';
return 'rgb(47, 0, 0)';
customize:
script.set_hue_sensitivity:
action_name: 'Set'
icon: mdi:settings
script.set_hue_threshold:
action_name: 'Set'
icon: mdi:settings
input_select.select_hue_sensitivity:
templates:
icon: >
if (state === 'Low') return 'mdi:numeric-0-box-multiple-outline';
if (state === 'Medium') return 'mdi:numeric-1-box-multiple-outline';
return 'mdi:numeric-2-box-multiple-outline';
icon_color: >
if (state === 'Low') return 'grey';
if (state === 'Medium') return 'blue';
return 'red';
input_number.slide_hue_threshold:
templates:
icon_color: >
if (state > 25000 ) return 'rgb(85, 0, 0)';
if (state > 20000) return 'rgb(255, 0, 0)';
if (state > 15000) return 'rgb(255, 165, 0)';
if (state > 10000) return 'rgb(0, 128, 0)';
if (state > 7500) return 'rgb(255, 211, 30)';
if (state > 5000) return 'rgb(255, 255, 0)';
if (state > 25000) return 'rgb(30, 144, 255)';
if (state > 1000) return 'rgb(30, 255, 255)';
return 'rgb(47, 0, 0)';
##############################################################################################################
# Scripts and Commands
##############################################################################################################
# https://community.home-assistant.io/t/hue-motion-sensors-remotes-custom-component/27176/698?u=mariusthvdb
rest_command:
set_hue_command: #not named sensitivy because the command can be used to set other entities/attributes also
url: !secret url_set_hue_command
method: put
payload: '{{ data }}'
script:
set_hue_sensitivity:
alias: Set Hue sensitivity
sequence:
service: rest_command.set_hue_command
data_template:
command: config
type: sensors
data: >
{% set mapper =
{ 'Low':'0',
'Medium':'1',
'High':'2' } %}
{% set state = states('input_select.select_hue_sensitivity') %}
{% set sensitivity = mapper[state] if state in mapper %}
{"sensitivity": {{sensitivity}} }
id: >
{% set mapper =
{ 'Laundry':'22',
'Dining table':'52',
'Auditorium':'44',
'Frontdoor':'60',
'Dorm':'56',
'Corridor':'5',
'Corridor terrace':'33',
'Master bedroom':'48',
'Corridor Office':'28',
'Control room':'7',
'Attic':'12' } %}
{% set state = states('input_select.select_hue_motion_sensor') %}
{% set id = mapper[state] if state in mapper %}
{{id}}
set_hue_threshold:
alias: Set Hue threshold
sequence:
service: rest_command.set_hue_command
data_template:
command: config
type: sensors
data: >
{"tholddark": {{states('input_number.slide_hue_threshold')|int}} }
id: >
{% set mapper =
{ 'Laundry':'25',
'Dining table':'53',
'Auditorium':'45',
'Frontdoor':'61',
'Dorm':'57',
'Corridor':'6',
'Corridor terrace':'34',
'Master bedroom':'49',
'Corridor Office':'29',
'Control room':'9',
'Attic':'13' } %}
{% set state = states('input_select.select_hue_motion_sensor') %}
{% set id = mapper[state] if state in mapper %}
{{id}}
##############################################################################################################
# Inputs
##############################################################################################################
input_select:
select_hue_sensitivity:
name: select Hue sensitivity
options:
- Low
- Medium
- High
select_hue_motion_sensor:
name: select Motion sensor
icon: mdi:run-fast
options:
- Laundry
- Dining table
- Auditorium
- Frontdoor
- Dorm
- Corridor
- Corridor terrace
- Master bedroom
- Corridor Office
- Control room
- Attic
input_number:
slide_hue_threshold:
icon: mdi:altimeter
name: Slide Hue threshold
min: 0
max: 30000 #hue max = 65534 but makes slider max ot of scale, since max is almost identical to 30000
step: 2500
##############################################################################################################
# Sensors
##############################################################################################################
sensor:
##############################################################################################################
# Sensitivity sensors
##############################################################################################################
#not used anymore, replaced by attributes sensitivity in CC HUE binary sensor
# - platform: command_line
# name: Laundry sensitivity
# command: !secret get_laundry_config
# value_template: >
# {{ value_json.config.sensitivity }}
# - platform: command_line
# name: Auditorium sensitivity
# command: !secret get_auditorium_config
# value_template: >
# {{ value_json.config.sensitivity }}
- platform: template
sensors:
laundry_motion_sensor_sensitivity:
friendly_name: 'Laundry sensitivity'
value_template: >
{{state_attr('binary_sensor.laundry_motion_sensor','sensitivity')}}
dining_table_motion_sensor_sensitivity:
friendly_name: 'Dining table sensitivity'
value_template: >
{{state_attr('binary_sensor.dining_table_motion_sensor','sensitivity')}}
auditorium_motion_sensor_sensitivity:
friendly_name: 'Auditorium sensitivity'
value_template: >
{{state_attr('binary_sensor.auditorium_motion_sensor','sensitivity')}}
# etcetc
##############################################################################################################
# Threshold sensors
##############################################################################################################
- platform: template
sensors:
laundry_motion_sensor_threshold:
friendly_name: 'Laundry threshold'
value_template: >
{{state_attr('binary_sensor.laundry_motion_sensor','threshold')}}
dining_table_motion_sensor_threshold:
friendly_name: 'Dining table threshold'
value_template: >
{{state_attr('binary_sensor.dining_table_motion_sensor','threshold')}}
auditorium_motion_sensor_threshold:
friendly_name: 'Auditorium threshold'
value_template: >
{{state_attr('binary_sensor.auditorium_motion_sensor','threshold')}}
#etcetc
##############################################################################################################
# Groups
##############################################################################################################
group:
set_hue_sensitivity_sensor:
icon: mdi:run-fast
control: hidden
name: Set Hue sensitivity sensor
entities:
- input_select.select_hue_motion_sensor
- input_select.select_hue_sensitivity
- script.set_hue_sensitivity
set_hue_threshold_sensor:
icon: mdi:altimeter
control: hidden
name: Set Hue threshold sensor
entities:
- input_select.select_hue_motion_sensor
- input_number.slide_hue_threshold
- script.set_hue_threshold
hue_sensitivity_sensors:
name: Hue sensitivity sensors
control: hidden
icon: mdi:numeric
entities:
- sensor.laundry_motion_sensor_sensitivity
- sensor.dining_table_motion_sensor_sensitivity
- sensor.auditorium_motion_sensor_sensitivity
- sensor.frontdoor_motion_sensor_sensitivity
- sensor.dorm_motion_sensor_sensitivity
- sensor.corridor_motion_sensor_sensitivity
- sensor.corridor_terrace_motion_sensor_sensitivity
- sensor.master_bedroom_motion_sensor_sensitivity
- sensor.corridor_office_motion_sensor_sensitivity
- sensor.control_room_motion_sensor_sensitivity
- sensor.attic_motion_sensor_sensitivity
hue_threshold_sensors:
name: Hue threshold sensors
control: hidden
icon: mdi:numeric
entities:
- sensor.laundry_motion_sensor_threshold
- sensor.dining_table_motion_sensor_threshold
- sensor.auditorium_motion_sensor_threshold
- sensor.frontdoor_motion_sensor_threshold
- sensor.dorm_motion_sensor_threshold
- sensor.corridor_motion_sensor_threshold
- sensor.corridor_terrace_motion_sensor_threshold
- sensor.master_bedroom_motion_sensor_threshold
- sensor.corridor_office_motion_sensor_threshold
- sensor.control_room_motion_sensor_threshold
- sensor.attic_motion_sensor_threshold
##############################################################################################################
# Notes
##############################################################################################################