Map values for an input_select?

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