Map values for an input_select?

HI,

for a Hue setup, I need to set sensor Ids in the code, but for the frontend I want the humanely understandable names of these sensors in the input_select. I need to map these values:

input_select:
  select_hue_motion_sensor:
  name: Select motion sensor
  options:
    - 5
    - 7
    - 12
    - 22
    - 28
    - 33
    - etc

to read like:

input_select:
  select_hue_motion_sensor:
  name: Select motion sensor
  options:
    - Corridor
    - Corridor terrace
    - Master bedroom
    - Corridor Office
    - Control room
    - Attic

to be able to use the numbers in this command:

rest_command:
  hue_command:
    url: 'http://HUE_BRIDGE_IP/api/APIKEY/{{ type }}/{{ id }}/{{ command }}'
    method: put
    payload: '{{ data }}'

automation:

  - id: set_motion_sensitivity
    trigger:
      [some_trigger]
    action:
      service: rest_command.hue_command
      data:
        command: config
        data: >
          { "sensitivity": "{{states('input_select.set_hue_sensitity')}}" }
        id: >
          {{states('input_select.select_hue_motion_sensor')}}
        type: sensors

create a mapper in the automation? suppose this could work for the 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}}

but how do I get that in the automation and rest command?
@petro please have a look with me would you?

2 Likes

It seems to me that you already have the solution. Just put the mapping code you’ve created in the automation’s id: section. Or did I misunderstand your requirements?


EDIT
I get the feeling I’m overlooking something important because this seems too easy … and you are a guru with this stuff! :slight_smile:

I’m not sure how you can do this without using python for a dynamic rest command.

o. What I try to do is build on this work by @Martso Hue motion sensors + remotes: custom component - #698 by Martso and template the id’s

1 Like

Ok, so everything he has is what you would use if I read his post properly.

  - id: set_motion_sensitivity
    trigger:
      [some_trigger]
    action:
      service: rest_command.hue_command
      data_template:
        command: config
        data: 
          sensitivity: >
            {{states('input_select.set_hue_sensitity')}}
        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}}
        type: sensors

or you could create a template sensor that updates and just has the number.

sensor:
  - platform: template
    sensors:
      hue_map:
        value_template: >
          {% 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 }}

automation:

  - id: set_motion_sensitivity
    trigger:
      [some_trigger]
    action:
      service: rest_command.hue_command
      data_template:
        command: config
        data:
          sensitivity: >
            {{ states('input_select.set_hue_sensitity') }}
        id: >
          {{ states('sensor.hue_map') }}
        type: sensors
10 Likes

That’s exactly what I’m trying to do and was looking for thank you very much!!

Been a long day and couldn’t see anymore but now you did, it makes sense again;-)

1 Like

So put the mapper code in the id: section? Cool! I got it right. :slight_smile: However, I overlooked the detail of changing data to data_template. I’ll eventually get the hang of it.

But I do like petro’s suggestion to move the mapping to a separate sensor. Makes it re-usable for other automations and makes the automation’s code neater.

Ideally, input_select would support a list of key-value pairs (list of lists). Then it could effectively store the mapping and you could identify the selected item either by key or value. Of course, that would be a heckuva breaking change!

options:
- - Corridor
  - '5'
- - Corridor terrace
  - '7'
- - Master bedroom
  - '12'
- - Corridor Office
  - '22'
- - Control room
  - '28'
- - Attic
  - '33'

Yah, it would be nice to have a map. I would theroize it would look something like this (to correctly follow yaml rules)

  options:
    - option: Corridor
      value: '1'
    - option: Corridor terrace
      value: '7'
    - option: Master bedroom
      value: '12'
    - option: Corridor Office
      value: '22'
    - option: Control room
      value: '28'
    - option: Attic
      value: '33'

And if this is done, I think the changes could be backward compatible. I.E. Under the hood this is a list of dictionaries where the old method is a list of strings. You can easily tell between the 2.

I think this would make a great feature request. Not sure if it would get much traction though.

3 Likes

It would certainly put the mapping where it belongs, namely with the selector (the source of truth).

I like your version (option:/value:) better. I used ‘list of lists’ style but it looks awkward and may be more error-prone when indenting.

1 Like

Yeah, people would get confused too. That’s usually the biggest issue. And yaml is confusing enough!

1 Like

I’ll submit it in the Feature Requests section. At the very least, the idea will be documented.

3 Likes

ill vote for it

1 Like

well, tbh, Im not sure…
I could imagine this would work in the backend, but my idea of the mapper is to keep backend stuff in the backend, and make the frontend as humanly understandable as possible. Don’t want the id’s in the frontend, but only then names…

If this mapper would enable that, Id vote for it :wink:

have another feature request though, that is, for my automations…

if Id like to set the sensitivity for a group of lets say 5 sensors in a group, or individual, to medium (1) how could I do that without having to select 5 sensors individually.

Could we make a loop (for sensors 1-5) or for sensors id in group.hallway_motion_sensors. etc etc?

now thats a challenge with the above automation, which might even turnout to become a script

input select: sensitivity
input select: sensors
script: rest_command.hue_command

Yes, that’s the goal. Referring to petro’s example, only option: would be shown in the selector and not value:.

In the home automation system I use now (Premise), it lets you create the mapping as a separate entity (called an enumeration). The enumeration contains child objects called enums. An enum has a name and a value (and more).

When you create a multivalue selector you specify which enumeration it should use. So, technically speaking, the mapping is not stored with the selector but stands alone. You just tell the selector which mapping (enumeration) it should use.

This illustrates the relationship between a selector (OccupancyMode), its enumeration (OccupancyModes), and the enums in the enumeration (Day, Night, Away, Vacation).

