Hi All…
I have couple temperature sensor in my house and outside…
In home assistant work all super, but i need to include this temperature value to my homepage.
A simple page where it reads the temperature value from HA every xxx minutes and displays it on the homepage …
What kind of webpage do you have?
You could use a simple GET URL to send the data to your webpage and store it there.
But this requires more than just html.
In that case it should be easy with a GET rest command.
Give me a few minutes and I can give you the code I use to send data from my HA to my PHP website.
You need to change the URL and the tempsensors names. The token at the end is just something random.
This is to make sure if someone else visits your PHP page it doesn’t take those values as temperatures. It’s probably not needed but it doesn’t really matter either.
PHP:
<?php
if($_GET['temp1'] != "" && $_GET['temp2'] != "" && $_GET['token'] == "ABCDEF"){
file_put_contents('../SomeWhere/Tempjson.txt', json_encode([$_GET['temp1'], $_GET['temp2']]));
// or just place the full json string there including the token. It's probably easier.
}
And if you want you could have the PHP output the data it receives as json and have the json_attributes in HA take it. That way you can see what data you have stored on your webpage.
I don’t have the need for that though.
Meaning add this below in HA:
json_attributes:
- "temp1"
- "temp2"
and so on…
Then on the page you want to display the temperatures you need to read the Tempjson.txt and decode the json to array, but I assume you know how to do that.
Since this is GET calls, the URL/values and token is visible. So a hacker could intercept it and get your room temperature and send other values to your room temperatures in your webpage.
I was thinking something , another way … How would I read the sensor value with a python and then write it to a file on rpi3? Is it possible ? i also did something small with python already on my RPI3
Yes i see link of Tom, but i not understand how add rest api to my sistem…
I read all, but only find : I must add api commponent to my configuration.yaml file.
I have integration, Xiaomi Gateway 3 with 11 devices…
Where can i find some example or something for begginers ?