Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


peejayw

1913 posts

Uber Geek
+1 received by user: 123


#303444 10-Feb-2023 19:37
Send private message

Back in Oct 21 I requested and received help on adding an offset to an ESP based temperature sensor. I have since replaced that sensor with an Aqara one and need to do the same thing with it.
One person mentioned using a template sensor to achieve this, something I have no knowledge of.
Can anyone point me to a resource that explains how to go about this?
Specifically, I need to take the air pressure value from the sensor and add 24 to it to convert it to a sea level value.
Thanks.




 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Filter this topic showing only the reply marked as answer Create new topic
hairy1
3352 posts

Uber Geek
+1 received by user: 644

ID Verified
Trusted
Lifetime subscriber

  #3034789 10-Feb-2023 20:53
Send private message

Hey.

 

Maybe try something like this? Not tested...

 

 

 

template:
  - sensor:
      - name: "Airpressure"
        unit_of_measurement: hPa
        value_template: “{{states(‘sensor.yourpressurehere’)|float + 24 }}”





My views (except when I am looking out their windows) are not those of my employer.




peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3034790 10-Feb-2023 20:55
Send private message

Ok, will try it, thanks.




 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3035066 11-Feb-2023 15:57
Send private message

Thanks to @hairy1 I have made a template sensor to add a value of 24 to the airpressure data, thanks hairy1.

 

However, the data off the snsor shows with one decimal ie 1015.0 whereas I just want it as 1015.

 

I tried using round int but that doesnt work, any suggestions?

 

Here is the entry...

 

 

 outside_air_pressure:

 

        friendly_name: "Outside Air Pressure"

 

        unit_of_measurement: 'hPa'

 

        value_template:   "{{states('sensor.lumi_lumi_weather_pressure_3')|float + 24 | round|int }}"

 

Thanks.

 

 

 

 





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.




mattenz
195 posts

Master Geek
+1 received by user: 48


  #3035387 12-Feb-2023 15:17
Send private message

That looks good, I don't suppose you've forgotten to restart?


peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3035392 12-Feb-2023 15:24
Send private message

No, I have restarted a few times but the decimal place persists.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


eluSiveNZ
192 posts

Master Geek
+1 received by user: 42


  #3035465 12-Feb-2023 16:56
Send private message

Had a look at some of mine, I am using round(0) would this work ?

 

Also FYI, in checking it looks like Home Assistant has changed the way templating is done and this current template is now "legacy".

 

Looks like I also have some updating to do...


 
 
 

Shop now on AliExpress (affiliate link).
peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3035494 12-Feb-2023 17:54
Send private message

Thanks, I tried round(0) but still the same.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


hairy1
3352 posts

Uber Geek
+1 received by user: 644

ID Verified
Trusted
Lifetime subscriber

  #3035656 12-Feb-2023 21:58
Send private message

Sorry. Have been flying all weekend and just walked in the door.

 

Try this...

 

 

 

 value_template:   "{{states('sensor.lumi_lumi_weather_pressure_3')| round(0) + 24 }}"





My views (except when I am looking out their windows) are not those of my employer.


peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3035700 13-Feb-2023 07:07
Send private message

That gave me an odd result,  #994.0 994

 

?





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


peejayw

1913 posts

Uber Geek
+1 received by user: 123


  #3035706 13-Feb-2023 07:34
Send private message

Oops, my bad, forgot to comment out a line. That works perfectly now, thanks very much.





 I'm supposed to respect my elders, but it's getting harder and harder for me to find one now.


Filter this topic showing only the reply marked as answer Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.