Scraping windspeed + event

Moderator: leecollings

Post Reply
PappleD
Posts: 4
Joined: Thursday 25 February 2016 22:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Scraping windspeed + event

Post by PappleD »

Hello,

I've been using domoticz now for more then 4 years, doing very basic stuff and copying lua script from others.
Since the update to buster and the latest release of domoticz you can use Buienradar plugin.
Finally there was an easy way to automate my sunscreen on the wind speed i thought.
So i've added the buienradar plugin added temperature, wind, rain etc.

so then i wanted to trigger an dummy switch based on the wind speed.

But the buienradar wind sensor is output is like this: 318.00;NW;34;58;23.7;23.7
(wind direction degree, wind direction, wind speed, gust, temperature, feeling temperature)
So as un-knowleged that i'm i started my script

If wind speed > 100 and wind trigger is off,
Do wind trigger is on
Else if: wind speed <100 and wind trigger is on
do wind trigger is off

But then my event will not get triggered... i found out that the event is using only the first number in the output seqeunce.
In this case wind direction.... so not what I was looking for.

Then i remember from my old rain buienradar script you can scrape values from this multi-value sensor.
So i looked it up and with some hassle i managed to made this:

It's a device trigger event
commandArray = {}

local sensorwu = 'WindTotaal' --name of the sensor that gets created when you add the WU device (and that contains multiple values like temperature, humidity, barometer etc)
local idxt = 260 --idx of the virtual temperature sensor you need to change this to your own Device IDx

if devicechanged[sensorwu] then
WindRichtingGraden, WindRichting, WindSnelheid, Windvlaag, Temperatuur, Gevoelstemperatuur = otherdevices_svalues[sensorwu]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
WindRichtingGraden = tonumber(WindRichtingGraden)
WindRichting = tostring(WindRichting)
WindSnelheid = tonumber(WindSnelheid)
Windvlaag = tonumber(Windvlaag)
Temperatuur = tonumber(Temperatuur)
Gevoelstemperatuur = tonumber(Gevoelstemperatuur)
--parseDebug = ('WU Script Parsed Wind snelheid=' WindSnelheid)
--print(parseDebug)

commandArray[1] = {['UpdateDevice'] = idxt .. '|0|' .. WindSnelheid}
--commandArray[2] = {['UpdateDevice'] = idxh .. '|' .. tostring(sWeatherHumidity) .. '|' .. tostring(sHumFeelsLike)}
--commandArray[3] = {['UpdateDevice'] = idxp .. '|0|' .. tostring(sWeatherPressure) .. ';' .. tostring(sWeatherPressForcast)}
end

return commandArray
I've made a virtual sensor for wind that this script is pushing his values to.
In the event page, on the paremeter overview i see my IDX 260 with the value of wind speed only.

part of log:
2020-04-08 19:14:12.885 Status: Warning: Expecting svalue with at least 5 elements separated by semicolon, 1 elements received ("27"), notification not sent (Hardware: 34 - WindCustom, ID: 82260, Unit: 1, Type: 56 - Wind, SubType: 1 - WTGR800)
2020-04-08 19:14:12.885 Status: EventSystem: Script event triggered: Windsnelheid
then i used that into my blocky event, but nothing happens.
Then i tried a custom sensor, but that also did not work.

Also i tried a simple event: if wind speed >0.1, do turn on light.
also no response

What am I missing? and is someone able to help me

Thanks
Paul
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest