Map values for an input_select?

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