#Boiler Switch

1 messages · Page 1 of 1 (latest)

viscid vale
#

I am trying my best to make a boiler switch with a timer in HA and I'm really struggling.
What I want is to have a timer and I've mapped it all out with a flowchart:

  1. If the boiler switch is turned on but the timer is at 0 then change the timer to be 120 minutes (and send a notification to my phone)
  2. If the timer changes from 0 and the boiler is off then turn on the boiler
  3. If the timer reaches 0 then turn off the boiler (and send a notification to my phone)

Here are the automations I've made:

Number 1:

description: ""
triggers:
  - trigger: state
    entity_id:
      - switch.bot_4b2a
    to: "on"
conditions:
  - condition: numeric_state
    entity_id: input_number.boiler_timer
    above: -0.1
    below: 0.1
actions:
  - action: input_number.set_value
    metadata: {}
    data:
      value: 120
    target:
      entity_id: input_number.boiler_timer
  - action: notify.mobile_app_pixel_9_pro_xl
    data:
      message: >-
        The boiler has been turned on and will turn off automatically after 2
        hours.
      title: Boiler Control
      data:
        actions:
          - action: ADD_30
            title: Add 30 Minutes
          - action: ADD_60
            title: Add 1 Hour
          - action: SUB_30
            title: Subtract 30 Minutes
          - action: SUB_60
            title: Subtract 1 Hour
mode: single

Number 2:

description: ""
triggers:
  - trigger: state
    entity_id:
      - input_number.boiler_timer
    from: "0"
  - trigger: homeassistant
    event: start
conditions:
  - condition: state
    entity_id: switch.bot_4b2a
    state: "off"
  - condition: numeric_state
    entity_id: input_number.boiler_timer
    above: 0.1
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.bot_4b2a
mode: single
```
#

Number 3:

description: ""
triggers:
  - entity_id: input_number.boiler_timer
    to: "0"
    trigger: state
conditions:
  - condition: state
    entity_id: switch.bot_4b2a
    state: "on"
  - condition: template
    value_template: >-
      {{ now() -
      state_attr('automation.if_boiler_turns_on_when_timer_is_at_0_120',
      'last_triggered') | default(timedelta(0)) > timedelta(seconds=5) }}
actions:
  - target:
      entity_id: switch.bot_4b2a
    action: switch.turn_off
    data: {}
  - data:
      message: Water is hot! Boiler turned off.
      title: Boiler Timer Finished
      data:
        actions:
          - action: ADD_30
            title: Add 30 Minutes
          - action: ADD_60
            title: Add 1 Hour
    action: notify.mobile_app_pixel_9_pro_xl
mode: single

Timer Automation Countdown:

description: ""
triggers:
  - trigger: time_pattern
    minutes: /5
conditions:
  - condition: numeric_state
    entity_id: input_number.boiler_timer
    above: 0
actions:
  - action: input_number.set_value
    metadata: {}
    data:
      value: "{{ [states('input_number.boiler_timer') | int - 5, 0] | max }}"
    target:
      entity_id: input_number.boiler_timer
mode: queued
max: 10
#

Interaction with Notifications:

description: ""
triggers:
  - event_type: mobile_app_notification_action
    event_data:
      action: ADD_30
    trigger: event
  - event_type: mobile_app_notification_action
    event_data:
      action: ADD_60
    trigger: event
  - event_type: mobile_app_notification_action
    event_data:
      action: SUB_30
    trigger: event
  - event_type: mobile_app_notification_action
    event_data:
      action: SUB_60
    trigger: event
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - ADD_30
        sequence:
          - target:
              entity_id: input_number.boiler_timer
            data:
              value: >-
                {{ [states('input_number.boiler_timer') | int + 30, 240] | min
                }}
            action: input_number.set_value
      - conditions:
          - condition: trigger
            id:
              - ADD_60
        sequence:
          - target:
              entity_id: input_number.boiler_timer
            data:
              value: >-
                {{ [states('input_number.boiler_timer') | int + 60, 240] | min
                }}
            action: input_number.set_value
      - conditions:
          - condition: trigger
            id:
              - SUB_30
        sequence:
          - target:
              entity_id: input_number.boiler_timer
            data:
              value: "{{ [states('input_number.boiler_timer') | int - 30, 0] | max }}"
            action: input_number.set_value
      - conditions:
          - condition: trigger
            id:
              - SUB_60
        sequence:
          - target:
              entity_id: input_number.boiler_timer
            data:
              value: "{{ [states('input_number.boiler_timer') | int - 60, 0] | max }}"
            action: input_number.set_value
mode: single