Wind speed script

Moderator: leecollings

Toulon7559
Posts: 859
Joined: Sunday 23 February 2014 17:56
Target OS: Raspberry Pi / ODroid
Domoticz version: <2025
Location: Hengelo(Ov)/NL
Contact:

Re: Wind speed script

Post by Toulon7559 »

Extending my latest message in this thread in which I stated
Considering your stated application for sunscreencontrol, think about a strong&long hysteresys, because otherwise the screens may be jumping up and down!
;-) A very practical risk, but solution is rather easy.

2 General approaches, which can be combined (or not):
1) timing of the script loop, which causes the script to be executed with intervals
2) filtering of data, which 'smooths' the incoming data

1) is rather simple with many examples.
General approach:
if <time-check> then
[script-actions]
end

2) is slightly more complicated.
General approach:
a. make user-variable output_var and set default value
b. (in the script) set value alpha for 'speed' of filter. 1 = 100% of actual data (= quick reaction), and 0.1 is 10% of actual data (~ lazy reaction)
c. read actual data
d. read user-variable output_var
e. calculate output = output_var + alpha * data
f. check value of output to take action (or not)
g. save output as user-variable output_var
h. repeat c. till g. in which 1) may set the rythm of the input & output.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Wind speed script

Post by Jan Jansen »

waaren wrote: Sunday 22 March 2020 12:38
I don't see a command in this script to update a device. It is only sending something to the log.
First, the classic LUA suits me most at this time. I am not a programmer, but I see that it makes sense for me to study Dzvents.

My wish is for the following devices to be updated
1 dummy, type wind, called Windsnelheid,
2 dummy, type wind, called Windvlaag,
3 dummy, temperature type, called Buitentemperatuur.

I hope I don't ask too much.

@ Toulon
For the next challenge I choose solution 1, thanks anyway
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Wind speed script

Post by waaren »

Jan Jansen wrote: Sunday 22 March 2020 15:15 My wish is for the following devices to be updated
1 dummy, type wind, called Windsnelheid,
2 dummy, type wind, called Windvlaag,
3 dummy, temperature type, called Buitentemperatuur.
Below is a dzVents version. If you need a Lua version you will have to wait for someone else on the forum to help.

Code: Select all

return 
{
	on = { devices = { 'Wind en buitentemperatuur' }},
	
	execute = function(dz, item)
	    dz.devices('Windsnelheid').updateWind(item.direction, item.directionString, item.speed, item.gust)
	    dz.devices('Windvlaag').updateWind(item.direction, item.directionString, item.gust, item.gust )
	    dz.devices('Buitentemperatuur').updateTemperature(item.temperature)
	end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Wind speed script

Post by Jan Jansen »

waaren wrote: Sunday 22 March 2020 17:17
Your tenacity convinced me. I'm going to practice with Dzvents.

Thank you very much for your help
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest