Automation based on input select with schedule

Hi, I’m probably trying to reinvent wheel but I want to have a input select with 3 states:

  • Manual On
  • Manual Off
  • Schedule

this would trigger some automation/scene that would control an shelly switch to enable/disable device based on the state. If schedule is selected then a fixed schedule would operate the switch.

any idea how to do that?

Also how would anyone create a button card for this with 3 buttons instead of the ugly list dropdown.

Thx

Here’s one way to approach the automation. It assumes you are using a schedule helper (or template binary sensor).

trigger:
  - platform: state
    entity_id: binary_sensor.shelly_schedule
    to: 
      - 'on'
      - 'off'
    from: 
      - 'on'
      - 'off'
    id: schedule
  - platform: state
    entity_id: 
    to: Schedule
    id: schedule
  - platform: state
    entity_id: input_select.shelly
    not_to:
      - Schedule
      - unknown
      - unavailable
    id: manual
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: schedule
          - condition: state
            entity_id: input_select.shelly
            state: 'Schedule'
        sequence:
          - service: switch.turn_{{ states('binary_sensor.shelly_schedule') }}
            target:
              entity_id: switch.shelly 
      - conditions:
          - condition: trigger
            id: manual
        sequence:
          - service: switch.turn_{{ (trigger.to_state.state)[7:] | lower }}
            target:
              entity_id: switch.shelly

For the buttons, you just need to assign each button an appropriate tap action. Here’s an example using the core Button card.

show_name: true
show_icon: true
type: button
entity: input_select.shelly
name: 'On'
tap_action:
  action: call-service
  service: input_select.select_option
  target:
    entity_id: input_select.shelly
  data:
    option: 'Manual On'