Page 1 of 1
Sensor Data to virtual Sensor
Posted: Friday 17 July 2020 20:51
by Wolli82
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
Re: Sensor Data to virtual Sensor
Posted: Friday 17 July 2020 21:21
by waaren
Wolli82 wrote: ↑Friday 17 July 2020 20:51
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?
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 ?
Re: Sensor Data to virtual Sensor
Posted: Friday 17 July 2020 22:11
by Wolli82
There was a spelling mistake. This is the Sensor with 0-10V

- Anmerkung 2020-07-17 220645.png (12.51 KiB) Viewed 1922 times
And i will fill this virtual Sensor

- Anmerkung 2020-07-17 220646.png (13.89 KiB) Viewed 1922 times
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!
Re: Sensor Data to virtual Sensor
Posted: Friday 17 July 2020 22:54
by waaren
Wolli82 wrote: ↑Friday 17 July 2020 22:11
So i would like an example to change the conversion myself.
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
}
Re: Sensor Data to virtual Sensor
Posted: Saturday 18 July 2020 18:38
by Wolli82
I have tested the script but unfortunately nothing works. Do you have another idea?
Re: Sensor Data to virtual Sensor
Posted: Saturday 18 July 2020 21:03
by waaren
Wolli82 wrote: ↑Saturday 18 July 2020 18:38
I have tested the script but unfortunately nothing works. Do you have another idea?
I also tested the script (before posting) and it works as expected. When I update the voltage sensor the pressure sensor gets updated

- Volt2Bar.png (20.06 KiB) Viewed 1869 times
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
Re: Sensor Data to virtual Sensor
Posted: Tuesday 21 July 2020 16:36
by Wolli82
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.
Re: Sensor Data to virtual Sensor
Posted: Tuesday 21 July 2020 17:47
by waaren
Wolli82 wrote: ↑Tuesday 21 July 2020 16:36
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.
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
}
Re: Sensor Data to virtual Sensor
Posted: Wednesday 22 July 2020 14:28
by Wolli82
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?
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
}
Re: Sensor Data to virtual Sensor
Posted: Wednesday 22 July 2020 15:45
by waaren
Wolli82 wrote: ↑Wednesday 22 July 2020 14:28
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?
Not sure I understand what you write but would this do ?
change line 42 from
Code: Select all
waterflowSensor.updateWaterflow(item.voltage)
to
Code: Select all
waterflowSensor.updateWaterflow(item.voltage * 0.01 )
Re: Sensor Data to virtual Sensor
Posted: Thursday 05 October 2023 22:22
by ssk17051980
what presure sensor do you use ?