I don’t think Home Assistant needs this level of flexibility. Just being able to have a map defined with the selector is a big improvement.

1 Like

yes, that is clear.
I don’ t feel to miss out on any of that though in HA, maybe because I am so used to these mappers… Simple forgot to put it in the action…

btw, when it boils down to using the mapper directly, or via an intermediary template sensor, I ,for now, prefer the former, to keep things together. And, avoid as many extra states/entities as possible, having over 1600 of them already…

If at one point Id be able to use a template elsewhere that might change of course. Just as the rest command is a template that can be used in other situations, kind of a module so to speak.

try {{states|count}} in dev-template :wink:

well, ive taken it this far for now. Somehow the command doesn’t work yet. I think the template for data {"sensitivity": "{{states('input_select.set_hue_sensitity')}}" } is causing that, or the fact that my secret is not allowing the variables.

this is in the secrets file:

url_set_hue_command: http://192.168.1.212/api/API/{{ type }}/{{ id }}/{{ command }}

ill give it a nights sleep, please check with me what cold be wrong?

18
##############################################################################################################
# Package Hue commands by @mariusthvdb
# see community discussion on Map values for an input_select?
# and Hue motion sensors + remotes: custom component
# big help by @pnbruckner @Martso @cicero222 and @petro. @123 file a feature request for the mappings on
# Input_select enhancement. Support mapping
# jan 25 2019
##############################################################################################################

homeassistant:
  customize:
    script.set_hue_command:
      action_name: 'Set sensitivity'
      icon: mdi:settings

    input_select.set_hue_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';

##############################################################################################################
# Scripts and Commands
##############################################################################################################
# https://community.home-assistant.io/t/hue-motion-sensors-remotes-custom-component/27176/698?u=mariusthvdb
rest_command:
  set_hue_command:
    url: !secret url_set_hue_command
    method: put
    payload: '{{ data }}'

script:
  set_hue_command:
    alias: Set Hue command
    sequence:
      service: rest_command.set_hue_command
      data_template:
        command: config
        data: >
          {"sensitivity": "{{states('input_select.set_hue_sensitity')}}" }
        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}}
        type: sensors

##############################################################################################################
# Inputs
##############################################################################################################

input_select:
  set_hue_sensitivity:
    name: set Hue sentitiviy
    options:
      - '0' #low
      - '1' #medium
      - '2' #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

##############################################################################################################
# Groups
##############################################################################################################

group:
  set_hue_sensor_sensitivity:
    icon: mdi:run-fast
    control: hidden
    name: Set Hue sensor sensitivity
    entities:
      - input_select.select_hue_motion_sensor
      - input_select.set_hue_sensitivity
      - script.set_hue_command

The package refers to the selector using three different versions of the word 'sensitivity`.

In customize:

input_select.set_hue_sensitivity: <--- sensitivity

In script:

{"sensitivity": "{{states('input_select.set_hue_sensitity')}}" } <--- sensitity

For input_select:

name: set Hue sentitiviy <--- sentitiviy

good catch!
didn’t help though…
test results so far:

secret with variable to secrets file: check, working fine (hadn’t done that before, so good to know)
template for id: check! working fine.

now testing template for sensitivity chichis a bit more of a challenge, though I see I had quoted the template and it should really be:

      `{"sensitivity": {{states('input_select.select_hue_sensitivity')}} }`

Update

Bingo!!:

I can report Ive got it working as hoped for, and made a few testing sensors to show it does, like:

- platform: command_line
  name: Laundry sensitivity
  command: curl -X GET http://192.168.1.212/api/API/sensors/22
  value_template: >
    {{ value_json.config.sensitivity }}

44
35
36

new package, fully functional, with added sensors and a new Mapper for sensitivity:

##############################################################################################################
# Package Hue sensitivity 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. @123 filed a feature request for the mappings on
# https://community.home-assistant.io/t/input-select-enhancement-support-maps-key-value-pairs/94391
# jan 25 2019
##############################################################################################################

homeassistant:
  customize:
    script.set_hue_sensitivity:
      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';

    sensor.laundry_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.auditorium_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';

##############################################################################################################
# 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}}


##############################################################################################################
# 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

##############################################################################################################
# Sensors
##############################################################################################################
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 }}

##############################################################################################################
# Groups
##############################################################################################################

group:
  set_hue_sensor_sensitivity:
    icon: mdi:run-fast
    control: hidden
    name: Set Hue sensor sensitivity
    entities:
      - sensor.laundry_sensitivity
      - sensor.auditorium_sensitivity
      - input_select.select_hue_motion_sensor
      - input_select.select_hue_sensitivity
      - script.set_hue_sensitivity

##############################################################################################################
# Notes
##############################################################################################################

UPDATE

with Tiles, mimicking the Hue App:

42

2 Likes

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.

36

31
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
##############################################################################################################
1 Like

as an update:

Above scripts work fine, and setting the input selects is great as an interface with manual input.

Had the need to use these in automation directly with fixed values for some of my scenes.

So created a ‘direct’ script:

  set_hue_sensitivity_direct:
    alias: Set Hue sensitivity direct
    sequence:
      service: rest_command.set_hue_command
      data_template:
        command: config
        type: sensors
        data: >
          {"sensitivity": {{sensitivity}} }
        id: >
          {{id}}

tested it in the dev-service, with data

{"sensitivity": 0,"id":44} my motion sensors gets its sensitivity set accordingly. So I know this works as designed.

using this in the scenes now:

- service: script.set_hue_sensitivity_direct
  data_template:
    id: 44
    sensitivity: 0

sets the sensors accordingly. Which is great, cause I can now do it manually with the input_selects, and in an automation setting sensor and sensitivity directly :wink: