[Solved] Calculating Temperature Difference

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

[Solved] Calculating Temperature Difference

#1 Post by costo » 07 Feb 2019, 02:55

I am using ESPEasy 1.48 with MQTT protocol.
I have two DS18b20 sensors , one connected to the cold and the other to the warmwater pipe of my central heating.
Both values are received by domoticz. Now I also want to display the temperature_difference into domoticz.
I could easy do this in domoticz with a script but I thought it must be easy for EASPEasy to do this for me.
Sending the temperature with Publish domoticz/in works but the value is displayed as a string.

this is my Rules:

Code: Select all

On System#Boot do
  timerSet,1,30
endon

On Rules#Timer=1 do
 Diff = Warm#Temperature-Cold#Temperature
 
 Publish domoticz/in,{"idx":775,"nvalue":0,"svalue":Diff}
 timerSet,1,30
endon

The log looks like this:
2089230 : DS : Temperature: 40.75 (28-d4-41-45-92-e-2-44)
2089231 : EVENT: Cold#Temperature=40.75
2089301 : DS : Temperature: 45.44 (28-9-4a-45-92-e-2-ba)
2089303 : EVENT: Warm#Temperature=45.44
2089378 : MQTT : Connected to broker
2089381 : Subscribed to: domoticz/out
2095542 : EVENT: Rules#Timer=1
2095546 : ACT : Diff = Warm#Temperature-Cold#Temperature
2095550 : ACT :
2095554 : ACT : Publish domoticz/in,{"idx":775,"nvalue":0,"svalue":Diff}
2095563 : ACT : timerSet,1,30
I tried it in several ways but I cannot make it work so that the Diff string is replaced by the calculated difference of warm & cold.

Is this possible to do in ESPEasy 1.48 ?
How can it be done ?
Or do I need to go to ther mega version ?
Last edited by costo on 07 Feb 2019, 14:38, edited 1 time in total.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Calculating Temperature Difference

#2 Post by grovkillen » 07 Feb 2019, 05:37

Create a dummy device and do this:

Code: Select all

On System#Boot do
  timerSet,1,30
endon

On Rules#Timer=1 do
 TaskValueSet,12,1,[Warm#Temperature]-[Cold#Temperature]
 Publish domoticz/in,{"idx":775,"nvalue":0,"svalue":[Diff#Temp]}
 timerSet,1,30
endon
In this example the dummy is named Diff#Temp and is stored on task number 12.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
costo
Normal user
Posts: 500
Joined: 21 Nov 2015, 15:03
Location: NL, zw-NB

Re: Calculating Temperature Difference

#3 Post by costo » 07 Feb 2019, 14:37

Thank you grovkillen for this excellent solution.

After posting the question here I kept experimenting with the example in the wiki and found a working solution with a dummy.

Code: Select all

 on Warm#Temperature do
  TaskValueSet,4,1,[Warm#Temperature]-[Cold#Temperature]  
   Publish domoticz/in,{"idx":775,"nvalue":0,"svalue":"[Diff#C1]"}
 endon
But I find your solution with timerSet more elegant so I will use that.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 38 guests