Create a Voltage sensor from utility to dummy
Moderator: leecollings
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Create a Voltage sensor from utility to dummy
Hello.. i need to create a (Dummy) voltage sensor from utility sensor to correct value
lets say i get a value on the utility sensor of 120 (or whatever it is) and send that to dummy sensor as 23V and value 121 (or whatever) as 23.5v
and so on...
someone that can help me with a script?
lets say i get a value on the utility sensor of 120 (or whatever it is) and send that to dummy sensor as 23V and value 121 (or whatever) as 23.5v
and so on...
someone that can help me with a script?
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
Here you have an example of something similar https://domoticz.com/forum/viewtopic.php?t=33414
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
hi.. thanks..
something similar.. but i dont want 120 to be 120v or 0 (value of utility) to be 0 V
im going to measure a battery voltage range of like 22v to 27v dc..
lets say utility sensor say 120 and that is the same as 22v and 240 (ut sensor) 27V
something similar.. but i dont want 120 to be 120v or 0 (value of utility) to be 0 V
im going to measure a battery voltage range of like 22v to 27v dc..
lets say utility sensor say 120 and that is the same as 22v and 240 (ut sensor) 27V
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
With dzvents scripting you can convert values as long as you have a formula.
And if you use some kind of self made sensor there are perhaps possibilities to already have the sensor sending real values.
And if you use some kind of self made sensor there are perhaps possibilities to already have the sensor sending real values.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
im using denkovi hardware but as i wrote i just get a X value that corresponds to Y volt
so it is a script im looking for to implement/Correct the values from utility sensor to a dummy in volts
its the script and formula i want
so it is a script im looking for to implement/Correct the values from utility sensor to a dummy in volts
its the script and formula i want

