Switch controller by hand and timer

I’m trying to configure a switch (MQTT relay) to be used in both hand and automated way. Here the behavior I would like to achieve:

  • I can manually turn on/off the switch as I wish
  • if I turn on the switch it will turn off automatically after X minutes, defined by an input value
  • if enabled, an automation will trigger on the switch at the predefined time (and it will be automatically turned off after X minutes as before)

Right now I’ve done the following:

configuration:

switch:
  - platform: mqtt
    name: "Sprinkler"
    command_topic: "home/alarm/rele/2"
    state_topic: "home/alarm/rele/2/state"
    availability_topic: "home/alarm/availability"
    payload_available: "online"
    payload_not_available: "offline"

input_number:
  sprinkler_timer:
    name: Duration
    initial: 5
    min: 1
    max: 10
    unit_of_measurement: minutes
    step: 1

timer:
  sprinkler:
    duration: 0

groups:

  default_view:
    view: yes
    name: Home
    icon: mdi:home
    entities:
      - updater.updater
      - group.groupGarden

  groupGarden:
    name: Garden
    control: hidden
    entities:
      - light.garden_lights
      - switch.sprinkler
      - timer.sprinkler
      - input_number.sprinkler_timer

automation:

- id: sprinkler_begin
  alias: Sprinkler begin
  trigger:
  - platform: state
    entity_id: switch.sprinkler
    to: on
  action:
  - service: timer.start
    entity_id: timer.sprinkler

- id: sprinkler_cancelled
  alias: Sprinkler cancelled
  trigger:
  - platform: state
    entity_id: switch.sprinkler
    to: off
  action:
  - service: timer.cancel
    entity_id: timer.sprinkler

- id: sprinkler_end
  alias: Sprinkler end
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.sprinkler
  action:
  - entity_id: switch.sprinkler
    service: switch.turn_off

- id: sprinkler_start
  alias: Sprinkler start
  hide_entity: false
  initial_state: true
  trigger:
  - event: sunset
    offset: 00:30:00
    platform: sun
  action:
  - entity_id: switch.sprinkler
    service: switch.turn_on
  - data:
      message: Sprinkler turned on
    service: notify.pushbullet

Is this the correct approach?