select:
  - platform: template
    id: height_units_config
    name: "Height Units"
    entity_category: "config"
    optimistic: true
    restore_value: true
    options:
      - in
      - cm
    initial_option: ${default_height_units}
    on_value:
      then:
        lambda: |
          const char *unit = id(height_units_config)->state.c_str();
          id(desk_height)->set_unit_of_measurement(unit);
          id(target_desk_height)->traits.set_unit_of_measurement(unit);

button:
  - platform: template
    name: "Re-Detect Decoder"
    entity_category: "config"
    icon: "mdi:cog-refresh"
    on_press:
      - uart.write:
          id: handset_tx
          data: [ 0x0 ]
      - standing_desk_height.detect_decoder: desk_height

number:
  - platform: template
    name: "Min Target Height"
    entity_category: "config"
    min_value: 0
    max_value: 150
    step: 0.1
    optimistic: true
    restore_value: true
    initial_value: ${standing_desk_min_height}
    on_value:
      then:
        lambda: |
          id(target_desk_height)->traits.set_min_value(x);
  - platform: template
    name: "Max Target Height"
    entity_category: "config"
    min_value: 0
    max_value: 150
    step: 0.1
    optimistic: true
    restore_value: true
    initial_value: ${standing_desk_max_height}
    on_value:
      then:
        lambda: |
          id(target_desk_height)->traits.set_max_value(x);