Communication / Home Assistant
Integrating MiniHPC with Home Assistant via MQTT
MiniHPC can be integrated into the Home Assistant system using the MQTT protocol. This allows you to monitor data (e.g., temperature, power, consumption, relay output statuses, etc.) as well as to set various parameters (e.g., heating/cooling mode, temperature settings, and other MiniHPC parameters).
Prerequisites and Requirements
1. Operational MQTT Broker
- For example, the Mosquitto MQTT broker.
- If you are using Home Assistant OS or Home Assistant Supervised, you can use the official Mosquitto Add-On.
2. Connecting MiniHPC to the MQTT Broker
- Within the web interface of MiniHPC, you need to configure the IP address, port, and login credentials (username, password) for the broker.
3. Familiarity with the topics used by MiniHPC
- Within MQTT, the device (MiniHPC) publishes data to specific topics (e.g., miniHPC/data/...) and receives commands through other topics (e.g., minihpc/set/...).
4. Home Assistant with Active MQTT Integration
- In Home Assistant, it is necessary to add the MQTT integration via Settings → Devices & Services → Add Integration.
The following example shows a complete configuration.yaml with sample sensors. In an actual deployment, you need to adjust the root topic (if a topic other than the default miniHPC is used).
mqtt:
# =======================
# 1) Sensors (reading data from MiniHPC)
# =======================
- sensor:
- name: "Temperature T1"
unique_id: "temperature_t1"
state_topic: "miniHPC/data/t1"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: &minihpc_device_info
identifiers: "MiniHPC"
name: "MiniHPC"
model: "MiniHPC"
manufacturer: "MiniHPC"
configuration_url: http://192.168.1.199 # update this with your MiniHPC config URL
- name: "Temperature T2"
unique_id: "temperature_t2"
state_topic: "miniHPC/data/t2"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Temperature T3"
unique_id: "temperature_t3"
state_topic: "miniHPC/data/t3"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Temperature T4"
unique_id: "temperature_t4"
state_topic: "miniHPC/data/t4"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Temperature T5"
unique_id: "temperature_t5"
state_topic: "miniHPC/data/t5"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Temperature T6"
unique_id: "temperature_t6"
state_topic: "miniHPC/data/t6"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Out Temperature"
unique_id: "temperature_out"
state_topic: "miniHPC/data/tout"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Temperature Evap"
unique_id: "temperature_evap"
state_topic: "miniHPC/data/tsuc"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Compressor Temperature"
unique_id: "temperature_compressor"
state_topic: "miniHPC/data/texh"
device_class: temperature
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "ODU mode"
unique_id: "odu_mode"
state_topic: "miniHPC/data/outMode"
device: *minihpc_device_info
- name: "ODU state"
unique_id: "odu_state"
state_topic: "miniHPC/data/outState"
value_template: >-
{% if value == '1' %}
ON
{% else %}
OFF
{% endif %}
device: *minihpc_device_info
- name: "Compressor frequency"
unique_id: "Compressor frequency"
state_topic: "miniHPC/data/outFrequency"
device_class: frequency
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "Hz"
device: *minihpc_device_info
- name: "Fan speed"
unique_id: "fan_speed"
state_topic: "miniHPC/data/outFan"
device_class: speed
state_class: measurement
value_template: "{{ value }}"
unit_of_measurement: "RPM"
device: *minihpc_device_info
- name: "Power in"
unique_id: "power_in"
state_topic: "miniHPC/data/outPower"
device_class: power
state_class: measurement
unit_of_measurement: "W"
value_template: "{{ value | float | round (1) }}"
device: *minihpc_device_info
- name: "EEV"
unique_id: "eev"
state_topic: "miniHPC/data/outEEV"
state_class: measurement
device: *minihpc_device_info
- name: "ODU DC voltage"
unique_id: "odu_dc_voltage"
state_topic: "miniHPC/data/outDCbus"
device_class: voltage
state_class: measurement
unit_of_measurement: "V"
value_template: "{{ value | int }}"
device: *minihpc_device_info
- name: "ODU defrosting"
unique_id: "odu_defrost"
state_topic: "miniHPC/data/outDefrost"
value_template: >-
{% if value == '1' %}
ON
{% else %}
OFF
{% endif %}
device: *minihpc_device_info
- name: "ODU DC current"
unique_id: "odu_dc_current"
state_topic: "miniHPC/data/outDCcurrent"
device_class: current
state_class: measurement
unit_of_measurement: "A"
value_template: "{{ value | float | round (1) }}"
device: *minihpc_device_info
- name: "Water Flow"
unique_id: "water_flow"
state_topic: "miniHPC/data/flow"
device_class: volume_flow_rate
state_class: measurement
unit_of_measurement: "l/min"
value_template: "{{ value | float | round (2) }}"
device: *minihpc_device_info
- name: "Set Temperature"
unique_id: "set_temperature"
state_topic: "miniHPC/data/tset"
device_class: temperature
state_class: measurement
value_template: "{{ value | float | round (2) }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "ODU Tpreset"
unique_id: "odu_tpreset"
state_topic: "miniHPC/data/tIDUroom"
device_class: temperature
state_class: measurement
value_template: "{{ value | float | round (2) }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "ODU Tamb"
unique_id: "odu_tamb"
state_topic: "miniHPC/data/tIDUset"
device_class: temperature
state_class: measurement
value_template: "{{ value | float | round (1) }}"
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Power out"
unique_id: "power_out"
state_topic: "miniHPC/data/pwrOutHP"
device_class: power
state_class: measurement
unit_of_measurement: "W"
value_template: "{{ value | float | round (1) }}"
device: *minihpc_device_info
- name: "Time - HP heating"
unique_id: "time_hp_heating"
state_topic: "miniHPC/data/heatTimeHP"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Time - el. heater R2"
unique_id: "time_el_heater_r2"
state_topic: "miniHPC/data/heatTimeELH"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Time - defrost"
unique_id: "time_defrost"
state_topic: "miniHPC/data/heatTimeDefr"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Count - HP heating"
unique_id: "count_hp_heating"
state_topic: "miniHPC/data/heatCountHP"
state_class: measurement
device: *minihpc_device_info
- name: "Count - el. heater R2"
unique_id: "count_el_heater_r2"
state_topic: "miniHPC/data/heatCountELH"
state_class: measurement
device: *minihpc_device_info
- name: "count - defrost"
unique_id: "count_defrost"
state_topic: "miniHPC/data/heatCountDefr"
state_class: measurement
device: *minihpc_device_info
- name: "Time - HP cooling"
unique_id: "time_hp_cooling"
state_topic: "miniHPC/data/coolTimeHP"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Count - HP cooling"
unique_id: "count_hp_cooling"
state_topic: "miniHPC/data/coolCountHP"
state_class: measurement
device: *minihpc_device_info
- name: "Date - anti-legionella"
unique_id: "date_antilegionela"
state_topic: "miniHPC/data/dhwLegTime"
device_class: timestamp
value_template: "{{ (value | int) | timestamp_local }}"
device: *minihpc_device_info
- name: "Time - HP DHW"
unique_id: "time_hp_dhw"
state_topic: "miniHPC/data/dhwTimeHP"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Time - el. heater R1"
unique_id: "time_el_heater_r1"
state_topic: "miniHPC/data/dhwTimeELH"
device_class: duration
state_class: measurement
unit_of_measurement: "s"
device: *minihpc_device_info
- name: "Count - HP DHW"
unique_id: "count_hp_dhw"
state_topic: "miniHPC/data/dhwCountHP"
state_class: measurement
device: *minihpc_device_info
- name: "Count - el. heater R1"
unique_id: "count_el_heater_r1"
state_topic: "miniHPC/data/dhwCountELH"
state_class: measurement
device: *minihpc_device_info
- name: "Energy consumption - heating"
unique_id: "energy_consumption_heating"
state_topic: "miniHPC/data/heatPwrIn"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy consumption - cooling"
unique_id: "energy_consumption_cooling"
state_topic: "miniHPC/data/coolPwrIn"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy consumption - DHW"
unique_id: "energy_consumption_dhw"
state_topic: "miniHPC/data/dhwPwrIn"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy - HP heating"
unique_id: "energy_hp_heating"
state_topic: "miniHPC/data/heatPwrOutHP"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy - ELH heating"
unique_id: "energy_elh_heating"
state_topic: "miniHPC/data/heatPwrOutELH"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy - cooling"
unique_id: "energy_cooling"
state_topic: "miniHPC/data/coolPwrOut"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "Energy - DHW"
unique_id: "energy_dhw"
state_topic: "miniHPC/data/dhwPwrOut"
device_class: energy
state_class: measurement
unit_of_measurement: "kWh"
value_template: "{{ ((value | float) / 1000000) | round(3) }}"
device: *minihpc_device_info
- name: "BT - humidity"
unique_id: "bt_humidity"
state_topic: "miniHPC/data/BThum"
device_class: humidity
state_class: measurement
unit_of_measurement: "%"
value_template: "{{ value | float | round (2) }}"
device: *minihpc_device_info
- name: "BT - battery"
unique_id: "bt_battery"
state_topic: "miniHPC/data/BTbat_lev"
device_class: battery
state_class: measurement
unit_of_measurement: "%"
device: *minihpc_device_info
- name: "BT - RSSI"
unique_id: "bt_rssi"
state_topic: "miniHPC/data/BTrssi"
device_class: signal_strength
state_class: measurement
device: *minihpc_device_info
# =======================
# 2) binary (binarny sensor)
# =======================
- binary_sensor:
- name: "relay R1"
unique_id: "relay_r1"
state_topic: "miniHPC/data/R1"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "relay R2"
unique_id: "relay_r2"
state_topic: "miniHPC/data/R2"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "relay R3"
unique_id: "relay_r3"
state_topic: "miniHPC/data/R3"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "relay R4"
unique_id: "relay_r4"
state_topic: "miniHPC/data/R4"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "relay R5"
unique_id: "relay_r5"
state_topic: "miniHPC/data/R5"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "Switch S1"
unique_id: "switch_s1"
state_topic: "miniHPC/data/S1"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
- name: "Switch S2"
unique_id: "switch_s2"
state_topic: "miniHPC/data/S2"
payload_on: "1"
payload_off: "0"
device: *minihpc_device_info
# =======================
# 3) Select (select menu)
# =======================
- select:
- name: "Mode"
unique_id: "selest_mode"
command_topic: "miniHPC/set/mode"
state_topic: "miniHPC/config/mode"
options:
- "off"
- "heat"
- "cool"
command_template: >-
{% if value == 'off' %}
0
{% elif value == 'heat' %}
1
{% elif value == 'cool' %}
2
{% endif %}
value_template: >-
{% if value == '0' %}
off
{% elif value == '1' %}
heat
{% elif value == '2' %}
cool
{% else %}
off
{% endif %}
device: *minihpc_device_info
- name: "ODU power limit"
unique_id: "odu_power_limit"
command_topic: "miniHPC/set/odu_power_limit"
state_topic: "miniHPC/config/odu_power_limit"
options:
- "off"
- "70%"
- "50%"
command_template: >-
{% if value == 'off' %}
0
{% elif value == '70%' %}
1
{% elif value == '50%' %}
2
{% endif %}
value_template: >-
{% if value == '0' %}
off
{% elif value == '1' %}
70%
{% elif value == '2' %}
50%
{% else %}
off
{% endif %}
device: *minihpc_device_info
- name: "ODU Night mode"
unique_id: "odu_night_mode"
command_topic: "miniHPC/set/odu_night_mode"
state_topic: "miniHPC/config/odu_night_mode"
options:
- "off"
- "on"
- "timer"
command_template: >-
{% if value == 'off' %}
0
{% elif value == 'on' %}
1
{% elif value == 'timer' %}
2
{% endif %}
value_template: >-
{% if value == '0' %}
off
{% elif value == '1' %}
on
{% elif value == '2' %}
timer
{% else %}
off
{% endif %}
device: *minihpc_device_info
# =======================
# 4) Switch
# =======================
- switch:
- name: "DHW"
unique_id: "dhw"
state_topic: "miniHPC/config/dhw_onoff"
command_topic: "miniHPC/set/dhw_onoff"
payload_on: "1"
payload_off: "0"
state_on: "1"
state_off: "0"
retain: false
qos: 0
device: *minihpc_device_info
# =======================
# 5) Number
# =======================
- number:
- name: "Room Temperature T1"
unique_id: "room_temperature_t1"
state_topic: "miniHPC/config/temperature_T1"
command_topic: "miniHPC/set/temperature_T1"
min: 10
max: 30
step: 0.1
unit_of_measurement: "°C"
command_template: "{{ value|float * 10 }}"
value_template: "{{ value|float / 10 }}"
device: *minihpc_device_info
- name: "Water Temperature T2/T3 - heating"
unique_id: "water_temperature_t3_heating"
state_topic: "miniHPC/config/temperature_T3"
command_topic: "miniHPC/set/temperature_T3"
min: 15
max: 55
step: 1
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Water Temperature T3 - cooling"
unique_id: "water_temperature_t3_cooling"
state_topic: "miniHPC/config/temperature_T3_cool"
command_topic: "miniHPC/set/temperature_T3_cool"
min: 10
max: 55
step: 1
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "Offset - equithermal curve"
unique_id: "offset_equithermal_curve"
state_topic: "miniHPC/config/heating_eqtr_offset"
command_topic: "miniHPC/set/heating_eqtr_offset"
min: -9
max: 9
step: 1
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "DHW - switching difference"
unique_id: "dhw_switching_difference"
state_topic: "miniHPC/config/dhw_temp_diff"
command_topic: "miniHPC/set/dhw_temp_diff"
min: 5
max: 50
step: 1
unit_of_measurement: "°C"
device: *minihpc_device_info
- name: "DHW - Temperature"
unique_id: "dhw_temperature"
state_topic: "miniHPC/config/dhw_temp_target"
command_topic: "miniHPC/set/dhw_temp_target"
min: 2
max: 80
step: 1
unit_of_measurement: "°C"
device: *minihpc_device_info
Example YAML Code for Adding a Thermostat to Home Assistant
The thermostat switches between cooling/heating modes, reads the temperature T1, and sets the temperature_T1 value in the configuration.
mqtt:
- climate:
- name: "Thermostat"
unique_id: thermostat
device: *minihpc_device_info # in case, the device was defined before
modes:
- "off"
- "heat"
- "cool"
# ====================
# 1) Mode control
# ====================
mode_command_topic: "miniHPC/set/mode"
mode_state_topic: "miniHPC/config/mode"
mode_command_template: >-
{% if value == 'off' %}
0
{% elif value == 'heat' %}
1
{% elif value == 'cool' %}
2
{% endif %}
mode_state_template: >-
{% if value == '0' %}
off
{% elif value == '1' %}
heat
{% elif value == '2' %}
cool
{% else %}
off
{% endif %}
# ====================
# 2) Current temperature
# ====================
current_temperature_topic: "miniHPC/data/t1"
current_temperature_template: "{{ value|float }}"
temperature_unit: "C"
# ====================
# 3) Target temperature
# ====================
temperature_command_topic: "miniHPC/set/temperature_T1"
temperature_state_topic: "miniHPC/config/temperature_T1"
temperature_command_template: "{{ value|float * 10 }}"
temperature_state_template: "{{ value|float / 10 }}"
min_temp: 10
max_temp: 30
temp_step: 0.1
With the following YAML code, we create a thermostat card on the dashboard.
type: thermostat
entity: climate.minihpc_thermostat
features:
- style: icons
type: climate-hvac-modes
show_current_as_primary: true
External Sensor T1
An example for configuring a Home Assistant automation that calculates the average of 5 temperature sensors located around the house and sends their average as the T1 temperature of an external sensor to MiniHPC every minute.
alias: MiniHPC teploty T1
description: ""
triggers:
- minutes: /1
trigger: time_pattern
actions:
- data_template:
topic: miniHPC/setsensor/T1
payload: >
{% set sensors = [
states('sensor.temperature_room1'),
states('sensor.temperature_room2'),
states('sensor.temperature_room3'),
states('sensor.temperature_room4'),
states('sensor.temperature_room5')
] %} {% set valid_sensors = sensors | select('is_number') | map('float') | list %} {% if valid_sensors | length > 0 %}
{{ (valid_sensors | sum) / (valid_sensors | length) }}
{% else %}
0
{% endif %}
action: mqtt.publish
COP Calculation
For calculating COP, it is possible to create a template in configuration.yaml, which will compute it using the formula power/consumption
template:
- sensor:
- name: "MiniHPC COP"
unique_id: "minihpc_cop"
state: >
{% set p_out = states('sensor.minihpc_power_out') | float(0) %}
{% set p_in = states('sensor.minihpc_power_in') | float(1) %}
{% if p_out == 0 or p_in == 0 or
states('sensor.minihpc_power_out') in ['unavailable', 'unknown'] or
states('sensor.minihpc_power_in') in ['unavailable', 'unknown'] %}
unavailable
{% else %}
{{ (p_out / p_in) | round(2) }}
{% endif %}
icon: mdi:chart-line
state_class: measurement
device_class: power_factor