-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
I have this script for a percentage sensor that will work very good but it would be nice to show actually volts instead..
Code: Select all
return {
on = {
devices = {
'Tank'
},
},
logging = {
level = domoticz.LOG_INFO,
marker = "Converter"
},
execute = function(dz, item)
local inverted = true -- if max value of sensor should be reflected in 0% and minValue in 100%
local dataFromAin8 = item.rawData[1]
local maxValue = 194
local minValue = 44
local decimals = 2
local percentage = ( dataFromAin8 - minValue ) / ( maxValue - minValue ) * 100
if inverted then
percentage = 100 - percentage
end
local roundedPercentage = dz.utils.round(percentage,decimals )
local percentageDevice = dz.devices('Vatten')
dz.log("Rounded percentage is " .. roundedPercentage .. "%")
percentageDevice.updatePercentage(roundedPercentage)
end
}
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
Then you have to create a dummy voltage sensor and rewrite the script so it updates this voltage sensor with the correct values.
Check the Dzvents documentation how to update a voltage sensor. https://www.domoticz.com/wiki/DzVents:_ ... ng#Voltage
For using a formula search Google for Lua examples (dzvents is a layer over the programming language Lua) for example https://www.lua.org/pil/3.1.html#:~:tex ... entiation).
Check the Dzvents documentation how to update a voltage sensor. https://www.domoticz.com/wiki/DzVents:_ ... ng#Voltage
For using a formula search Google for Lua examples (dzvents is a layer over the programming language Lua) for example https://www.lua.org/pil/3.1.html#:~:tex ... entiation).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
Thanks.. but my level of knowledge is to edit values in finnished scrips, i dont think i can manage to make my own script..
I was hoping someone else had a similar setup..
I was hoping someone else had a similar setup..
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
Here are other scripts that will need some small changes for your use case: viewtopic.php?t=33116
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 395
- Joined: Sunday 03 July 2016 16:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.7
- Location: Netherlands
- Contact:
Re: Create a Voltage sensor from utility to dummy
@Tarzan
Try learning dzVents. Yes... in the beginning it's very difficult but by figuring out excisting scripts you definitly get the skills. Then, if your self written script does not do what you want many people around here are helpfull for you.
Just begin with a very simple script.
Try learning dzVents. Yes... in the beginning it's very difficult but by figuring out excisting scripts you definitly get the skills. Then, if your self written script does not do what you want many people around here are helpfull for you.
Just begin with a very simple script.
Raspberry pi 3b
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
Arduino
KAKU
RfxCom
Zwave2MQTT
OTGW
Chinese sensors temp (Dallas),movement
Tasmota
Esp8266 / 32 espeasy
Zigbee2MQTT
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
i have tried some days now to edit scrips and so on.. i cant get it to work..
can someone give me an exampe of a script just to copy the same info from a utility sensor
to a dummy voltage sensor..
i tried something like this (plus a lot of others with no result)
lets say the utility sensor have the name of Batt and the dummy voltage sensor is Test
can someone give me an exampe of a script just to copy the same info from a utility sensor
to a dummy voltage sensor..
i tried something like this (plus a lot of others with no result)
Code: Select all
return
{
on =
{
devices =
{
'Batt' -- change to name of voltage device
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script executes without issues
marker = 'voltage',
},
execute = function(dz, item)
local Sensor = item.rawData[1]
local voltageDevice = dz.devices('Test') -- change to name of Custom Sensor for windspeed.
local voltage = dataFromAin8
end
}
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
I do not know what you took as a base but the script from this topic should be a good base for you. viewtopic.php?p=287065#p287065
Check the Dzvents documentation for the specific commands to read and update your device. They are different for each device type.
Check the Dzvents documentation for the specific commands to read and update your device. They are different for each device type.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
ok so i tried to use that as base and now my dummy device is updating in time and i can se in log that its reading values from
my device as well.. but no values are updating in custom volt device still 0v
this is how the script looks like now..
my device as well.. but no values are updating in custom volt device still 0v
this is how the script looks like now..
Code: Select all
return
{
on =
{
devices =
{
'Batt' -- change to name of voltage device
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script executes without issues
marker = 'volt',
},
execute = function(dz, item)
local VoltageDevice = dz.devices('Volt') -- change to name of Custom Sensor for windspeed.
local decimals = 2
local measuredVoltage = item.rawData[1]
local Voltage = dz.utils.round(measuredVoltage)
local roundedVoltage = dz.utils.round(measuredVoltage,decimals )
dz.log('Voltage = ' .. Voltage, dz.LOG_DEBUG)
VoltageDevice.updateVoltage(voltage)
end
}
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
double
Last edited by waltervl on Thursday 12 October 2023 9:44, edited 1 time in total.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
Dzvents is case sensitive so voltage should be Voltage in
And
Code: Select all
VoltageDevice.updateVoltage(Voltage)
Code: Select all
local measuredVoltage = item.voltage
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
ohh so stupid i feel now.. i have been watching this so many times but not really good in this.. but thanks (very much) it is working now..
now i want something like
if u know what i mean?
so i can convert different values to correct voltage.. but i cant really find out how to write.. not even with dzwents manual..
now i want something like
Code: Select all
if measuredVoltage > 500 then voltage 27 end
so i can convert different values to correct voltage.. but i cant really find out how to write.. not even with dzwents manual..
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
I believe this will work
This is all standard Lua so search Google with your question for if then Lua and you will find examples.
I see you have measuredvoltage, roundedvoltage and voltage. That also seems 1 too many.
Code: Select all
if measuredVoltage > 500 then Voltage=27 end
I see you have measuredvoltage, roundedvoltage and voltage. That also seems 1 too many.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
hello..
i did try that to.. but i get unable to compare number with string in that line in the log..
i did try that to.. but i get unable to compare number with string in that line in the log..
- waltervl
- Posts: 5859
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Create a Voltage sensor from utility to dummy
Then you need to convert the number into a string for logging eg
Code: Select all
dz.log('Voltage = ' .. tostring(Voltage), dz.LOG_DEBUG)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 60
- Joined: Friday 01 June 2018 20:32
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Create a Voltage sensor from utility to dummy
ok. so probably its other stuff i need to change now with string values? since i get the same error in log.. Dont i think i manage to do this
right now..
anyway this is the last code i have if someone see anything obvious that i do wrong
right now..
anyway this is the last code i have if someone see anything obvious that i do wrong
Code: Select all
return
{
on =
{
devices =
{
'Batt' -- change to name of voltage device
}
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script executes without issues
marker = 'volt',
},
execute = function(dz, item)
local VoltageDevice = dz.devices('Volt') -- change to name of Custom Sensor for voltage.
local decimals = 2
local measuredVoltage = item.rawData[1]
local Voltage = measuredVoltage
if measuredVoltage > 450 then Voltage=27 end
dz.log('Voltage = ' .. tostring(Voltage), dz.LOG_DEBUG)
VoltageDevice.updateVoltage(Voltage)
end
}
Who is online
Users browsing this forum: No registered users and 1 guest