-
Notifications
You must be signed in to change notification settings - Fork 45
Home Assistant Integration (outdated)
Masoko edited this page Feb 11, 2024
·
1 revision
If you are using discovery_messages
, then this step is not required as a new MQTT device will be automatically created in Home Assistant and all you need to do is add it to a dashboard.
Once you installed the script on your raspberry you need to create some sensors in home assistant.
This is the sensors configuration if group_messages = True
assuming your sensors are separated in sensors.yaml
file.
- platform: mqtt
name: 'rpi4 cpu load'
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[0] }}'
unit_of_measurement: "%"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[1] }}'
name: rpi4 cpu temp
unit_of_measurement: "°C"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[2] }}'
name: rpi4 diskusage
unit_of_measurement: "%"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[3] }}'
name: rpi4 voltage
unit_of_measurement: "V"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[4] }}'
name: rpi4 sys clock speed
unit_of_measurement: "MHz"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[5] }}'
name: rpi4 swap
unit_of_measurement: "%"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[6] }}'
name: rpi4 memory
unit_of_measurement: "%"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[7] }}'
name: rpi4 uptime
unit_of_measurement: "days"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[8] }}'
name: rpi4 wifi signal
unit_of_measurement: "%"
- platform: mqtt
state_topic: 'masoko/rpi4'
value_template: '{{ value.split(",")[9] }}'
name: rpi4 wifi signal
unit_of_measurement: "dBm"
This is the sensors configuration if group_messages = False
assuming your sensors are separated in sensors.yaml
file.
- platform: mqtt
state_topic: "masoko/rpi4/cpuload"
name: rpi4 cpu load
unit_of_measurement: "%"
- platform: mqtt
state_topic: "masoko/rpi4/cputemp"
name: rpi4 cpu temp
unit_of_measurement: "°C"
- platform: mqtt
state_topic: "masoko/rpi4/diskusage"
name: rpi4 diskusage
unit_of_measurement: "%"
- platform: mqtt
state_topic: "masoko/rpi4/voltage"
name: rpi4 voltage
unit_of_measurement: "V"
- platform: mqtt
state_topic: "masoko/rpi4/sys_clock_speed"
name: rpi4 sys clock speed
unit_of_measurement: "hz"
- platform: mqtt
state_topic: "masoko/rpi4/swap"
name: rpi4 swap
unit_of_measurement: "%"
- platform: mqtt
state_topic: "masoko/rpi4/memory"
name: rpi4 memory
unit_of_measurement: "%"
- platform: mqtt
state_topic: "masoko/rpi4/uptime_days"
name: rpi4 uptime
unit_of_measurement: "days"
- platform: mqtt
state_topic: "masoko/rpi4/wifi_signal"
name: rpi4 wifi signal
unit_of_measurement: "%"
- platform: mqtt
state_topic: "masoko/rpi4/wifi_signal_dbm"
name: rpi4 wifi signal
unit_of_measurement: "dBm"
Add this to your customize.yaml
file to change the icons of the sensors.
sensor.rpi4_voltage:
friendly_name: rpi 4 voltage
icon: mdi:flash
sensor.rpi4_cpu_load:
friendly_name: rpi4 cpu load
icon: mdi:chip
sensor.rpi4_diskusage:
friendly_name: rpi4 diskusage
icon: mdi:harddisk
sensor.rpi4_sys_clock_speed:
icon: mdi:clock
sensor.rpi4_cpu_temp:
friendly_name: rpi4 cpu temperature
sensor.rpi4_swap:
icon: mdi:folder-swap
sensor.rpi4_memory:
icon: mdi:memory
After that you need to create entities list via the home assistant GUI. You can use this code or compose it via the GUI.
type: entities
title: Rapsberry Pi MQTT monitor
entities:
- entity: sensor.rpi4_cpu_load
- entity: sensor.rpi4_cpu_temp
- entity: sensor.rpi4_diskusage
- entity: sensor.rpi4_voltage
- entity: sensor.rpi4_sys_clock_speed
- entity: sensor.rpi4_swap
- entity: sensor.rpi4_memory
- entity: sensor.rpi4_uptime
- entity: sensor.rpi4_wifi_signal
- entity: sensor.rpi4_wifi_signal_dbm
...