Humbug modes for Hive heating entities?

Thanks - I managed to get an HP 800 G4 with a G5500t cpu, 128Gb NVME and 8Gb ram for £70 and also got the Sonoff 3.0 zigbee-E version. For now I set up HA on a VM and connected the thermostat, receiver and TRV. I suspect TRVs will be a pain to setup, especially getting them to work in a predictable way, since I am reading they have their own PID controller implemented on-board, which can be both a good and a bad thing! More to come!

nice.

The '‘E’ is newer than the ‘P’ but not sure about the differences.

No worries done

@jchh

This looks great! I would like to set this up.
Can you share the code for your dash please?

Sure!

I’ve removed any links to the LH menu and top alarms as that’s another story.

Note that since I last posted, I’ve changed the top section for both heating and water to reflect the fact I realised I never needed the “off” or “Scheduled” buttons as I lever had a need to leave “scheduled” so now looks like this:

I think I mentioned before that you cannot switch schedule 2 or 6 on/off or set their time - this is because they are the default ‘day’ and ‘night’ temps and so must always be ‘on’ and the timing is set by input_select.house_mode. It’s easy enough to con age if you don’t want to do it this way, but just ask if you want help.

I’m using a bunch of decluttering templates (which uses custom: button) so you’ll need to install the following (HACS):

The code might look a little bonkers but info_button is used all over my dash and a single change to it will change the look of all my dashboards.

The Hive ‘system’ assumes the following template sensors exist which I can provide if needed):"

  • input_select.house_mode can be ['Awake','Asleep','Manual']
  • zone.home (most users have this)
  • sensor.time (most users have this)
  • contact sensors ending in door_contact, doors_contact, window_contact - check the package for binary_sensor.hive_heating_doors/windows open which uses these and has some ignored (eg: for me the front door and ensuite window).

Dashboard view

Heating/Water view
title: Hive heating
path: hive
icon: phu:hive
cards:

#-------------------------------------------------------------------------------
- type: vertical-stack
  title: Hive Status
  cards:
    - type: custom:decluttering-card
      template: climate-info

    - type: custom:decluttering-card
      template: climate-info-temperature
   
    - type: horizontal-stack
      cards:
      - type: custom:decluttering-card
        template: info_button
        variables:
          - entity: sensor.hive_heating_today
          - name: Heating today
          - show_icon: false
          - icon: mdi:radiator
          - action: navigate
          - navigation_path: hive_history
      - type: custom:decluttering-card
        template: info_button
        variables:
          - entity: sensor.hive_water_today
          - name: Water today
          - show_icon: false
          - icon: mdi:radiator
      - type: custom:decluttering-card
        template: info_button
        variables:
          - entity: switch.study_smartplug
          - name: Study radiator
          - show_icon: false
          - on_colour: var(--state-climate-heat-color)
          - off_colour: grey
          - action: toggle

    - type: history-graph
      show_names: false
      entities:
        - entity: climate.hive_heat


#-------------------------------------------------------------------------------
- type: vertical-stack
  title: Heating
  cards:

    - type: custom:decluttering-card
      template: climate-influence_boost
      variables:
        - item: heating
        - name: "[[[ return '➜ '+ states['sensor.hive_heating_target_temp'].state +'℃' ]]]"
        - icon: "[[[ return states['sensor.hive_heating_target_temp'].attributes.icon ]]]"
        - label: "[[[ return 'set by: ' + states['sensor.hive_heating_target_temp'].attributes.influence ]]]"

    # influence
    - type: conditional
      conditions:
        - entity: binary_sensor.hive_heating_doors_windows_open
          state_not: 'off'
      card:
        type: markdown
        content: >
          <h3>Dr/win open:</h3>
          {{ state_attr('binary_sensor.hive_heating_doors_windows_open','influence') }}

    # schedule
    - type: custom:text-divider-row
      text: "Schedule & Settings"

    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 1
        - scheduled_colour: Brown

    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 2
        - action: none                # day default - must not be toggled off

    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 3
    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 4
    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 5
    - type: custom:decluttering-card
      template: climate-schedule_heating
      variables:
        - schedule: 6
        - scheduled_colour: Brown
        - action: none                # night default - must not be toggled off


    # defaults
    - type: custom:expander-card
      title: Default settings
      title-card-button-overlay: true
      padding: 0em
      gap: 0em
      cards:
        - type: entities
          entities:
            - type: custom:numberbox-card
              entity: input_number.hive_heating_away_temp
              name: Away
            - type: custom:numberbox-card
              entity: input_number.hive_heating_open_temp
              name: Win/Drs
            - type: divider
            - type: custom:numberbox-card
              entity: input_number.hive_heating_boost_temp
            - type: custom:numberbox-card
              entity: input_number.hive_heating_boost_time
        - type: custom:decluttering-card
          template: internals_automation
          variables:
            - automation: 'hive_heating_*'


#-------------------------------------------------------------------------------
- type: vertical-stack
  title: Hot water
  cards:

    - type: custom:decluttering-card
      template: climate-influence_boost
      variables:
        - item: heating
        - name: "[[[ return '➜ '+ states['sensor.hive_water_target_mode'].state ]]]"
        - icon: "[[[ return states['sensor.hive_water_target_mode'].attributes.icon ]]]"
        - label: "[[[ return 'set by: ' + states['sensor.hive_water_target_mode'].attributes.influence ]]]"
        - color: var(--state-active-color)

    # schedule
    - type: custom:text-divider-row
      text: "Schedule & Settings"
    - type: custom:decluttering-card
      template: climate-schedule_water
      variables:
        - schedule: 1
    - type: custom:decluttering-card
      template: climate-schedule_water
      variables:
        - schedule: 2
    - type: custom:decluttering-card
      template: climate-schedule_water
      variables:
        - schedule: 3
    - type: custom:decluttering-card
      template: climate-schedule_water
      variables:
        - schedule: 4

    # defaults
    - type: custom:expander-card
      title: Default settings
      title-card-button-overlay: true
      padding: 0em
      gap: 0em
      cards:
        - type: custom:numberbox-card
          entity: input_number.hive_water_boost_time

Decluttering cards

Note: I use these everywhere so may have functionality not used by the Hive view"

info_button
default:
  - show_name: true
  - name:
  - show_state: true
  - show_icon: true
  # note attribute take precedence over label
  - label: ''
  - attribute: false
  - icon:
  - colour: gre
  - show_border: true
  # on / off
  - on_value: 'on'
  - on_operator: '=='
  - on_colour: var(--state-active-color)
  - on_icon:
  - on_name:
  - on_label: # for attribute ilo state
  - on_box_shadow: false
  - off_value: 'off'
  - off_operator: '=='
  - off_icon:
  - off_label:
  - off_name:
  - off_colour: var(--state-inactive-color)
  - off_box_shadow: false
  # values: note box_shadow_[1,2,3] uses on_box_shadow
  - value_1:
  - value_2:
  - value_3:
  - operator_1: '=='
  - operator_2: '=='
  - operator_3: '=='
  - icon_1:
  - icon_2:
  - icon_3:
  - label_1:
  - label_2:
  - label_3:
  - action: none
  - hold_action: none
  - condition_entity: input_boolean.dummy
  - condition_state: "on"
card:
  type: conditional
  conditions:
    - condition: state
      entity: '[[condition_entity]]'
      state: '[[condition_state]]'
  card:
    type: custom:button-card
    entity: "[[entity]]"
    show_name: '[[show_name]]'
    name: '[[name]]'
    show_icon: '[[show_icon]]'
    show_state: '[[show_state]]'
    show_label: "[[[ if ( [[label]] != '' || [[attribute]] != false ) return 'true'; else return 'false'; ]]]"
    label: '[[label]]'
    icon: '[[icon]]'
    size: 30px
    color: auto
    color_type: icon
    styles:
      card:
        - font-size: 15px
        - border: "[[[ if ( '[[show_border]]' == 'false' ) return 'solid 0px'; ]]]"
      icon:
        - color: '[[colour]]'
      state:
        - color: '[[colour]]'
      label:
        - color: '[[colour]]'
    state:
      - value: '[[on_value]]'
        operator: '[[on_operator]]'
        icon: '[[on_icon]]'
        name: '[[on_name]]'
        label: '[[on_label]]'
        styles:
          card:
            - box-shadow: "[[[ if ( '[[on_box_shadow]]' == 'true' ) return '0px 0px 9px 3px [[on_colour]]'; ]]]"
          state:
            - color: '[[on_colour]]'
          icon:
            - color: '[[on_colour]]'
          label:
            - color: '[[on_colour]]'
      - value: '[[off_value]]'
        operator: '[[off_operator]]'
        icon: '[[off_icon]]'
        name: '[[off_name]]'
        label: '[[off_label]]'
        styles:
          card:
            - box-shadow: "[[[ if ( '[[off_box_shadow]]' == 'true' ) return '0px 0px 9px 3px [[off_colour]]'; ]]]"
          state:
            - color: '[[off_colour]]'
          icon:
            - color: '[[off_colour]]'
          label:
            - color: '[[off_colour]]'
  
      - value: '[[value_1]]'
        operator: '[[operator_1]]'
        icon: '[[icon_1]]'
        label: '[[label_1]]'
        styles:
          card:
            - box-shadow: "[[[ if ( '[[on_box_shadow]]' == 'true' ) return '0px 0px 9px 3px [[on_colour]]'; ]]]"
          state:
            - color: '[[colour_1]]'
          icon:
            - color: '[[colour_1]]'
          label:
            - color: '[[colour_1]]'
      - value: '[[value_2]]'
        operator: '[[operator_2]]'
        icon: '[[icon_2]]'
        label: '[[label_2]]'
        styles:
          card:
            - box-shadow: "[[[ if ( '[[on_box_shadow]]' == 'true' ) return '0px 0px 9px 3px [[on_colour]]'; ]]]"
          state:
            - color: '[[colour_2]]'
          icon:
            - color: '[[colour_2]]'
          label:
            - color: '[[colour_2]]'
      - value: '[[value_3]]'
        operator: '[[operator_3]]'
        icon: '[[icon_3]]'
        label: '[[label_3]]'
        styles:
          card:
            - box-shadow: "[[[ if ( '[[on_box_shadow]]' == 'true' ) return '0px 0px 9px 3px [[on_colour]]'; ]]]"
          state:
            - color: '[[colour_3]]'
          icon:
            - color: '[[colour_3]]'
          label:
            - color: '[[colour_3]]'
      - value: "[[[ return entity.state == 'unknown' || entity.state == 'unavailable' || entity.state == 'offline' ]]]"
        operator: 'template'
        styles:
          state:
            - color: var(--error-color)
          icon:
            - color: var(--error-color)
          label:
            - color: var(--error-color)
    tap_action:
      action: "[[action]]"
      navigation_path: "[[navigation_path]]"
      url_path: "[[url_path]]"
      service: '[[service]]'
      data:
        entity_id: '[[entity]]'
    hold_action:
      action: "[[hold_action]]"
climate-influence_boost
default:
  - item: heating
card:

  type: custom:layout-card
  layout_type: custom:grid-layout
  layout:
    grid-template-columns: 3fr 1fr
    grid-template-rows: auto
    grid-template-areas: '"infl boost"'
  cards:

    - type: custom:button-card
      view_layout:
        grid-area: infl
      entity: "sensor.hive_[[item]]_target_temp"
      size: 30px
      name: '[[name]]'
      icon: '[[icon]]'
      show_icon: true
      show_state: false
      show_label: true
      label: '[[label]]'
      layout: icon_name_state2nd
    
      styles:
        card:
          - height: 60px
          - font-size: 15px
        name:
          - color: var(--state-active-color)
          - justify-self: start
        label:
          - justify-self: start
        icon:
          - color: var(--state-active-color)
      tap_action:
        action: none

    - type: custom:button-card
      view_layout:
        grid-area: boost
      entity: timer.hive_[[item]]_boost
      name: >
        [[[
          if ( states['timer.hive_[[item]]_boost'].state == 'active' ) return 'Cancel Boost'
          else return 'Boost'
        ]]]
      icon: mdi:plus
      size: 30px
      color_type: icon
      color: auto
      show_state: false
      styles:
        card:
          - height: 60px
          - font-size: 15px
        icon:
          - color: var(--state-inactive-color)
      state:
        - value: "active"
          styles:
            icon:
              - color: var(--state-active-color)
            state:
              - color: var(--state-active-color)
      tap_action:
        action: none
      hold_action:
        action: call-service
        service: script.hive_[[item]]_toggle_boost
climate-schedule_heating
default:
  - action: toggle
  - scheduled_colour: SkyBlue
