Send entity data to external server

Hi guys,

I am new to this and I struggle with one major setup.

I installed HA OS to Pi 4 and connected various devices to it, including solar inverter and a weather station. Everything is working fine, but I want the data to be used further on my website, which runs on an externally hosted server.

What I would like to do is to be able to send selected entity data (eg. temperature from my weather station, current solar panel generation) to this external server (the format does not really matter, either as a JSON text file, CSV file or anything easily readable) at a regular interval, say every minute.

I want to be able to display this data on my website in real-time and this would also create a long-term storage for the data, because unlike my Pi4 + SD card, my server has much larger storage capacity.

I found some topics mentioning MQTT, I installed it in my HA, but I am not sure how to set it up on the server side because I can only access my externally hosted server via FTP and I cannot install anything there.

Any hint or solution is highly appreciated.

Google Sheets?

My idea was to send data directly to the server without any intermediat services.

Is your Home Assistant reachable from outside your network? If so, having the server poll the HA API is probably the easiest way to go.

In that case you can set up a rest sensor that contacts a remote php server with the data.
The php server just needs to grab the GET variables.

I use this to get the version image below.

  - platform: rest
    name: forum_image
    resource_template: >-
                        http://www.somewhere.com/hass/version.php?version={{states('sensor.installed_version_2') }}&latest={{states('sensor.latest_version_2') }}
    value_template: '1'  
    scan_interval: 3600  

So this sends my installed version and the latest version every hour, and if either of them has changed the php code generates a new image.

Thanks a lot, I will try this, it seems like this is what I need.

The only downside to this approach is scan interval isn’t totally reliable. Everytime HA restarts or the REST integration is reloaded from the UI the state of that sensor will be recalculated and then a new 3600 second timer will start. Which means you won’t actually get data every hour. You’ll get it every hour while HA is running continuously but then every restart, update or reload it’ll give you a data point at an unpredictable time.

@jachymbrzezina If you want the data every hour on the hour (or at some other extremely regular and predictable interval) then I would suggest using a rest command instead. Then make an automation which calls your rest command at the interval you want with a time pattern trigger.

Plus rest commands support POST calls so the actual API call should be a lot easier. Don’t have to try and stuff all the info in the query string, just make a JSON payload.