Use logfile from seperate Raspberry as Device / Device.entity

Hi all,
I am totally new to HA.
HA is running on Docker on a server.
I have a raspberry connected to my network and a sensor is connected to this raspberry.
I do some calculations with the sensor values and put the value with a time stamp into a logfile.
Now I want to use the latest entry and give it as entity to HA and want to see it on the Dashboard.

What is the best way to hand over the latest value to HA?

How? With code you wrote yourself? Or some third party software?

Either way, the best way to get the data to HA is via MQTT, and push the data to HA via a broker.

1 Like

okay, thanks. I wrote some code myself runnign as Python script on the raspberry.

Cool - so all you need to do is add a MQTT client in your python code, add Mosquitto server to your HA install and define some sensors. :smiley:

I use HAOS rather than a docker install so I am not much help with installing the server, but here is a site for the Python MQTT client:

Obviously you want to connect to the server on your HA box rather than some external one.

I created a MQTT broker on the server.
Added in my Python script a MQTT push.
See in HA integration MQTT see the messages from the raspberry, if I click on starting listening.

I tried to add a sensor to configuration.yaml like in the tutorials and documentation:

Logger: homeassistant.config
First occurred: 17:20:25 (1 occurrences)
Last logged: 17:20:25

Invalid config for [mqtt]: [-sensor] is an invalid option for [mqtt]. Check: mqtt->mqtt->0->-sensor. (See /config/configuration.yaml, line 13). Please check the docs at MQTT - Home Assistant

13: mqtt:
14: -sensor:
15: state_topic: “oeltank/tankinhalt”

How to configure a MQTT sensor?

now its working with this config:
name: “Oeltank Tankinhalt”
unique_id: “oeltank/tankinhalt”
state_topic: “oeltank/tankinhalt”
unit_of_measurement: “Liter”

Very strange…

I think I fucked up some lines and spaces.
I am not sure why there were so many issues.
Now it seems working. Thanks for the help

1 Like