Add sum of two dewices in to another total sum device

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
McLund
Posts: 9
Joined: Monday 28 December 2020 16:29
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Add sum of two dewices in to another total sum device

Post by McLund »

Hi.

I have a heat pump from which I receive many measurement values ​​via MQTT to Domoticz, including device (336) "5C54 Compr. consump. tot" and device (339) "5C57 Aux consumption tot".

Now, I want to add these two MQTT devices (336) 5C54 + (339) 5C57 and display the total sum in device TotalActual (342) as it looks in red ring 1 and 2 in device (336) and (339).

Everything in the script works but I do not see the result in kWh in device TotalActual (342) at yellow ring 4 as it appears in device (339) at red ring 2 and (336) at red ring 1 where the sum for today is displayed on row two.

Additionally, I can only see Watt value in TotalActual (342) at yellow ring 3, but no value is displayed in the graphs for device TotalActual (342). I want to see value in device TotalActual (342) as it looks in device (336) 5C54 and device (339) 5C57.

I would be grateful if someone could help me and show what I do wrong in the script.


Thank you for all help! ;-)


Best regard's
McLund

Code: Select all

return {

on = {
timer = { 'every 5 minutes' }
},

execute = function(domoticz, item)
local Husdata_5C54 = domoticz.devices(336).WhToday -- = Husdata "5C54 Compr. consump. tot" via MQTT - use WhToday?
local Husdata_5C57 = domoticz.devices(339).WhToday -- = Husdata "5C57 Aux consumption tot" via MQTT - use WhToday?
local TotalActual = Husdata_5C54 + Husdata_5C57

domoticz.devices(342).updateElectricity(TotalActual)

end

}

2024-04-22_21-10-21_75.png
2024-04-22_21-10-21_75.png (75.89 KiB) Viewed 548 times
2024-04-22_21-19-51_50.png
2024-04-22_21-19-51_50.png (19.41 KiB) Viewed 548 times
2024-04-22_21-25-41_50.png
2024-04-22_21-25-41_50.png (108.29 KiB) Viewed 548 times
User avatar
waltervl
Posts: 5851
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Add sum of two dewices in to another total sum device

Post by waltervl »

If you only need total whtoday you have to make device 342 a custom sensor and not a electricity device.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest