updateRain give other value

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

updateRain give other value

Post by hestia »

Hi
I have created several rain sensors that are updated with dzVents: updateRain(rate, counter)
I can see exactly my values updated for the rate, but others values for the counter (in the web page and in the log)

The script

Code: Select all

--[[ 
]]--

local DOMAIN = ':test'

local dev_rain = 314 -- dummy receive rain in mm / Type Rain
local dev_Rain1h = 311 -- dummy receive 1h expected rain in mm / Type Rain
local dev_Rain12h = 312 -- dummy receive 12h expected rain in mm / Type Rain
local dev_Rain24h = 313 -- dummy receive 24h expected rain in mm / Type Rain



return {
	active = true,
	logging = {
		level = domoticz.LOG_DEBUG, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
		marker = DOMAIN},
	on = {
		devices = {206}   -- a switch for testing w/o waiting minutes
	
	},
	execute = function(dz, triggerObject)
    
    	print('0 - rate: ' .. dz.devices(dev_rain).rainRate)
    	print('0 - rain: ' .. dz.devices(dev_rain).rain)
  
    	print('1 - rate: ' .. dz.devices(dev_Rain1h).rainRate)
    	print('1 - rain: ' .. dz.devices(dev_Rain1h).rain)
    	
    	print('12 - rate: ' .. dz.devices(dev_Rain12h).rainRate)
    	print('12 - rain: ' .. dz.devices(dev_Rain12h).rain)
    	
    	print('24 - rate: ' .. dz.devices(dev_Rain24h).rainRate)
    	print('24 - rain: ' .. dz.devices(dev_Rain24h).rain)
    	
    	
		local RainPrecip = 150 -- in Rate divided by 100
		local RainRate = 5 -- in Top
	    
	    print('RainPrecip:  ' .. RainPrecip .. '  RainRate:  ' .. RainRate)
	  
	  	-- Rain meter: rain: Number / rainRate: Number / updateRain(rate, counter)
		
		dz.devices(dev_rain).updateRain(RainPrecip, RainRate)
		dz.devices(dev_Rain1h).updateRain(RainPrecip, RainRate)
		dz.devices(dev_Rain12h).updateRain(RainPrecip, RainRate)
		dz.devices(dev_Rain24h).updateRain(RainPrecip, RainRate)
	
   
end
}
The log
Spoiler: show
2018-10-30 13:37:46.327 Status: dzVents: Info: :test: ------ Start internal script: Meteo_test: Device: "test inter4 (Dummy1)", Index: 206
2018-10-30 13:37:46.329 Status: dzVents: Debug: :test: Processing device-adapter for Pluie (mm): Rain device
2018-10-30 13:37:46.329 Status: dzVents: 0 - rate: 1.5
2018-10-30 13:37:46.329 Status: dzVents: 0 - rain: 4.5999999046326
2018-10-30 13:37:46.330 Status: dzVents: Debug: :test: Processing device-adapter for Pluie 1 h (mm): Rain device
2018-10-30 13:37:46.330 Status: dzVents: 1 - rate: 1.5
2018-10-30 13:37:46.330 Status: dzVents: 1 - rain: 5
2018-10-30 13:37:46.331 Status: dzVents: Debug: :test: Processing device-adapter for Pluie 12 h (mm): Rain device
2018-10-30 13:37:46.331 Status: dzVents: 12 - rate: 1.5
2018-10-30 13:37:46.331 Status: dzVents: 12 - rain: 3.5999999046326
2018-10-30 13:37:46.333 Status: dzVents: Debug: :test: Processing device-adapter for Pluie 24 h (mm): Rain device
2018-10-30 13:37:46.333 Status: dzVents: 24 - rate: 1.5
2018-10-30 13:37:46.333 Status: dzVents: 24 - rain: 3.5999999046326
2018-10-30 13:37:46.333 Status: dzVents: RainPrecip: 150 RainRate: 5
2018-10-30 13:37:46.333 Status: dzVents: Info: :test: ------ Finished Meteo_test
2018-10-30 13:37:46.414 Status: EventSystem: Script event triggered: /home/pi/domoticz/dzVents/runtime/dzVents.lua
Anybody has any explanation?
Thanks
Hestia
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: updateRain give other value

Post by waaren »

hestia wrote: Tuesday 30 October 2018 13:40 Hi
I have created several rain sensors that are updated with dzVents: updateRain(rate, counter)
I can see exactly my values updated for the rate, but others values for the counter (in the web page and in the log)
Anybody has any explanation?
dzVents just store the values you entered in updateRain() in the sValue field of the sensor device. Domoticz then take these values from the database and perform some magic calculations on them to come with values presented on the Gui.
I once tried to understand what exactly that magic was and implemented it in my updateWeatherSensors script. (look for functions self.RainForecast2MM and self.RainForecast) but was never completely satisfied with the result.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: updateRain give other value

Post by hestia »

Thanks waaren for the answer.
I've checked and the others weather sensors seems do give the good values (same value I've updated). I have issue only with the counter for the rain and the dew value that seems to be calculated anyway.
Perhaps I could just do a custom sensor with the rain icon. But custom sensors only have one value :-(
BTW do you know how to set the rain icon in a custom sensor and put it in the weather tab?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest