Temperatur sensor to web page

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 …

Thanks for the tips, examples and guidelines …

You have two options:

Thankyou, i will read and try… I hope some example is attached. I use xiaomi gateway3 and BT temp. sensors…
Regards

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.

I use simple php page…

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.

1 Like

Use a rest sensor in HA.

  - platform: rest
    name: send_temp_to_php
    resource_template: "http://www.YourURL.com/YourFile.php?temp1={{ states('sensor.temp1') }}&temp2={{ states('sensor.temp2') }}&token=ABCDEF"
    value_template: "OK"
    scan_interval: 300 # 5 minutes

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.

Ohh… super…do not rush

Did you see the post above?

Yes i see… Thankyou very much…
I’m on vacation now. When I get home I will give it a try

I expected to get an answer within 14 days, I am very surprised by the quick response

Regards

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

Again, see the first link of Tom.

Python is not my cup of tea.
But you can do it in Node red also.
It can read states and write files. Not sure if that will work for your case though

1 Like

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 ?

Thankyou