HomeAssistant and RPICT unit on the same Raspberry Pi
This guide is for interfacing a RPICT unit hosted on the same Raspberry Pi along with HomeAssistant.
Installing Home Assistant on the Raspberry Pi
Install the homeassistant image as explained on this page below.
https://www.home-assistant.io/installation/raspberrypi
Enable the serial port
For this you will need to make a change that can only be done on the SD card itself.
Use a SD card reader to read the SD card you just flashed with Home Assistant.
Open the hassos-boot
volume on your computer.
On some OS this volume might not be automatically mounted. Use a disk manager to mount it.
In there you will find a file called config.txt
.
Open this file with a text editor and remove the # in front the line saying
enable_uart=1
For Pi5 also add this line below
dtoverlay=uart0
Save the file and unmount the SD card. You can now insert it in the Raspberrypi and start Home Assistant.
Edit the configuration.yaml
Go to Settings | Add-ons | Add-on Store.
Search for File and install File Editor.
Make sure you start it once installed and tick Show in sidebar on.
Go to File Editor from the left pane. Select the file called configuration.yaml. At the botton of this file add the following configuration:
sensor:
- platform: serial
name: "RPICT"
serial_port: /dev/ttyAMA0
baudrate: 38400
- platform: template
sensors:
rpict_ct1:
friendly_name: CT1
unit_of_measurement: "W"
value_template: "{{ states('sensor.RPICT').split(' ')[1] | float }}"
rpict_ct2:
friendly_name: CT2
unit_of_measurement: "W"
value_template: "{{ states('sensor.RPICT').split(' ')[2] | float }}"
rpict_ct3:
friendly_name: CT3
unit_of_measurement: "W"
value_template: "{{ states('sensor.RPICT').split(' ')[3] | float }}"
homeassistant:
customize:
sensor.rpict_ct1:
icon: mdi:current-ac
sensor.rpict_ct2:
icon: mdi:current-ac
sensor.rpict_ct3:
icon: mdi:current-ac
Save the file using the red floppy disc icon at the top right.
Then go to Developper tools and click on CHECK CONFIGURATION from the top bar. Make sure it confirms the configuration file is valid before continuing.
If everything looks good click on RESTART then Restart Home Assistant.
View the Sensor data
You can now go to Overview and the data will appear in the Sensor section.
Convert Power to Energy
Homeassistant can convert power in Watts to energy in KWh using the Riemann integral.
More about this here.
To enable this add the following to the sensor
section of the configuration.yaml file.
- platform: integration
source: sensor.rpict_ct1
name: energy_ct1
unit_prefix: k
round: 2
max_sub_interval:
minutes: 5
rpict_ct1
is the channel you intend to convert to Energy. Modify this as required.
From the Energy dashboard you should now be able to add energy_ct1
as a consumption in the Elecrticity Grid.
The widget below should appear
Troubleshooting
-
Beware that Homeassistant does not seem to work well with Firefox. Use another browser if you find it failing to open some pages.
-
hassos-boot volume is not always automatically mounted. Use your operating system disk manager to mount it manually.
Homeassistant and RPICT unit on a different host
We would recommend to use MQTT to forward the RPICT data other to Homeassistant.
This is described in our guide here
This Github source below will help you achieve that. https://github.com/ned-kelly/docker-lechacal-homeassistant
Credit to ned-kelly on Github for making this interface.