Page 1 of 1

Breaking apart sensor values

Posted: Monday 10 July 2023 15:33
by desertdog
I am setting up my sunscreens and I want them to retract when rain is expected and/or when windspeeds get to high.
I get the following values from my weather sensors

wind: 240.00;WSW;36;62;24.1;24.1
rain: 0;0.0
rain.over: 0.0000

The last value is easy to use in a blocky. If the value is between 0 and 15, there will be rain within 15 minutes and the sunscreens will go up
The other values are more of a hassle. There are multiple values in the returned date: wind direction; wind direction name; speed (36 means 3,6 m/s); gust; temperature; chill.

How can I separate these values so I can use them in blockly? I want to be able to write something like:
If the value of speed is greater than 6 or the gust is greater than 8, the sunscreens will go up.

How can I do this?

Re: Breaking apart sensor values

Posted: Tuesday 11 July 2023 14:37
by Jan Jansen
For the weather I use OMW. To split the data I use the following dzvents script.

Code: Select all

return 
{
	on = { devices = { 'Wind' }},
	
	execute = function(dz, item)
	    dz.devices('Windsnelheid').updateCustomSensor(item.speed)
	    dz.devices('Windstoten').updateCustomSensor(item.gust)
	    dz.devices('Windrichting').updateCustomSensor(item.direction)
	end
}

Re: Breaking apart sensor values

Posted: Tuesday 11 July 2023 16:02
by desertdog
Thank so much. Is there also a way to get the temperature from this ?
I added the follwing line and the virtual sensor, but it seems item.temp is not the value. where can I find those?

dz.devices('Temperatuur').updateCustomSensor(item.temp)

Re: Breaking apart sensor values

Posted: Wednesday 12 July 2023 6:49
by Jan Jansen
Replace the custom sensor with a temperature sensor. Use the following script:

Code: Select all

return 
{
	on = { devices = { 'Wind' }},
	
	execute = function(dz, item)
	    dz.devices('Windsnelheid').updateCustomSensor(item.speed)
	    dz.devices('Windstoten').updateCustomSensor(item.gust)
	    dz.devices('Windrichting').updateCustomSensor(item.direction)
	    dz.devices('Buitentemperatuur').updateTemperature(item.temperature)
	end
}