card:

  type: custom:expander-card
  title-card:
    type: custom:button-card
    entity: 'input_boolean.hive_heating_[[schedule]]_scheduled'
    size: 30px
    card_size: 1
    show_name: true
    name: |
      [[[
        if ( '[[schedule]]' == '2' ) return 'Awake';
        if ( '[[schedule]]' == '6' ) return 'Asleep';
        else return states['input_datetime.hive_heating_[[schedule]]'].state.slice(0,-3);
      ]]]
    show_icon: true
    icon: mdi:calendar-remove
    show_state: false
    show_label: true
    label: "[[[ if ( states['input_boolean.hive_heating_[[schedule]]_scheduled'].state === 'on' ) return '➜ ' + states['input_number.hive_heating_[[schedule]]_temp'].state + ' ℃'; ]]]"
    layout: icon_name

    styles:
      card:
        - height: 50px
        - padding: 5px
        - font-size: 15px
      grid:
        - grid-template-areas: '"i n l"'
        - grid-template-rows: 40px
        - grid-template-columns: 20% 20% 60%
      name:
        - color: var(--state-inactive-color)
        - justify-self: start
      label:
        - color: var(--state-inactive-color)
        - justify-self: start
      icon:
        - color: var(--state-inactive-color)

    state:
      # heating
      - operator: template
        value: "[[[ return states['sensor.hive_heating_target_temp'].attributes.influence.slice(-1) == [[schedule]] ]]]"
        icon: mdi:radiator
        styles:
          card:
            - box-shadow: 0px 0px 9px 3px var(--state-active-color)
          name:
            - color: var(--state-active-color)
          icon:
            - color: var(--state-active-color)
          label:
            - color: var(--state-active-color)
      # scheduled
      - value: "on"
        icon: mdi:calendar-check-outline
        styles:
          name:
            - color: '[[scheduled_colour]]'
          icon:
            - color: '[[scheduled_colour]]'
          label:
            - color: '[[scheduled_colour]]'
    tap_action:
      action: none
    hold_action:
      action: '[[action]]'
    # end of title card --------------------------------------------------------
  title-card-button-overlay: true
  padding: 0em
  gap: 0em
  cards:
    - type: custom:vertical-stack-in-card
      cards:
        - type: conditional # dont show 'on' if [[schedule]] is 2 or 6
          conditions:
            - entity: input_datetime.hive_heating_[[schedule]]
              state_not: 'unavailable'
          card:
            type: custom:time-picker-card
            entity: input_datetime.hive_heating_[[schedule]]
            name: Time
            link_values: true
            layout:
              align_controls: right
              name: inside
              thin: true
            tap_action:
              action: none
        - type: custom:numberbox-card
          entity: input_number.hive_heating_[[schedule]]_temp
          name: Temp
climate-schedule_water
card:
  type: custom:expander-card
  title-card: #-----------------------------------------------------------------
    type: custom:button-card
    entity: 'input_boolean.hive_water_[[schedule]]_scheduled'
    size: 30px
    card_size: 1
    show_name: true
    name: "[[[ return states['input_datetime.hive_water_[[schedule]]_on'].state.slice(0,-3) ]]]"
    show_icon: true
    icon: mdi:calendar-remove
    show_state: false
    show_label: true
    label: "[[[ if ( states['input_boolean.hive_water_[[schedule]]_scheduled'].state === 'on' ) return 'for ' + states['input_number.hive_water_[[schedule]]_time'].state + ' Hr(s)'; ]]]"
    layout: icon_name

    styles:
      card:
        - height: 50px
        - padding: 5px
        - font-size: 15px
      grid:
        - grid-template-areas: '"i n l"'
        - grid-template-rows: 40px
        - grid-template-columns: 20% 20% 60%
      name:
        - color: var(--state-inactive-color)
        - justify-self: start
      label:
        - color: var(--state-inactive-color)
        - justify-self: start
      icon:
        - color: var(--state-inactive-color)

    state:
      # On
      - operator: template
        value: "[[[ return states['sensor.hive_water_target_mode'].attributes.influence.slice(-1) == [[schedule]] ]]]"
        icon: mdi:water-pump
        styles:
          card:
            - box-shadow: 0px 0px 9px 3px var(--state-active-color)
          name:
            - color: var(--state-active-color)
          icon:
            - color: var(--state-active-color)
          label:
            - color: var(--primary-text-color)
      # scheduled
      - value: "on"
        icon: mdi:calendar-check-outline
        styles:
          name:
            - color: var(--primary-text-color)
          icon:
            - color: var(--primary-text-color)
          label:
            - color: var(--primary-text-color)
    tap_action:
      action: none
    hold_action:
      action: toggle
    # end of title card --------------------------------------------------------
  title-card-button-overlay: true
  padding: 0em
  gap: 0em
  cards:
    - type: custom:vertical-stack-in-card
      cards:
        - type: custom:time-picker-card
          entity: input_datetime.hive_water_[[schedule]]_on
          name: Time
          link_values: true
          layout:
            align_controls: right
            name: inside
            thin: true
          tap_action:
            action: none
        - type: custom:numberbox-card
          entity: input_number.hive_water_[[schedule]]_time
          name: Duration
climate-info-temperature
card:
  type: custom:vertical-stack-in-card
  horizontal: true
  cards:
    - type: custom:decluttering-card
      template: info_button
      variables:
        - entity: sensor.coldest_temp
        - name: Coldest
        - icon: mdi:thermometer-low
        - colour: LightBlue
        - action: navigate
        - navigation_path: weather_temp
    - type: custom:decluttering-card
      template: info_button
      variables:
        - entity: sensor.coldest_heated_temp
        - name: heated
        - icon: mdi:thermometer
        - colour: LightBlue
        - action: navigate
        - navigation_path: weather_temp
    - type: custom:decluttering-card
      template: info_button
      variables:
        - entity: sensor.hottest_temp
        - name: Hottest
        - icon: mdi:thermometer-high
        - colour: pink
        - action: navigate
        - navigation_path: weather_temp
climate-info
default:
  - action: none
card:
  type: vertical-stack
  cards:
  - type: custom:vertical-stack-in-card
    horizontal: true
    cards:
    - type: custom:layout-card
      layout_type: custom:grid-layout
      layout:
        grid-template-columns: auto
        grid-template-rows: auto
        grid-template-areas: '"down hive up"'
      cards:
    
      # down ---------------------------------------
      - type: conditional
        conditions:
          - entity: sensor.hive_heating_reported_mode
            state_not: "off"
        card:
          type: custom:button-card
          view_layout:
            grid-area: down
          entity: sensor.hive_heating_reported_target_temp
          size: 30px
          show_name: true
          name: Set target
          show_state: false
          show_label: true
          label: "[[[ return (entity.state -0.5) + '℃' ]]]"
          icon: mdi:thermometer-minus
          styles:
            card:
              - font-size: 15px
              - color: grey
            icon:
              - color: LightBlue
          tap_action:
            action: call-service
            service: script.turn_on
            service_data:
              entity_id: script.hive_heating_decrease_setpoint

      # hive ---------------------------------------
      - type: custom:button-card
        view_layout:
          grid-area: hive
        entity: binary_sensor.hive_heating_reported_action
        size: 30px
        show_name: false
        name: "Actual"
        show_state: false
        show_icon: true
        icon: "[[[ if ( states['binary_sensor.hive_heating_reported_action'].state == 'off') return 'mdi:radiator-disabled'; else return 'mdi:radiator'; ]]]"
        show_label: false
        label: >
          [[[
            if ( states['sensor.hive_heating_reported_mode'].state == 'off' ) return '(off)';
            if ( states['timer.hive_heating_boost'].state == 'active' ) return states['sensor.hive_heating_reported_target_temp'].state +'<font color="grey"> (Boost)</font>';
            else return '<font color="grey"> (' + states['binary_sensor.hive_heating_reported_action'].state+')</font>';
          ]]]
        custom_fields:
          ts: "[[[ if ( states['sensor.hive_heating_reported_mode'].state == 'off' ) return 'off'; else return states['sensor.hive_heating_reported_target_temp'].state  + '℃' ]]]"
          tn: "Target"
          cs: "[[[ return states['sensor.hive_heating_reported_current_temp'].state  + '℃' ]]]"
          cn: "Actual"
        styles:
          grid:
            - grid-template-areas: |
                "i  i"
                "s  s"
                "tn cn"
                "ts cs"
            - grid-template-columns: auto
          card:
            - font-size: 15px
            - border: 0px solid
          icon:
            - color: >
                [[[
                  if ( states['sensor.hive_heating_reported_mode'].state == 'off' ) return 'grey';
                  else if ( states['binary_sensor.hive_heating_reported_action'].state == 'off' ) return 'LightBlue';
                  else return 'var(--state-climate-heat-color)';
                ]]]
          state:
            - color: "[[[ if ( states['sensor.hive_heating_reported_mode'].state == 'off' ) return 'grey'; else return 'orange'; ]]]"
          custom_fields:
            tn:
              - color: grey
            cn:
              - color: grey
            ts:
              - color: "[[[ if ( states['sensor.hive_heating_reported_mode'].state == 'off' ) return 'grey'; ]]]"
            cs:
              - color: >
                  [[[
                    if ( states['sensor.hive_heating_reported_current_temp'].state < states['sensor.hive_heating_reported_target_temp'].state ) return 'LightBlue';
                    else if ( states['sensor.hive_heating_reported_current_temp'].state > states['sensor.hive_heating_reported_target_temp'].state ) return 'orange';
                  ]]]
        tap_action:
          action: more-info

      # up ---------------------------------------
      - type: conditional
        conditions:
          - entity: sensor.hive_heating_reported_mode
            state_not: "off"
        card:
          type: custom:button-card
          view_layout:
            grid-area: up
          entity: sensor.hive_heating_reported_target_temp
          size: 30px
          show_name: true
          name: Set target
          show_state: false
          show_label: true
          label: "[[[ return (+entity.state +0.5) + '℃' ]]]"
          icon: mdi:thermometer-plus
          styles:
            card:
              - font-size: 15px
              - color: grey
            icon:
              - color: orange
          tap_action:
            action: call-service
            service: script.turn_on
            service_data:
              entity_id: script.hive_heating_increase_setpoint
