Hi,
I have a question how to establish the following with dzVents.
I have
Switch with IDX=1
Voltage indicator with IDX=2
Voltage indicator with IDX=3
When Switch with IDX=1 is "ON" then copy the measured voltage from IDX=2 to the voltage indicator with IDX=3
Can some help me with this?
Thanks
Analog measurement
Moderator: leecollings
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Analog measurement
Do you want to copy the value from 2 to 3 only when the switch state change from Off to On or do you want to copy from 2 to 3 every x minutes for as long as the switch state is On ?Knibor wrote: Saturday 27 October 2018 9:46 When Switch with IDX=1 is "ON" then copy the measured voltage from IDX=2 to the voltage indicator with IDX=3
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
-
Knibor
- Posts: 112
- Joined: Sunday 20 May 2018 12:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: Analog measurement
Hi,
Thanks for you reply, I want copy the value from 2 to 3 every x seconds for as long as the switch state is On ?
And when the Switch is Off the last On value keeps in IDX 3
Thanks for you reply, I want copy the value from 2 to 3 every x seconds for as long as the switch state is On ?
And when the Switch is Off the last On value keeps in IDX 3
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Analog measurement
This script is triggered on any update to the voltage sensor with IDX 2 and copy the voltage value to (virtual) voltage sensor with IDX 3 when Switch is On and values in the voltage sensors are not already equal.Knibor wrote: Saturday 27 October 2018 12:42 I want copy the value from 2 to 3 every x seconds for as long as the switch state is On ?
And when the Switch is Off the last On value keeps in IDX 3
Code: Select all
-- voltageCopy
return {
on = { devices = { 2 }}, -- Master voltage sensor
logging = { level = domoticz.LOG_DEBUG, -- commment these 2 lines when script execute without any issues
marker = "voltageCopy" },
execute = function(dz, item) -- item is the Master voltage sensot
local slaveVoltageSensor = dz.devices(3)
local voltageCopySwitch = dz.devices(1)
if voltageCopySwitch.state == "On" then
if slaveVoltageSensor.voltage ~= item.voltage then
dz.log("Script is triggered by " .. item.name .. "; new voltage (" .. item.voltage .. ") will be copied to " .. slave.name,dz.LOG_DEBUG)
slaveVoltageSensor.updateVoltage(item.voltage) - the actual copy
else
dz.log("Script is triggered by " .. item.name .. "; voltage (" .. item.voltage .. ") will NOT be copied to " .. slave.name .. "(voltages are equal)",dz.LOG_DEBUG)
end
else
dz.log("Script is triggered by " .. item.name .. "; voltage (" .. item.voltage .. ") will NOT be copied to " .. slave.name .. "(control switch is Off)",dz.LOG_DEBUG)
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
-
Knibor
- Posts: 112
- Joined: Sunday 20 May 2018 12:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: Analog measurement
Hi, thanks for the code.
I tried this code with the actual IDX from my Domoticz system, but until now no succes.
Domoticz says there is an Error in line ...slaveVoltageSensor.updateVoltage(item.voltage) - the actual copy
I tried to delete this part. The error was gone but, I don't know should i delete this part? When I delete this part, still no succes.
Here is my actual code
I tried this code with the actual IDX from my Domoticz system, but until now no succes.
Domoticz says there is an Error in line ...slaveVoltageSensor.updateVoltage(item.voltage) - the actual copy
I tried to delete this part. The error was gone but, I don't know should i delete this part? When I delete this part, still no succes.
Here is my actual code
- Attachments
-
- Schermafbeelding 2018-10-27 om 16.26.57.png (320.7 KiB) Viewed 827 times
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Analog measurement
the part "- the actual copy" is missing 1 "-"Knibor wrote: Saturday 27 October 2018 16:27 Domoticz says there is an Error in line ...slaveVoltageSensor.updateVoltage(item.voltage) - the actual copy
I tried to delete this part. The error was gone but, I don't know should i delete this part? When I delete this part, still no succes.
the line should have been
Code: Select all
slaveVoltageSensor.updateVoltage(item.voltage) -- the actual copy To be complete I post the corrected script.
Code: Select all
-- voltageCopy
return {
on = { devices = { 2 }}, -- Master voltage sensor
logging = { level = domoticz.LOG_DEBUG, -- commment these 2 lines when script execute without any issues
marker = "voltageCopy" },
execute = function(dz, item) -- item is the Master voltage sensot
local slaveVoltageSensor = dz.devices(3)
local voltageCopySwitch = dz.devices(1)
if voltageCopySwitch.state == "On" then
if slaveVoltageSensor.voltage ~= item.voltage then
dz.log("Script is triggered by " .. item.name .. "; new voltage (" .. item.voltage .. ") will be copied to " .. slave.name,dz.LOG_DEBUG)
slaveVoltageSensor.updateVoltage(item.voltage) -- the actual copy
else
dz.log("Script is triggered by " .. item.name .. "; voltage (" .. item.voltage .. ") will NOT be copied to " .. slave.name .. "(voltages are equal)",dz.LOG_DEBUG)
end
else
dz.log("Script is triggered by " .. item.name .. "; voltage (" .. item.voltage .. ") will NOT be copied to " .. slave.name .. "(control switch is Off)",dz.LOG_DEBUG)
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
-
Knibor
- Posts: 112
- Joined: Sunday 20 May 2018 12:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: Analog measurement
Hi,
I tried this latest code with a fresh installed Domoticz, so only this code and the new IDX
IDX 14 is the master voltage sensor, were I can read now the value 80.
IDX 13 is the slave sensor, and I read now the value "0".
IDX 15 is the voltage Switch and I with it on and off serval times. Also tried when the switch is on change the value off IDX 14 master voltage.
But no copy from IDX 14 to IDX15.
Do I something wrong?
Here is my log
I tried this latest code with a fresh installed Domoticz, so only this code and the new IDX
IDX 14 is the master voltage sensor, were I can read now the value 80.
IDX 13 is the slave sensor, and I read now the value "0".
IDX 15 is the voltage Switch and I with it on and off serval times. Also tried when the switch is on change the value off IDX 14 master voltage.
But no copy from IDX 14 to IDX15.
Do I something wrong?
Here is my log
- Attachments
-
- Schermafbeelding 2018-10-27 om 20.12.55.png (34.94 KiB) Viewed 799 times
-
- Schermafbeelding 2018-10-27 om 20.12.27.png (62.5 KiB) Viewed 799 times
-
- Schermafbeelding 2018-10-27 om 20.11.45.png (390.75 KiB) Viewed 799 times
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Analog measurement
As you described it, the copy should go from 14 to 13Knibor wrote: Saturday 27 October 2018 20:14 Hi,
I tried this latest code with a fresh installed Domoticz, so only this code and the new IDX
IDX 14 is the master voltage sensor, were I can read now the value 80.
IDX 13 is the slave sensor, and I read now the value "0".
IDX 15 is the voltage Switch and I with it on and off serval times. Also tried when the switch is on change the value off IDX 14 master voltage.
But no copy from IDX 14 to IDX15.
Do I something wrong?
Here is my log
Can you show the script how it is now and at least show the log with the debug lines of the script? Preferable in textformat within "[ code]" "[ \code]" tags
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
-
Knibor
- Posts: 112
- Joined: Sunday 20 May 2018 12:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: NL
- Contact:
Re: Analog measurement
Hi, it works now
I don't now why? I only changed the file name from the script from Sample/Hold to SampleHold.
Suddenly it works!
Thank you very much for the support.
I have made a battery cell monitor. It reads the battery voltage value with Espeasy mini D1and send it (wireless) to Domoticz. The Espeasy is connected with a multiplexer and can measure 16 channels.
I send with Domotics a binary code for battery cell 1(switch) to cell 13 with an interval of 15 seconds. So when Cell 1 is measured it will go to this Sample/Hold script.....and so on until to cell 13. Now I can use 13 voltage indicators in Domoticz with the actual value.
Robin
I don't now why? I only changed the file name from the script from Sample/Hold to SampleHold.
Suddenly it works!
Thank you very much for the support.
I have made a battery cell monitor. It reads the battery voltage value with Espeasy mini D1and send it (wireless) to Domoticz. The Espeasy is connected with a multiplexer and can measure 16 channels.
I send with Domotics a binary code for battery cell 1(switch) to cell 13 with an interval of 15 seconds. So when Cell 1 is measured it will go to this Sample/Hold script.....and so on until to cell 13. Now I can use 13 voltage indicators in Domoticz with the actual value.
Robin
Who is online
Users browsing this forum: No registered users and 1 guest