How to do a simple calculation P=U*I [Solved]
Moderator: leecollings
- Thuis
- Posts: 273
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
How to do a simple calculation P=U*I
Hello, i try to calculate P=U*I, or Idx95*Idx1417=Idx1714 in W or kW.
But i do not seem to get this simple P=U*I to input in a style that dzvents wants.
And i know this is not correct i have the cos phi of the device the blind and the real power bla bla, but i just want the simplest calculation to work. P=U*I
Could someone give me an example of how i can do this in the most simple way in dzvents, or lua is also fine. P=U*I
Thanks in advance.
But i do not seem to get this simple P=U*I to input in a style that dzvents wants.
And i know this is not correct i have the cos phi of the device the blind and the real power bla bla, but i just want the simplest calculation to work. P=U*I
Could someone give me an example of how i can do this in the most simple way in dzvents, or lua is also fine. P=U*I
Thanks in advance.
I Love Domoticz ! And the community around it :-)
- gizmocuz
- Posts: 2551
- Joined: Thursday 11 July 2013 18:59
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Top of the world
- Contact:
Re: How to do a simple calculation P=U*I
Can you post your dzVents script here?
Sure you can get the value of a Ampere and voltage sensor, and just multiply them and write the value to the console?
Sure you can get the value of a Ampere and voltage sensor, and just multiply them and write the value to the console?
Quality outlives Quantity!
- Thuis
- Posts: 273
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: How to do a simple calculation P=U*I
I probably think too simple...
I see no errors in the log also the kwh device stays on zero kwh, perhaps im using wrong device to put the value in? No clue.
Code: Select all
return {
on = {
timer = {'every 5 seconds'}
},
execute = function(dz)
local spanning = dz.devices('Voltage') -- Voltage from p1 meter
local stroom = dz.devices('Onshuis_AC - Stroom opname') -- Opname AC via esp AC
local value = dz.devices('Verbruik MHI Airco') -- Virtuele kwh meter
value = (spanning * stroom)
end
}
I Love Domoticz ! And the community around it :-)
- Thuis
- Posts: 273
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: How to do a simple calculation P=U*I
And ofcourse im reading https://www.domoticz.com/wiki/DzVents:_ ... _scripting but there are lots of calculations about averages, medians, max, min, sum and delta's but no multiply.
I Love Domoticz ! And the community around it :-)
- waltervl
- Posts: 5893
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: How to do a simple calculation P=U*I
dzvents is built on lua so standard arithmic operators apply https://www.lua.org/pil/3.1.html
But to update a kwh device you have to use
https://www.domoticz.com/wiki/DzVents:_ ... tric_usage
But to update a kwh device you have to use
Code: Select all
dz.devices('Verbruik MHI Airco').updateEnergy(spanning * stroom)
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
- Thuis
- Posts: 273
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: How to do a simple calculation P=U*I
updateEnergy(energy) Aha.
Ok im doing it wrong its not updating, no errors in log, but ill keep on trying.
Thanks for the steering me in a direction
Ok im doing it wrong its not updating, no errors in log, but ill keep on trying.
Thanks for the steering me in a direction

I Love Domoticz ! And the community around it :-)
- waltervl
- Posts: 5893
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: How to do a simple calculation P=U*I
What you were doing ( value = (spanning * stroom) ) is from a scripting point of view not wrong only it is not doing anything with the device..... That is why you did not get an error.
You never can change a domoticz device with only setting a value. You always have to use a function.
You never can change a domoticz device with only setting a value. You always have to use a function.
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
- RonkA
- Posts: 115
- Joined: Tuesday 14 June 2022 12:57
- Target OS: NAS (Synology & others)
- Domoticz version: 2025.1
- Location: Harlingen
- Contact:
Re: How to do a simple calculation P=U*I
Dont you read your private messages?
SolarEdge ModbusTCP - Kaku - Synology NAS - Watermeter - ESPEasy - DS18b20
Work in progress = Life in general..
Work in progress = Life in general..
-
- Posts: 577
- Joined: Monday 20 March 2023 14:41
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Somewhere in NL
- Contact:
Re: How to do a simple calculation P=U*I
You also have to use
Code: Select all
execute = function(dz)
local spanning = dz.devices('Voltage').voltage -- Voltage from p1 meter
local stroom = dz.devices('Onshuis_AC - Stroom opname').current -- Opname AC via esp AC
Logic will get you from A to B. Imagination will take you everywhere.
- Thuis
- Posts: 273
- Joined: Tuesday 11 September 2018 11:36
- Target OS: Linux
- Domoticz version: Beta
- Location: The Netherlands
- Contact:
Re: How to do a simple calculation P=U*I [Solved]
I Love Domoticz ! And the community around it :-)
Who is online
Users browsing this forum: No registered users and 1 guest