internals_automation
default:
  - title: ''
  - slice: 0

card:
  type: custom:auto-entities
  show_empty: false
  card:
    type: entities
    title: '[[title]]'
    show_header_toggle: false
  sort:
    method: name
  filter:
    include:
      - entity_id: 'automation.[[automation]]'
        options:
          type: custom:button-card
          entity: this.entity_id
          show_state: true
          name: "[[[ return entity.attributes.friendly_name.slice([[slice]]) ]]]"
          styles:
            grid:
              - grid-template-areas: '". n s"'
              - grid-template-columns: 1em 1fr 2em
            card:
              - height: 40px
              - padding: 0
            name:
              - justify-self: start
              - font-size: 14px
              - color: "[[[ if (entity.state == 'off') return 'grey'; else return 'lightgrey'; ]]]"
            state:
              - color: "[[[ if (entity.state == 'off') return 'brown'; else return 'green'; ]]]"
              - font-weight: bold
          tap_action:
            action: toggle
          hold_action:
            action: more-info

OK, this has taken a little time to write/edit so I apologise if there are any typos. Just ask if something doesn’t work. Please test it to ensure it works for you.

I’ll repost the packages shortly (the forum would not let me put it all on one post.

[Edited for clarity and typos]

1 Like

Packages

  • The SLR2C is named hive which produces climate.hive_heat and climate.hive_water
  • The SLT3C is names hive_thermostat
  • The notes to change so a single channel (heating only) version is at the top of the heating package (below), but ask if you want to explicitly pst that version.
Heating package
# for SLR1c:
  # climate.hive
  # zigbee2mqtt/<receiver-name>/set

# for SLR2c:
  # climate.hive_heat
  # zigbee2mqtt/<receiver-name>/heat/set


input_boolean: #----------------------------------------------------------------

  hive_heating_1_scheduled:
    name: Schedule 1

  # default day (don't toggle off)
  hive_heating_2_scheduled:
    name: Schedule 2
    initial: true

  hive_heating_3_scheduled:
    name: Schedule 3

  hive_heating_4_scheduled:
    name: Schedule 4

  hive_heating_5_scheduled:
    name: Schedule 5

  # default night (don't toggle off)
  hive_heating_6_scheduled:
    name: Schedule 6
    initial: true


input_datetime: #---------------------------------------------------------------

  hive_heating_1:
    name: Schedule 1
    icon: mdi:clock-start
    has_date: false
    has_time: true

  # hive_heating_2 starts when input_select.house_mode ➜ "Awake"

  hive_heating_3:
    name: Schedule 3
    icon: mdi:clock-start
    has_date: false
    has_time: true

  hive_heating_4:
    name: Schedule 4
    icon: mdi:clock-start
    has_date: false
    has_time: true

  hive_heating_5: # pre-wake-up temp
    name: Schedule 5
    icon: mdi:clock-start
    has_date: false
    has_time: true

  # hive_heating_6 starts when input_select.house_mode ➜ "Asleep"


input_number: #-----------------------------------------------------------------

  hive_heating_open_temp:
    name: "Windows open"
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:power-off

  hive_heating_away_temp:
    name: "Away temp"
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:power-off

  # "pre-heat" before house_mode: 'Awake'
  hive_heating_1_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  # default house_mode: 'Awake'
  hive_heating_2_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  hive_heating_3_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  hive_heating_4_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  hive_heating_5_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  # default house_modse: 'Asleep'
  hive_heating_6_temp:
    unit_of_measurement: °C
    min: 12
    max: 22
    step: 0.5
    icon: mdi:thermometer

  hive_heating_boost_prior_temp:
    name: "Previous temp"
    min: 10
    max: 25 # set high to ensure morning towel boost works even when already hot inside
    step: 1
    initial: 19
    unit_of_measurement: °C
    icon: mdi:thermometer
    mode: box
  
  hive_heating_boost_temp:
    name: "Boost by"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 1.0
    unit_of_measurement: °C
    icon: mdi:plus
    mode: slider

  hive_heating_boost_time:
    name: "Boost for"
    min: 0.5
    max: 4
    step: 0.5
    #initial: 2
    unit_of_measurement: Hrs
    icon: mdi:plus
    mode: slider


input_select: #-----------------------------------------------------------------

  # not sure I need this - keep in 'heat' and just chnage the temp setting
  hive_heating_target_mode:
    name: Hive heating mode
    icon: mdi:radiator-disabled
    options:
      - "off"                 # Hive thermostat is in frost protect
      - "heat"                # Hive thermostat is manual/HA controlled
      #- "emergency_heating"   # Hive thermostat is Hive app boosting
      #- "auto"                # Hive thermostat is Hive app controlled


sensor: #-----------------------------------------------------------------------

  - platform: history_stats
    name: Hive heating today
    entity_id: binary_sensor.hive_heating_reported_action
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"


template: #---------------------------------------------------------------------

  - binary_sensor:

      # Action as reported by HIVE | 'hive' (SLR1c) & 'hive_heat' (SLR2c)
      - name: "Hive heating reported action"
        unique_id: hive_heating_reported_action
        state: "{{ is_state_attr('climate.hive_heat','hvac_action', 'heating') }}"
        
      # doors and windows that are heating relevant
      - name: "Hive heating doors/windows open"
        state: >
          {% set ignore_seconds = 60 %}
          {% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
          {{
            states.binary_sensor
            | selectattr('entity_id', 'search', '(doors?|window)_contact')
            | rejectattr('entity_id', 'search', 'bedroom_[w,1]|ensuite')
            | selectattr('state', 'match', 'on')
            | rejectattr('last_changed', 'gt', ignore_ts)
            | list
            | count
          }}
        attributes:
          influence: >
            {% set ignore_seconds = 60 %}
            {% set ignore_ts = (now().timestamp() - ignore_seconds)|as_datetime %}
            {{
              states.binary_sensor
              | selectattr('entity_id', 'search', 'c_contact')
              | selectattr('state', 'match', 'on')
              | rejectattr('entity_id', 'search', 'bedroom_[w,1]|ensuite')
              | rejectattr('last_changed', 'gt', ignore_ts)
              | sort(attribute='name')
              | map(attribute='name')
              | list
              | join(',\n')
              | replace(' contact', '')
            }}

  - sensor:

      # Mode as reported by HIVE thermostat: off, heat, auto (Hive schedule), emergency_heating (Hive boost)
      - name: "Hive heating reported mode"
        unique_id: hive_heating_reported_mode
        state: "{{ states('climate.hive_heat') }}"

      # Current temp as reported by HIVE thermostat
      - name: "Hive heating reported current temp"
        unique_id: hive_heating_reported_current_temp
        device_class: temperature
        unit_of_measurement: °C
        state: "{{ state_attr('climate.hive_heat','current_temperature') }}"
        state_class: measurement

      # Target temp as reported by HIVE thermostat
      - name: "Hive heating reported target temp"
        unique_id: hive_heating_reported_target_temp
        device_class: temperature
        unit_of_measurement: °C
        state: "{{ state_attr('climate.hive_heat','temperature') }}"
        state_class: measurement

      # Hive automation sets temp to this sensor
      - name: "Hive heating target temp"
        unique_id: hive_heating_target_temp
        device_class: temperature
        unit_of_measurement: °C
        availability: "{{ has_value('binary_sensor.hive_heating_doors_windows_open') }}"
        attributes:
        # influence shows (on dashboard) what is setting the temp
          influence: >
            {% set sched1 = states('input_boolean.hive_heating_1_scheduled') %}
            {% set sched2 = states('input_boolean.hive_heating_2_scheduled') %}
            {% set sched3 = states('input_boolean.hive_heating_3_scheduled') %}
            {% set sched4 = states('input_boolean.hive_heating_4_scheduled') %}
            {% set sched5 = states('input_boolean.hive_heating_5_scheduled') %}
            {% set sched6 = states('input_boolean.hive_heating_6_scheduled') %}
      
            {% set on1  = states('input_datetime.hive_heating_1')[:5] %}
            {% set on3  = states('input_datetime.hive_heating_3')[:5] %}
            {% set on4  = states('input_datetime.hive_heating_4')[:5] %}
            {% set on5  = states('input_datetime.hive_heating_5')[:5] %}
      
            {% set mode =     states('input_select.hive_heating_target_mode') %}
            {% set boost =    states('timer.hive_heating_boost') %}
            {% set bathroom = states('timer.hive_heating_boost_bathroom') %}
            {% set dr_win =   states('binary_sensor.hive_heating_doors_windows_open') %}
            {% set home =     states('zone.home') %}
            {% set time =     states('sensor.time') %}
            {% set house =    states('input_select.house_mode') %}
          
            {%   if mode        == 'heat' %}
              {%   if boost     == 'active' %}                        Boost
              {% elif bathroom  == 'active' %}                        Bathroom
              {% elif dr_win    == 'on' %}                            Dr/Win
              {% elif home      != '0' %}
      
                {%   if house   == 'Awake' %}
                  {%   if sched5 == 'on' and (time >= on5 or time < on1) %} Schedule 5
                  {% elif sched4 == 'on' and (time >= on4 or time < on1) %} Schedule 4
                  {% elif sched3 == 'on' and (time >= on3 or time < on1) %} Schedule 3
                  {% else %}                                                Schedule 2
                  {% endif %}
                {% elif sched1 == 'on' and ('12:00' > time >= on1) %}       Schedule 1
                {% else %}                                                  Schedule 6
                {% endif %}
      
              {% else %}                                              Away
              {% endif %}
            {% else %}                                                Off
            {% endif %}
        state: >
          {% set influence =  state_attr('sensor.hive_heating_target_temp','influence') %}
      
          {% set temp1  =     states('input_number.hive_heating_1_temp')|float %}
          {% set temp2 =      states('input_number.hive_heating_2_temp')|float %}
          {% set temp3 =      states('input_number.hive_heating_3_temp')|float %}
          {% set temp4 =      states('input_number.hive_heating_4_temp')|float %}
          {% set temp5 =      states('input_number.hive_heating_5_temp')|float %}
          {% set temp6 =      states('input_number.hive_heating_6_temp')|float %}
          {% set open =       states('input_number.hive_heating_open_temp')|float  %}
          {% set away =       states('input_number.hive_heating_away_temp')|float  %}
          {% set boostpre =   states('input_number.hive_heating_boost_prior_temp')|float %}
          {% set boostby =    states('input_number.hive_heating_boost_temp')|float %}
        
          {%   if influence == 'Boost' %}       {{ boostpre + boostby }}
          {% elif influence == 'Bathroom' %}    {{ boostpre + 0.5 }}
          {% elif influence == 'Dr/Win' %}      {{ open }}
          {% elif influence == 'Schedule 1' %}  {{ temp1 }}
          {% elif influence == 'Schedule 2' %}  {{ temp2 }}
          {% elif influence == 'Schedule 3' %}  {{ temp3 }}
          {% elif influence == 'Schedule 4' %}  {{ temp4 }}
          {% elif influence == 'Schedule 5' %}  {{ temp5 }}
          {% elif influence == 'Schedule 6' %}  {{ temp6 }}
          {% elif influence == 'Away' %}        {{ away }}
          {% elif influence == 'Off' %}         12
          {% else %}                            15
          {% endif %}
        state_class: measurement
        icon: >
          {% set influence = state_attr('sensor.hive_heating_target_temp','influence') %}
          
          {%   if influence == 'Boost' %}       mdi:timer
          {% elif influence == 'Bathroom' %}    mdi:shower
          {% elif influence == 'Dr/Win' %}      mdi:door-open
          {% elif influence == 'Schedule 1' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 2' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 3' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 4' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 5' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 6' %}  mdi:calendar-check-outline
          {% elif influence == 'Away' %}        mdi:car
          {% elif influence == 'Off' %}         mdi:power-off
          {% else %}                            mdi:help
          {% endif %}



timer: #------------------------------------------------------------------------

# Boosts when timer is 'active' - by 'boost_temp' for boost_time [hrs]
  hive_heating_boost:
    name: Hive heating boost timer
    icon: mdi:radiator
    restore: true

# Boosts when timer is 'active' - by 0.5℃ for 30 mins
  hive_heating_boost_bathroom:  # not in use but still part of sensor.hive_heating_target_temp
    name: Hive heating bathroom timer
    duration: "00:30:00"
    icon: mdi:shower
    restore: true
    

script:  #----------------------------------------------------------------------

  hive_heating_increase_setpoint:
    alias: "Hive heating: Increase setpoint"
    sequence:
      - action: climate.set_temperature
        data:
          temperature: "{{ states('sensor.hive_heating_reported_target_temp') |float() +0.5 }}"
          entity_id: climate.hive_heat
    icon: mdi:thermometer-plus
    mode: queued

  hive_heating_decrease_setpoint:
    alias: "Hive heating: Increase setpoint"
    sequence:
      - action: climate.set_temperature
        data:
          temperature: "{{ states('sensor.hive_heating_reported_target_temp') |float() -0.5 }}"
          entity_id: climate.hive_heat
    icon: mdi:thermometer-minus
    mode: queued

# only needed as I'm not sure how to set timer duration within custom:button.  also called my mum's morning rad boost
  hive_heating_toggle_boost:
    alias: "Hive heating: Toggle boost"
    sequence:
      - if:
          - condition: state
            entity_id: timer.hive_heating_boost
            state: 'active'
        then:
          - action: timer.finish
            target:
              entity_id: timer.hive_heating_boost
        else:
          # check it is not too hot already - keeping max under 25
          - if: "{{ states('sensor.hive_heating_reported_current_temp')|float(21) + states('input_number.hive_heating_boost_temp')|float(1) < 25 }}"
            then:
              # record prior target temp to allow sensor.hive_heating_target_temp to set correct boost temp
              - action: input_number.set_value
                target:
                  entity_id: input_number.hive_heating_boost_prior_temp
                data:
                  value: "{{ states('sensor.hive_heating_reported_current_temp') |float(15) }}"
              - action: timer.start
                target:
                  entity_id: timer.hive_heating_boost
                data:
                  duration:  "{{ (states('input_number.hive_heating_boost_time') |float(30)) *3600 }}"
            else:
              - action: persistent_notification.create
                data:
                  message: "Boosting will take the themostat above 25℃"
                  title: "Boost cancelled"
    icon: mdi:radiator
    mode: single


automation:  #------------------------------------------------------------------

  # set mode and temp
  - alias: Hive heating control
    id: "hive_heating"
    description: ''
    mode: queued
    initial_state: true
    trigger:
      # reset mode if out-of-sync
      - platform: template
        value_template: "{{ states('sensor.hive_heating_reported_mode') != states('input_select.hive_heating_target_mode') }}"
      # set mode
      - platform: state
        entity_id: input_select.hive_heating_target_mode
      # set correct mode on startup
      - platform: homeassistant
        event: start
      # set temp
      - platform: state
        entity_id: sensor.hive_heating_target_temp
    action:
      - choose:
          - conditions:
              - condition: state
                entity_id: input_select.hive_heating_target_mode
                state: 'off'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/heat/set
                  payload: |-
                    {
                      "system_mode":"off",
                      "temperature_setpoint_hold":"0"
                    }
          - conditions:
              - condition: state
                entity_id: input_select.hive_heating_target_mode
                state: 'heat'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/heat/set
                  payload: |- # 'payload' or 'payload_template' ?
                    {
                      "system_mode":"heat",
                      "temperature_setpoint_hold":"1",
                      "occupied_heating_setpoint":{{ states('sensor.hive_heating_target_temp') }}
                    }
          # 'auto' hashed out for input_select.hive_heating_target_mode
          - conditions:
              - condition: state
                entity_id: input_select.hive_heating_target_mode
                state: 'auto'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/heat/set
                  payload: |-
                    {
                      "system_mode":"auto",
                      "temperature_setpoint_hold":"1"
                    }
          # 'emergency_heating' hashed out for input_select.hive_heating_target_mode
          - conditions:
              - condition: state
                entity_id: input_select.hive_heating_target_mode
                state: 'emergency_heating'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/heat/set
                  payload: |-
                    {
                      "system_mode":"emergency_heating",
                      "temperature_setpoint_hold":"1",
                      "temperature_setpoint_hold_duration":"{{ states('input_number.hive_heating_boost_time')|float *60 }}",
                      "occupied_heating_setpoint":"{{ states('sensor.hive_heating_reported_current_temp')|float + states('input_number.hive_heating_boost_temp')|float }}"
                    }

  - alias: Hive heating wakeup boost
    id: hive_heating_wakeup_boost
    description: ''
    mode: single
    triggers:
      - trigger: state
        entity_id: input_select.house_mode
        to: "Awake"
    conditions:
      - "{{ states('sensor.weather_temp_max')|int <= 15 }}"
      - "{{ states('zone.home') == '0' }}"
    actions:
      - action: script.hive_heating_toggle_boost
Water package
input_boolean: #----------------------------------------------------------------

  hive_water_1_scheduled:

  hive_water_2_scheduled:

  hive_water_3_scheduled:

  hive_water_4_scheduled:


input_datetime:  #--------------------------------------------------------------

  hive_water_1_on:
    name: water (1) on
    icon: mdi:water-pump
    has_date: false
    has_time: true

  hive_water_2_on:
    name: water (2) on
    icon: mdi:water-pump
    has_date: false
    has_time: true

  hive_water_3_on:
    name: water (3) on
    icon: mdi:water-pump
    has_date: false
    has_time: true

  hive_water_4_on:
    name: water (4) on
    icon: mdi:water-pump
    has_date: false
    has_time: true


input_number:  #----------------------------------------------------------------

  hive_water_1_time:
    name: "Water 1 on for"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 0.5
    unit_of_measurement: Hrs
    icon: mdi:timer
    mode: slider

  hive_water_2_time:
    name: "Water 2 on for"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 0.5
    unit_of_measurement: Hrs
    icon: mdi:timer
    mode: slider

  hive_water_3_time:
    name: "Water 3 on for"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 0.5
    unit_of_measurement: Hrs
    icon: mdi:timer
    mode: slider

  hive_water_4_time:
    name: "Water 4 on for"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 0.5
    unit_of_measurement: Hrs
    icon: mdi:timer
    mode: slider

  hive_water_boost_time:
    name: "Water boost for"
    min: 0.5
    max: 2
    step: 0.5
    #initial: 0.5
    unit_of_measurement: Hrs
    icon: mdi:timer
    mode: slider


input_select:  #----------------------------------------------------------------

  hive_water_target_mode:
    name: Hive water mode
    icon: mdi:water-pump
    options:
      - "off"                     # off (boiler off)
      - "heat"                    # water (boiler on)
      #- "emergency_heating"       # Hive thermostat is boosting
      #- "auto"                    # Hive thermostat/app scheduled


sensor: #-----------------------------------------------------------------------

  - platform: history_stats
    name: Hive water today
    entity_id: binary_sensor.hive_water_reported_action
    state: "on"
    type: time
    start: "{{ now().replace(hour=0, minute=0, second=0) }}"
    end: "{{ now() }}"


template:  #--------------------------------------------------------------------

  - binary_sensor:

      # Action as reported by HIVE
      - name: "Hive water reported action"
        unique_id: hive_water_reported_action
        state: "{{ is_state_attr('climate.hive_water','hvac_action', 'heating') }}"


  - sensor:

      # Mode as reported by HIVE (Off, On, Schedule, Boost)
      - name: Hive water reported mode
        unique_id: hive_water_reported_mode
        state: "{{ states('climate.hive_water') }}"

      # Triggers hive automation to set temp to this sensor
      - name: "Hive water target mode"
        unique_id: hive_water_target_mode
        availability: "{{ states('climate.hive_water') not in ['unknown', 'unavailable'] }}"  # check this
        state: >
          {% set influence = state_attr('sensor.hive_water_target_mode','influence') %}

          {%   if influence == 'Boost' %}       heat
          {% elif influence == 'Bathroom' %}    heat
          {% elif influence == 'Schedule 1' %}  heat
          {% elif influence == 'Schedule 2' %}  heat
          {% elif influence == 'Schedule 3' %}  heat
          {% elif influence == 'Schedule 4' %}  heat
          {% else %}                            off
          {% endif %}
        attributes:
          influence: >    # entity setting the temperature
            {% set shed1 = states('input_boolean.hive_water_1_scheduled') %}
            {% set shed2 = states('input_boolean.hive_water_2_scheduled') %}
            {% set shed3 = states('input_boolean.hive_water_3_scheduled') %}
            {% set shed4 = states('input_boolean.hive_water_4_scheduled') %}
            
            {% set on1 = states('input_datetime.hive_water_1_on')[:5] %}
            {% set on2 = states('input_datetime.hive_water_2_on')[:5] %}
            {% set on3 = states('input_datetime.hive_water_3_on')[:5] %}
            {% set on4 = states('input_datetime.hive_water_4_on')[:5] %}
            
            {% set off1 = (
                            state_attr('input_datetime.hive_water_1_on','timestamp')
                            + states('input_number.hive_water_1_time')|float *3600
                          )|timestamp_custom('%H:%M', false) %}
            {% set off2 = (
                            state_attr('input_datetime.hive_water_2_on','timestamp')
                            + states('input_number.hive_water_2_time')|float *3600
                          )|timestamp_custom('%H:%M', false) %}
            {% set off3 = (
                            state_attr('input_datetime.hive_water_3_on','timestamp')
                            + states('input_number.hive_water_3_time')|float *3600
                          )|timestamp_custom('%H:%M', false) %}
            {% set off4 = (
                            state_attr('input_datetime.hive_water_4_on','timestamp')
                            + states('input_number.hive_water_4_time')|float *3600
                          )|timestamp_custom('%H:%M', false) %}
            
            {% set mode =     states('input_select.hive_water_target_mode') %}
            {% set boost =    states('timer.hive_water_boost') %}
            {% set bathroom = states('timer.hive_water_boost_bathroom') %}
            {% set home =     states('zone.home') %}
            {% set time =     states('sensor.time') %}
            
            {%   if mode        == 'heat' %}
              {%   if boost     == 'active' %}                                  Boost
              {% elif bathroom  == 'active' %}                                  Bathroom
              {% elif home      != '0' %}
                {%   if shed1   == 'on' and (time >= on1) and (time < off1) %}  Schedule 1
                {% elif shed2   == 'on' and (time >= on2) and (time < off2) %}  Schedule 2
                {% elif shed3   == 'on' and (time >= on3) and (time < off3) %}  Schedule 3
                {% elif shed4   == 'on' and (time >= on4) and (time < off4) %}  Schedule 4
                {% else %}                                                      Standby
                {% endif %}
              {% else %}                                                        Away
              {% endif %}
            {% else %}                                                          Off
            {% endif %}
        icon: >
          {% set influence = state_attr('sensor.hive_water_target_mode','influence') %}
        
          {%   if influence == 'Boost' %}       mdi:timer
          {% elif influence == 'Bathroom' %}    mdi:shower
          {% elif influence == 'Schedule 1' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 2' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 3' %}  mdi:calendar-check-outline
          {% elif influence == 'Schedule 4' %}  mdi:calendar-check-outline
          {% elif influence == 'Off' %}         mdi:water-boiler-off
          {% elif influence == 'Away' %}        mdi:car
          {% elif influence == 'Standby' %}     mdi:power-on
          {% elif influence == 'Off' %}         mdi:power-off
          {% else %}                            mdi:help
          {% endif %}

      - name: Hive Water 1 Off
        unique_id: Hive Water 1 Off
        device_class: timestamp
        state: >
          {% set time = states('input_datetime.hive_water_1_on') |today_at %}
          {% set minutes = (states('input_number.hive_water_1_time') |float)*60 %}
          {{ (time + timedelta(minutes=minutes)) }}

      - name: Hive Water 2 Off
        unique_id: Hive Water 2 Off
        device_class: timestamp
        state: >
          {% set time = states('input_datetime.hive_water_2_on') | today_at %}
          {% set minutes = (states('input_number.hive_water_2_time') |float)*60 %}
          {{ (time + timedelta(minutes=minutes)) }}

      - name: Hive Water 3 Off
        unique_id: Hive Water 3 Off
        device_class: timestamp
        state: >
          {% set time = states('input_datetime.hive_water_3_on') | today_at %}
          {% set minutes = (states('input_number.hive_water_3_time') |float)*60 %}
          {{ (time + timedelta(minutes=minutes)) }}

      - name: Hive Water 4 Off
        unique_id: Hive Water 4 Off
        device_class: timestamp
        state: >
          {% set time = states('input_datetime.hive_water_4_on') | today_at %}
          {% set minutes = (states('input_number.hive_water_4_time') |float)*60 %}
          {{ (time + timedelta(minutes=minutes)) }}

timer:  #-----------------------------------------------------------------------

  # Boosts when timer is 'active'     for boost_time [hrs]
  hive_water_boost:
    name: Hive water boost timer
    icon: mdi:timer
    restore: true
 
  # Boosts when timer is 'active'     by 30 [mins]
  hive_water_boost_bathroom:
    name: Hive water bathroom timer
    duration: "00:30:00"
    icon: mdi:shower
    restore: true


script: #-----------------------------------------------------------------------

  # only needed as I'm not sure how to set timer duration within custom:button
  hive_water_toggle_boost:
    alias: "Hive water: Toggle boost"
    sequence:
      - if:
          - condition: state
            entity_id: timer.hive_water_boost
            state: 'active'
        then:
          - action: timer.finish
            target:
              entity_id: timer.hive_water_boost
        else:
          - action: timer.start
            target:
              entity_id: timer.hive_water_boost
            data:
              duration:  "{{ (states('input_number.hive_water_boost_time') |float(30)) *3600 }}"
    icon: mdi:water-pump
    mode: single


automation:   #-----------------------------------------------------------------

  - alias: Hive water control
    id: "hive_water"
    description: ''
    mode: queued
    initial_state: true                                     # ensure automation is on at startup
    trigger:
      - platform: template                                  # reset mode if thermostat out-of-sync
        value_template: "{{ states('sensor.hive_water_reported_mode') != states('input_select.hive_water_target_mode') }}"
      - platform: state
        entity_id: input_select.hive_water_target_mode      # user sets mode - for 'emergency_heating' and 'auto'
      - platform: state
        entity_id: sensor.hive_water_target_mode            # prog sets mode - for 'heat' and 'off'
      - platform: homeassistant
        event: start                                        # set correct mode on startup
    action:
      - choose:
          - conditions:
              - condition: or
                conditions:
                  - condition: state
                    entity_id: sensor.hive_water_target_mode
                    state: 'off'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/water/set
                  payload: |-
                    {
                      "system_mode":"off",
                      "temperature_setpoint_hold":"0"
                    }
          - conditions:
              - condition: state
                entity_id: sensor.hive_water_target_mode
                state: 'heat'
            sequence:
              - action: mqtt.publish
                data:
                  topic: zigbee2mqtt/Hive/water/set
                  payload: |-
                    {
                      "system_mode":"heat",
                      "temperature_setpoint_hold":"1"
                    }

Were my posts of any use?

Thanks for sharing. I will try out over the weekend and let you know how I get on.

@jchh Thank you for doing this. It has been on my “todo list” for a while.
I have worked out the templates and how to install, and my screen is now showing less and less errors (I havent got the hive system setup via z2m until I know it works (WAF!)).

I have these errors on heating.yaml and water.yaml packages

Is it because the entities are missing?
Thanks again!

It’s working fine for me - not sure what errors those are. What version of HA are you running?

Can you show the actual errors you are seeing?

I am using HAOS/ core 2024.11.1/ supervisor 2024.11.3
Will investigate further and see if I can add the hive system via z2m when I get some time. It is probably due to the missing entities

Many thanks!

so have you converted everything from a package file and created them individually? …wow a lot of work.

Yes, the problem is probably be that climate.hive_heat and climate.hive_water dont yet exist. You could rename my template entities to match whatever climate.xxx` you are using if you are feeling adventurous?

I did have a package version that used the hive hub but I got rid off it when I realised I was sticking with Z2M.

I can try to recreate it for you but will be unable to test. The changes would be in the scripts and automations.

…or are you simply prepping as much as possible for your move Z2M/ZHA?

Yes, this!

I need to have a solution that replaces the ease of functionality of the Hive app with something running locally on HA. But saying that,most of the interaction is actually by voice (Alexa-but will move to HA Voice at sometime)
I do have TRVs, but hardly ever change them from a schedule.

I wasnt sure how to implement your solution… I copied the template bits into the view and these seem to work. I have managed to get the package files working as far as I know.

Happy to learn - you have much more in the way of skills than I do at this!

I have a Hive Thermostat v3, two channel receiver and about 12 Hive TRVs. I’m already have a large Z2M Zigbee network so want to move Hive over to a local installation. Before I do so, I just want to clarify a something that’s niggling me. Will the TRVs activate a Call to Heat on the Thermostat which then signals the receiver?

Or is everything manual ie the TRV is activated so you need to tell the Thermostat to boost and also tell the receiver to start up the boiler?

I really just wish to know how much of the inbuilt Hive automation remains once you move to Z2M

TIA

I am using 1 TRV in my bedroom radiator and I have a simple automation to switch it ff when I get up and switch it on in the evening. It doesn’t call anything.

I don’t think the TRVs do anything with respect to the Hive thermostat unless you specifically program it to do so (and I have not).

I did some experimenting myself and can confirm an automation is required to activate the boiler receiver when the TRV issues a call to heat. I’ve written up a guide for setting up a full fat Hive based heating system

https://community.home-assistant.io/t/how-to-move-your-heating-system-from-hive-to-home-assistant/808765

1 Like

Hi jchh,

Yes! your posts were great, many thanks for posting this! Just moved my Hive to local control, rather than the online Hive service, and all your code is working very nicely, as far as I can tell (once I’d worked out I’d missed ensuring sensor.time was configured!)

I’ve also learnt so much about using YAML to configure everything

Only error I’m now getting is that internals_automation is missing - it’s referenced in the dashboard, but I can’t see it in any of what you’ve posted - did I miss it, or is it something you’ve omitted?

many thanks again

1 Like

I have no clue (off the top of my head) what that is. Can you post a screenshot? Is there anything on the logs?

This is from the dashboard:


          - type: custom:expander-card
            title: Default settings
            title-card-button-overlay: true
            padding: 0em
            gap: 0em
            cards:
              - type: entities
                entities:
                  - type: custom:numberbox-card
                    entity: input_number.hive_heating_away_temp
                    name: Away
                  - type: custom:numberbox-card
                    entity: input_number.hive_heating_open_temp
                    name: Win/Drs
                  - type: divider
                  - type: custom:numberbox-card
                    entity: input_number.hive_heating_boost_temp
                  - type: custom:numberbox-card
                    entity: input_number.hive_heating_boost_time
              - type: custom:decluttering-card
                template: internals_automation
                variables:
                  - automation: hive_heating_*

And this is the error I get:

thanks

OK, got it.

Sorry, this is my mistake. I forgot to add that decuttering_template as it’s a general one that I use all over the place and forgot that it was in that dashboard as well.

I no longer use it (it was just a way of being able to switch the Hive automatons on/off from the dashboard.

You’ve got 2 choices:

1 - delete this from your dash:

decluttering-card
 - type: custom:decluttering-card
   template: internals_automation
   variables:
     - automation: hive_heating_*

2- add the decluttering template:

internals_automation
default:
  - title: ''
  - slice: 0

card:
  type: custom:auto-entities
  show_empty: false
  card:
    type: entities
    title: '[[title]]'
    show_header_toggle: false
  sort:
    method: name
  filter:
    include:
      - entity_id: 'automation.[[automation]]'
        options:
          type: custom:button-card
          entity: this.entity_id
          show_state: true
          name: "[[[ return entity.attributes.friendly_name.slice([[slice]]) ]]]"
          styles:
            grid:
              - grid-template-areas: '". n s"'
              - grid-template-columns: 1em 1fr 2em
            card:
              - height: 40px
              - padding: 0
            name:
              - justify-self: start
              - font-size: 14px
              - color: "[[[ if (entity.state == 'off') return 'grey'; else return 'lightgrey'; ]]]"
            state:
              - color: "[[[ if (entity.state == 'off') return 'brown'; else return 'green'; ]]]"
              - font-weight: bold
          tap_action:
            action: toggle
          hold_action:
            action: more-info

edit: I’ll modify the original post to include it.