Calculate average temperature
Moderators: leecollings, remb0
-
- Posts: 9
- Joined: Saturday 30 September 2017 17:13
- Target OS: Linux
- Domoticz version: 2020.2
- Location: NL/PT
- Contact:
Calculate average temperature
How do I write the average temperature from 3 outside sensors in one created dummy temperature sensor?
Domoticz on Synology NAS and Intel NUC (Linux)
Interfaces: zWave, Zigbee and RFXcom
Locations: Netherlands and Portugal
Interfaces: zWave, Zigbee and RFXcom
Locations: Netherlands and Portugal
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Calculate average temperature
Using a dzVents script, it Could look like below scriptHenkHavelaar wrote: ↑Monday 07 December 2020 20:24 How do I write the average temperature from 3 outside sensors in one created dummy temperature sensor?
__________________________________________________________________________________________________________________________
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
___________________________________________________________________________________________________________________________
Code: Select all
return
{
on =
{
timer =
{
'every minute',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to LOG_ERROR when all OK
marker = 'Average temperature',
},
execute = function(dz, device)
local t1 = dz.devices('temperature 1').temperature -- change text between quotes to name of your devices
local t2 = dz.devices('temperature 2').temperature
local t3 = dz.devices('temperature 3').temperature
local averageTemperature = dz.devices('Average Temperature')
averageTemperature.updateTemperature( dz.utils.round( ( ( t1 + t2 + t3 ) / 3 ) , 1 ) )
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Saturday 30 September 2017 17:13
- Target OS: Linux
- Domoticz version: 2020.2
- Location: NL/PT
- Contact:
Re: Calculate average temperature
Thanx waaren for the tips. I am going to try this after reading the tips and wiki.
Programma ingevoegd, aangepast aan eigen device namen, werkt perfect! Bedankt.
Programma ingevoegd, aangepast aan eigen device namen, werkt perfect! Bedankt.
Domoticz on Synology NAS and Intel NUC (Linux)
Interfaces: zWave, Zigbee and RFXcom
Locations: Netherlands and Portugal
Interfaces: zWave, Zigbee and RFXcom
Locations: Netherlands and Portugal
- Thuis
- Posts: 251
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: Calculate average temperature
Hello, so i came across this script and i use it now for average of 3 temperatures.
But there is something i do not understand. The average temperature is correct but.
2 of the temperature devices are Temp,Hum and Baro. Only one device, is temperature only.
Now i call it every 2 minutes. But the sensor with only temperature gives an error in the log like:
Now if i just disable this reading in the script and change the script to take only t2 and t3 divide by 2 then no error.
Enable the original 3 temperature devices and error.
How come? Do i need to read-out the sensor in a different way instead of ".temperature"?
Anyone has an answer? Much appreciated.
But there is something i do not understand. The average temperature is correct but.
2 of the temperature devices are Temp,Hum and Baro. Only one device, is temperature only.
Now i call it every 2 minutes. But the sensor with only temperature gives an error in the log like:
- Spoiler: show
Now if i just disable this reading in the script and change the script to take only t2 and t3 divide by 2 then no error.
Enable the original 3 temperature devices and error.
How come? Do i need to read-out the sensor in a different way instead of ".temperature"?
Anyone has an answer? Much appreciated.
- Spoiler: show
I Love Domoticz ! And the community around it :-)
Who is online
Users browsing this forum: No registered users and 0 guests