Sensor Data to virtual Sensor
Moderator: leecollings
Sensor Data to virtual Sensor
Hello!
I want to copy the data from a sensor into a virtual sensor and convert the data. I have a 0-10V input that I want to convert into cash. Does anyone have an example for me?
Many Thanks
I want to copy the data from a sensor into a virtual sensor and convert the data. I have a 0-10V input that I want to convert into cash. Does anyone have an example for me?
Many Thanks
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sensor Data to virtual Sensor
What are the types / subtypes of the source and target sensors and what should be the ratio ? 10V is 10 cents or 10V is 10.000 $ or ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Sensor Data to virtual Sensor
There was a spelling mistake. This is the Sensor with 0-10V
For a flow meter i must do the same, but i don´t know the ratio now.
So i would like an example to change the conversion myself.
Thank you in advance for the help!
And i will fill this virtual Sensor
0V is 0 bar and 10V is 10 bar.For a flow meter i must do the same, but i don´t know the ratio now.
So i would like an example to change the conversion myself.
Thank you in advance for the help!
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sensor Data to virtual Sensor
Could look like below in dzVents
When not yet familiar with dzVents please start with reading Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents enabled' is checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
return
{
on =
{
devices =
{
'Brunnenpumpe Druck',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domiticz.LOG_ERROR when all OK
marker = 'Conversion',
},
execute = function(dz, item)
dz.devices('Brunnenpumpe Druck1').updatePressure(item.voltage)
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Sensor Data to virtual Sensor
I have tested the script but unfortunately nothing works. Do you have another idea?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sensor Data to virtual Sensor
I also tested the script (before posting) and it works as expected. When I update the voltage sensor the pressure sensor gets updated
Please provide more detail about the circumstances and relevant loglines. This will make searching why it does not work for you, easier for other forum members.
So how do you update the voltage meter. And can you show the loglines of this update
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Sensor Data to virtual Sensor
It works now, thank you very much!!!
Can you help me to another problem?
I have a Switch "Brunnenpumpe Ein/Aus".
If "Brunnenpumpe Ein/Aus" is on and the value for "Brunnenpumpe Druck" >= 3V then the dimmer-switch "Brunnenpumpe Drehzahl" should be switched off.
Can you help me to another problem?
I have a Switch "Brunnenpumpe Ein/Aus".
If "Brunnenpumpe Ein/Aus" is on and the value for "Brunnenpumpe Druck" >= 3V then the dimmer-switch "Brunnenpumpe Drehzahl" should be switched off.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sensor Data to virtual Sensor
Below script combines the two requirements (Conversion and Control)
Code: Select all
local voltMeterName = 'Brunnenpumpe Druck'
local pumpSwitchName = 'Brunnenpumpe Ein/Aus'
return
{
on =
{
devices =
{
voltMeterName,
pumpSwitchName,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
marker = 'Conversion and Control',
},
execute = function(dz, item)
local pressureSensor = dz.devices('Brunnenpumpe Druck1')
local rotationalSpeed = dz.devices('Brunnenpumpe Drehzahl')
local voltMeter = dz.devices(voltMeterName)
local pumpSwitch = dz.devices(pumpSwitchName)
if item == voltMeter then
pressureSensor.updatePressure(item.voltage)
end
if ( voltMeter.voltage >= 3 ) and pumpSwitch.active and rotationalSpeed.state ~= 'Off' then
rotationalSpeed.dimTo(0)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Re: Sensor Data to virtual Sensor
Thanks, it works perfect!!
Here is my script, but i would like to convert the water flow sensor value with a factor of 0.01. Do you have another idea?
Here is my script, but i would like to convert the water flow sensor value with a factor of 0.01. Do you have another idea?
Code: Select all
local voltMeterName = 'Brunnenpumpe Druck'
local voltMeter1Name = 'Brunnenpumpe Durchfluss'
local pumpSwitchName = 'Brunnenpumpe Ein/Aus'
return
{
on =
{
devices =
{
voltMeterName,
voltMeter1Name,
pumpSwitchName,
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when all OK
marker = 'Conversion and Control',
marker = 'Conversion and Control1',
},
execute = function(dz, item)
local pressureSensor = dz.devices('Brunnenpumpe Drucksensor')
local waterflowSensor = dz.devices('Brunnenpumpe Durchflusssensor')
local rotationalSpeed = dz.devices('Brunnenpumpe Drehzahl')
local voltMeter = dz.devices(voltMeterName)
local voltMeter1 = dz.devices(voltMeter1Name)
local pumpSwitch = dz.devices(pumpSwitchName)
--Volt in Bar
if item == voltMeter then
pressureSensor.updatePressure(item.voltage)
end
--Volt in Liter pro Minute
if item == voltMeter1 then
waterflowSensor.updateWaterflow(item.voltage)
end
--Abschaltung Pumpe über 3 Bar
if ( voltMeter.voltage >= 3 ) and pumpSwitch.active then
rotationalSpeed.switchOff()
dz.log('Druck ueber 3 bar')
end
--Einschaltung unter 1 Bar
if ( voltMeter.voltage <= 1 ) and pumpSwitch.active then
rotationalSpeed.switchOn()
dz.log('Druck unter 1 bar')
end
end
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Sensor Data to virtual Sensor
Not sure I understand what you write but would this do ?
change line 42 from
Code: Select all
waterflowSensor.updateWaterflow(item.voltage)
Code: Select all
waterflowSensor.updateWaterflow(item.voltage * 0.01 )
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 112
- Joined: Thursday 08 December 2022 22:15
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2023.2
- Location: ROMANIA
- Contact:
Re: Sensor Data to virtual Sensor
what presure sensor do you use ?
Who is online
Users browsing this forum: jberinga and 1 guest