17.從零開始裝 Home Assistant 熱水器自動化

原本的自動化是使用sonoff內建的功能,不過要快速調整

就比較繁瑣一點。

所以就使用HA來建立自動化


設定-裝置與服務-輔助工具(上方)-新增輔助工具


搜尋計時器


名稱就自己取,選個圖案




點一下之後按小齒輪,就可以看到實體ID

建議先複製下來


再新增兩個數字輔助工具


一個叫熱水加熱時間,最小加熱時間10分鐘,最大是120分鐘,

刻度為1即可


一個叫熱水加熱溫度,最小加熱時間30度,最大是60度,

刻度為1即可


按一下取得實體ID


輔助工具

  1. 熱水計時器(計時器) timer.dao_ji_shi_jia_re
  2. 熱水加熱溫度(數字) input_number.input_number_bath_target_temp
  3. 熱水加熱時間(數字) input_number.input_number_bath_duration_min

實際的sonoff溫控開關

  1. 開關 switch.sonoff_10018d035a
  2. 溫度傳感器 sensor.sonoff_10018d035a_temperature



設定-自動化與場景-新增自動化-空白自動化開始

右上角的點點-以YAML編輯


alias: 電熱水器
description: 溫度達標即關閉,時間到關閉並通知目前水溫
triggers:
  - entity_id: switch.sonoff_10018d035a
    from: "off"
    to: "on"
    id: system_start
    trigger: state
  - event_type: timer.finished
    event_data:
      entity_id: timer.dao_ji_shi_jia_re
    id: timer_end
    trigger: event
  - entity_id: sensor.sonoff_10018d035a_temperature
    id: temp_change
    trigger: state
actions:
  - choose:
      - conditions:
          - condition: trigger
            id: system_start
        sequence:
          - target:
              entity_id: timer.dao_ji_shi_jia_re
            data:
              duration: >-
                00:{{ states('input_number.input_number_bath_duration_min') |
                int(40) }}:00
            action: timer.start
          - if:
              - condition: template
                value_template: >-
                  {{ states('sensor.sonoff_10018d035a_temperature') | float(0)
                  >= states('input_number.input_number_bath_target_temp') |
                  float(40) }}
            then:
              - target:
                  entity_id: switch.sonoff_10018d035a
                action: switch.turn_off
                data: {}
              - action: notify.mobile_app_iphone
                metadata: {}
                data:
                  message: >-
                    加熱結束,水溫:{{ states('sensor.sonoff_10018d035a_temperature')
                    }}°C
                  title: 熱水器
          - action: notify.mobile_app_iphone
            metadata: {}
            data:
              message: 開始加熱,水溫:{{ states('sensor.sonoff_10018d035a_temperature') }}°C
              title: 熱水器
      - conditions:
          - condition: trigger
            id: temp_change
          - condition: state
            entity_id: timer.dao_ji_shi_jia_re
            state: active
          - condition: template
            value_template: |
              {{ states('sensor.sonoff_10018d035a_temperature') | float(0) >= 
                 states('input_number.input_number_bath_target_temp') | float(40) }}
        sequence:
          - target:
              entity_id: switch.sonoff_10018d035a
            action: switch.turn_off
            data: {}
          - target:
              entity_id: timer.dao_ji_shi_jia_re
            action: timer.finish
            data: {}
      - conditions:
          - condition: trigger
            id: timer_end
        sequence:
          - target:
              entity_id: switch.sonoff_10018d035a
            action: switch.turn_off
          - action: notify.mobile_app_iphone
            data:
              message: 加熱結束,水溫:{{ states('sensor.sonoff_10018d035a_temperature') }}°C
              title: 熱水器
      - conditions:
          - condition: trigger
            id: system_stop
        sequence:
          - target:
              entity_id: timer.dao_ji_shi_jia_re
            action: timer.finish

mode: restart



到自定義的卡片位置

新增一個垂直排列面板


使用文字編輯




type: vertical-stack

cards:

  - type: custom:bubble-card

    card_type: button

    button_type: switch

    entity: switch.sonoff_10018d035a

    icon: mdi:water-boiler

    force_icon: false

    show_state: true

  - type: horizontal-stack

    cards:

      - type: entities

        entities:

          - entity: timer.dao_ji_shi_jia_re

            name: 剩餘時間

        show_header_toggle: false

        state_color: true

  - type: custom:mini-graph-card

    entities:

      - sensor.sonoff_10018d035a_temperature

    align_icon: left

    align_state: center

    name: 熱水溫度

    show:

      fill: true

    hours_to_show: 2

    points_per_hour: 30

  - type: custom:bubble-card

    card_type: button

    button_type: slider

    entity: input_number.input_number_bath_target_temp

    name: 加熱溫度/˚C

    icon: mdi:thermometer

    force_icon: false

    show_state: true

    show_last_changed: false

    min_value: 30

    max_value: 60

    step: 1

    tap_to_slide: false

    slider_live_update: false

    styles: ""

    show_name: true

    show_icon: true

    scrolling_effect: true

  - square: false

    type: grid

    columns: 4

    cards:

      - show_name: true

        show_icon: false

        type: button

        name: 40˚C

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_target_temp

          data:

            value: 40

        icon_height: 20px

        show_state: false

      - show_name: true

        show_icon: false

        type: button

        name: 50˚C

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_target_temp

          data:

            value: 50

        icon_height: 20px

      - show_name: true

        show_icon: false

        type: button

        name: 55˚C

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_target_temp

          data:

            value: 55

        icon_height: 20px

      - show_name: true

        show_icon: false

        type: button

        name: 60˚C

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_target_temp

          data:

            value: 60

        icon_height: 20px

  - type: custom:bubble-card

    card_type: button

    button_type: slider

    entity: input_number.input_number_bath_duration_min

    name: 加熱時間/分

    icon: mdi:av-timer

    force_icon: false

    show_state: true

    show_last_changed: false

    min_value: 10

    max_value: 120

    step: 1

    tap_to_slide: false

    slider_live_update: false

    styles: |+


    show_name: true

    show_icon: true

    scrolling_effect: true

  - square: false

    type: grid

    columns: 4

    cards:

      - show_name: true

        show_icon: false

        type: button

        name: 30分

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_duration_min

          data:

            value: 30

        icon_height: 20px

        show_state: false

      - show_name: true

        show_icon: false

        type: button

        name: 60分

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_duration_min

          data:

            value: 60

        icon_height: 20px

      - show_name: true

        show_icon: false

        type: button

        name: 90分

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_duration_min

          data:

            value: 90

        icon_height: 20px

      - show_name: true

        show_icon: false

        type: button

        name: 120分

        icon: ""

        tap_action:

          action: call-service

          service: input_number.set_value

          target:

            entity_id: input_number.input_number_bath_duration_min

          data:

            value: 120

        icon_height: 20px

grid_options:

  columns: 12


  rows: auto




因為滑桿設定還是比較不好用,所以用了幾個實體按鍵,來作為快速設定

,只要自動化有開啟,按下熱水器開關,就會自動加熱到預設的溫度,

這裡的計時器用來倒數,就算沒加熱到預設溫度,一樣會停止。

如果達到溫度,也會停止。





15.從零開始裝 Home Assistant 接入Hitachi冷氣

16.從零開始裝 Home Assistant 接入onvif協議攝影機

17.從零開始裝 Home Assistant 熱水器自動化

沒有留言:

張貼留言