Hi, consider this a guide, but also if anyone has some better suggestions I am more than willing to make changes and update what I’ve done.
I’m trying to use my Hive Heating devices via my Sonoff Zigbee controller instead of the included Hub (one less devices, plus it recently required a full reboot so, why not).
Another user @Burgess101 put together the required files, which I was able get to work when using just one device but I needed to integrate multiple devices - it wasn’t immediately obvious to me at first (bit of googling needed!).
The need for multiple devices would be common in Ireland and the UK where heating zones are created to control rads in different parts of the house, in my case it is two zones: Downstairs and Upstairs.
I’ll link to the relevant github from Burgess / Greeny which has all the files needed for a one Hive solution and the changes below for a multi Hive solution.
The main reason you need to change things to work is here is that HA wouldn’t recognise two separate files that both contain sensor: and climate: as per the original setup from above. This wouldn’t be obvious to newbies so figured this thread might help explain what to do.
Intro:
You will need to be able to access your config folder and have done some initial messing around with the configuration.yaml before starting with this in my opinion as I will have skipped some basic steps at times.
So, assuming you’re logged in via Visual Studio Add On or directly from the VS Application you want to start with adding and creating directories and files. We will add content later!
My current setup, right now I have one file with two sets of sensor and climate each in it.
Method 1:
Add the below lines to configuration.yaml - double check indentation.
mqtt:
!include hive/mqtt/MQTT_Both.yaml
Create Directories:
- Directory one to create is hive in the config folder
- Sub directory under this I have is mqtt
- The file to create is MQTT_Both.yaml (or your own name).
So the file MQTT_Both.yaml is quite large, you will need to take the first two sample files below and combine /copy paste them into one file, our MQTT_Both.yaml file (or your own name!). Some brief instructions below, or not so brief…
- Start a blank text file on your PC, in the very first line add
sensor:
- Paste the contents of Sample File 1 into the blank text file on your PC
- Perform a find and replace for “downstairs” with your preferred name (say Zone_1).
- Copy paste this into the bottom of MQTT_Both.yaml.
- Repeat 3 and 4 for all extra thermostats, for each Hive Receiver you need unique identifiers for all the sensors.
Now repeat the process for the Sample File 2, which is your climate device.
- Start a blank text file on your PC, in the very first line add
climate:
- Paste the contents of Sample File 2 into the blank text file on your PC
- Perform a find and replace for “downstairs” with your preferred name (say Zone_1).
- Copy paste this into the bottom of MQTT_Both.yaml.
- Repeat 3 and 4 for all extra thermostats, for each Hive Receiver you need unique identifiers for all the sensors.
If this confuses anyone I can simply send them the full copy of mine, or put that in a separate post in this thread. But I thought it more relevant to explain how it works, even if it is done poorly.
Method 2:
You’ll need to read method one as I won’t repeat instructions for more basic steps here.
This second method should work as well and I think is easier to keep organised. Basically you will have two files per Thermostat / Hive Receiver combo.
File 1 and 2 in the sensor folder will contain the sensors, see sample file 1 below. These will not need a sensor header as it is included in the configuration.yaml
File 3 and 4 in the climate folder will contain the climate entities, see sample file 2 below.
Directory structure: (in configuration.yaml)
Make sure to create the directories under config for hive, mqtt and both sensor and climate.
mqtt:
sensor:
!include_dir_merge_named hive/mqtt/sensor
climate:
!include_dir_merge_named hive/mqtt/climate
Each of these directories contains two files:
sensor
- hive_sensors_zone1.yaml
- hive_sensors_zone2.yaml
climate:
- hive_climate_zone1.yaml
- hive_climate_zone2.yaml
The content of these files is below, you will need to update the names for each copy of these.
Sample File 1: hive_sensors_zone1.yaml - this should be in the directory mentioned under mqtt > sensor above.
- unique_id: "downstairs_occupied_heating_setpoint"
name: "Downstairs Occupied Heating Setpoint"
state_topic: "zigbee2mqtt/Downstairs"
unit_of_measurement: "°C"
value_template: "{{ value_json.occupied_heating_setpoint }}"
force_update: true
- unique_id: "downstairs_system_mode"
name: "Heating System Mode"
state_topic: "zigbee2mqtt/Downstairs"
value_template: "{{ value_json.system_mode }}"
force_update: true
- unique_id: "downstairs_local_temperature"
name: "Downstairs Local temperature"
state_topic: "zigbee2mqtt/Downstairs"
value_template: "{{ value_json.local_temperature | round(1, 'floor') }}"
force_update: true
- unique_id: "downstairs_running_state"
name: "Downstairs Running State"
state_topic: "zigbee2mqtt/Downstairs"
value_template: "{{ value_json.running_state }}"
force_update: true
- unique_id: "downstairs_temperature_setpoint_hold"
name: "Downstairs Temperature Setpoint Hold"
state_topic: "zigbee2mqtt/Downstairs"
force_update: true
value_template: "{{ value_json.temperature_setpoint_hold }}"
Sample File 2: hive_climate_zone1.yaml - this should be in the directory mentioned under mqtt > climate above.
- unique_id: "downstairs_heating"
name: Downstairs Heating
max_temp: 32
min_temp: 12
precision: 0.5
retain: false
qos: 0
payload_on: 1
payload_off: 0
temperature_unit: "C"
modes:
- "auto"
- "off"
- "heat"
- "boost"
# Listen for changes published by the thermostat
mode_state_topic: "zigbee2mqtt/Downstairs"
mode_state_template: >-
{%
if value_json.system_mode == 'heat' and
value_json.temperature_setpoint_hold_duration !=65535
%}
auto
{%
elif value_json.system_mode == 'emergency_heating' %}
boost
{%
elif value_json.system_mode == 'heat' and
value_json.temperature_setpoint_hold_duration == 65535
%}
heat
{%
elif value_json.system_mode == 'off'%}
off
{% endif %}
current_temperature_topic: "zigbee2mqtt/Downstairs"
current_temperature_template: "{{value_json.local_temperature}}"
temperature_state_topic: "zigbee2mqtt/Downstairs"
temperature_state_template: >-
{% if value_json.occupied_heating_setpoint != 1 %}
{{value_json.occupied_heating_setpoint}}
{% elif states("sensor.downstairs_system_mode") == "off" %}
{{states("input_number.downstairs_frost_prevention")}}
{% elif states("sensor.downstairs_system_mode") == "heat" and
states("sensor.downstairs_temperature_setpoint_hold_duration") != 65536
%}
{{states("input_number.downstairs_frost_prevention")}}
{% endif %}
# get changes in the climate component and republish on the topic
# (Rather than going directly to the thermostat)
temperature_command_topic: "zigbee2mqtt/downstairs_heating/occupied_heating_setpoint"
mode_command_topic: "zigbee2mqtt/downstairs_heating/system_mode"
The rest of the setup is pretty standard to how it is done for just adding one device although I’ve possibly overcomplicated all of this.
In your configuration.yaml you will also need the below lines and the relevant files stores in the relevant directories. These files can be copy pasted from the github all the way above and renamed to match your own sensors.
#Load automations
automation hive_down: #Hive Automations
!include hive/automation/Hive_Downstairs.yaml
automation hive_up: #Hive Automations
!include hive/automation/Hive_Upstairs.yaml
#Load custom packages
homeassistant:
packages:
!include_dir_merge_named hive/integrations/
!include_dir_named packages/
Sample hive/integration file: (pretty much copy pasted from github with new names to match my devices / house setup)
downstairs_boost_temperature:
name: Heating Boost Temperature
initial: 22
min: 12
max: 32
step: 0.5
icon: "mdi:heat-wave"
downstairs_frost_prevention:
name: Heating Frost Prevention
initial: 12
min: 5
max: 16
step: 0.5
icon: "mdi:snowflake-thermometer"
downstairs_boost_duration:
name: Heating Boost Duration
min: 5
max: 45
step: 5
icon: "mdi:timer"
Sample Hive Automation File: (as above)
- id: '1666548062412'
alias: 'Downstairs Set Temperature'
description: 'Sends the requested temperature from the climate control to the correct topic'
trigger:
- platform: mqtt
topic: zigbee2mqtt/downstairs_heating/occupied_heating_setpoint
condition:
- condition: template
value_template: '{{trigger.payload != 1}}'
action:
- choose:
- conditions:
- condition: template
value_template: '{{ states("sensor.downstairs_system_mode") == "heat"}}'
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{"occupied_heating_setpoint": "{{trigger.payload}}"}'
- conditions:
- condition: template
value_template: '{{ states("sensor.downstairs_system_mode") == "off"}}'
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{"temperature_setpoint_hold": true, "system_mode": "heat" }'
- delay: 0.5
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"temperature_setpoint_hold": true,
"system_mode": "heat",
"occupied_heating_setpoint": {{trigger.payload}},
"temperature_setpoint_hold_duration": 65535
}'
mode: single
- id: '1666513667863'
alias: 'Downstairs Heating System Mode'
description: 'Sends the requested system mode from the climate control to the correct topic'
trigger:
- platform: mqtt
topic: zigbee2mqtt/downstairs_heating/system_mode
id: system mode
condition: []
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.payload == "off" }} '
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"system_mode": "off",
"temperature_setpoint_hold": false
}'
- delay: 0.5
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"occupied_heating_setpoint": {{states("input_number.downstairs_frost_prevention")}},
"temperature_setpoint_hold_duration": 65535
}'
- conditions:
- condition: template
value_template: '{{ trigger.payload == "heat" and states("sensor.occupied_heating_setpoint") != 1}}'
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"temperature_setpoint_hold_duration": 65535,
"occupied_heating_setpoint": 20.0,
"temperature_setpoint_hold": true,
"system_mode": "heat"
}'
- conditions:
- condition: template
value_template: '{{ trigger.payload == "boost" and states("sensor.occupied_heating_setpoint") != 1}}'
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"temperature_setpoint_hold": true,
"system_mode": "emergency_heating",
"occupied_heating_setpoint": {{states("input_number.downstairs_boost_temperature")}},
"temperature_setpoint_hold_duration": {{states("input_number.downstairs_boost_duration")}}
}'
- delay: 0.5
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"temperature_setpoint_hold": true,
"system_mode": "emergency_heating",
"occupied_heating_setpoint": {{states("input_number.downstairs_boost_temperature")}},
"temperature_setpoint_hold_duration": {{states("input_number.downstairs_boost_duration")}}
}'
- conditions:
- condition: template
value_template: '{{ trigger.payload == "auto" }} '
sequence:
- service: mqtt.publish
data:
topic: zigbee2mqtt/Downstairs/set
payload_template: '{
"system_mode": "heat",
"temperature_setpoint_hold": false,
"occupied_heating_setpoint": {{states("input_number.downstairs_frost_prevention")}},
"temperature_setpoint_hold_duration": 0
}'
mode: single