Breaking apart sensor values

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Breaking apart sensor values

Post 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?
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Breaking apart sensor values

Post 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
}
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: Breaking apart sensor values

Post 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)
Jan Jansen
Posts: 229
Joined: Wednesday 30 April 2014 20:27
Target OS: Raspberry Pi / ODroid
Domoticz version: Stable
Location: The Netherlands
Contact:

Re: Breaking apart sensor values

Post 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
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest