HomeWizard Battery plugin

Python and python framework

Moderator: leecollings

mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

HomeWizard Battery plugin

Post by mvdp »

I've just created a python plugin for the HomeWizard Battery at https://github.com/etmmvdp/HomeWizard-B ... /tree/main.

See the readme for details how to create a token which is required to run the plugin.
Let me know in case of questions and improvements.
hbennis
Posts: 9
Joined: Friday 29 September 2017 0:50
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HomeWizard Battery plugin

Post by hbennis »

great work
assp22
Posts: 1
Joined: Thursday 20 March 2025 17:03
Target OS: Linux
Domoticz version: 2024.7
Contact:

Re: HomeWizard Battery plugin

Post by assp22 »

thanks, but the totals in the overview are missing
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

assp22 wrote: Thursday 20 March 2025 17:13 thanks, but the totals in the overview are missing
Thanks for the feedback.
Which totals are you referring too? Which counter do you recommend?
User avatar
gizmocuz
Posts: 2488
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: HomeWizard Battery plugin

Post by gizmocuz »

Why did you use a P1 smart meter? This is a battery device
You should use generic kWh meters for the totals
Quality outlives Quantity!
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 9:24 Why did you use a P1 smart meter? This is a battery device
You should use generic kWh meters for the totals
Yeah, I know the P1 might be seen as a strange design choice. However, the generic kWh meter does not show import and export as separate values, while the P1 meter does.
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 9:24 Why did you use a P1 smart meter? This is a battery device
You should use generic kWh meters for the totals
I fixed a bug, the totals were not showing as they were added as kWh values instead of Wh values.
The counter documentation for device 243, subtype 29 is imho incorrect in that regard. See https://wiki.domoticz.com/Developing_a_ ... in#Devices
User avatar
gizmocuz
Posts: 2488
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: HomeWizard Battery plugin

Post by gizmocuz »

I think our documentation is pretty accurate as many are using it, but you could be right, but what is wrong with it?

You can create (or actually should) two kWh sensors and use these for the totals of the imported/exported enery/power

This way, you can also use them on the Energy Dashboard

Of course, you can create a dzVents script if you like to still make a P1 meter, but I don't think this should be the default, because... well it just is not a P1 meter

You could make it an option the user can turn on/off maybe? (Simulate a P1 Smart Meter)
But still use two kWh sensors for the totals
Quality outlives Quantity!
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 10:24 I think our documentation is pretty accurate as many are using it, but you could be right, but what is wrong with it?
Let's focus on the documentation first, I'll address the P1 meter in a separate answer.

The comment on device type 243, subtype 33 says: "The first number is the actual power in Watt, the second number is actual energy in kWh"
But the second number should be in Wh. This is documented on the P1 meter correctly, a bit further down on the the page.
User avatar
gizmocuz
Posts: 2488
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: HomeWizard Battery plugin

Post by gizmocuz »

Hmm strange as I read

for instance "123456;78", 123456 being the absolute counter value, 78 being the usage (Wh).
Quality outlives Quantity!
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 10:24 ...
You can create (or actually should) two kWh sensors and use these for the totals of the imported/exported enery/power

This way, you can also use them on the Energy Dashboard

Of course, you can create a dzVents script if you like to still make a P1 meter, but I don't think this should be the default, because... well it just is not a P1 meter

You could make it an option the user can turn on/off maybe? (Simulate a P1 Smart Meter)
But still use two kWh sensors for the totals
The kWh meter "Active Power" is showing the netted import and export energy usage, as wel as it's current power consumption.
I'll like the simulated P1 meter option so I'll make that change.
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 10:40 Hmm strange as I read

for instance "123456;78", 123456 being the absolute counter value, 78 being the usage (Wh).
.
With close reading I can now see that I should have interpreted the first kWh mentioned as Wh.
Last edited by mvdp on Friday 21 March 2025 11:00, edited 2 times in total.
User avatar
gizmocuz
Posts: 2488
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: HomeWizard Battery plugin

Post by gizmocuz »

For almost all (counter) sensors, the first value is the counter, and the second is the usage
So, the documentation is OK? (I did not create the documentation, but it looks OK to me programming wise :mrgreen: )
Quality outlives Quantity!
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

gizmocuz wrote: Friday 21 March 2025 10:48 So, the documentation is OK? (I did not create the documentation, but it looks OK to me programming wise :mrgreen: )
I think it would be even better when the kWh unit in the text is rephrased to Wh.
tiga
Posts: 159
Joined: Friday 27 May 2016 20:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: nederland
Contact:

Re: HomeWizard Battery plugin

Post by tiga »

just preordered a battery coming in juli and this is what i was looking for!!

great work!!thank you!
JanJaap
Posts: 210
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: HomeWizard Battery plugin

Post by JanJaap »

Gizmocuz I wonder about the comments. I am maintaining the plugin for the Sessy battery and created both Energy and P1 meter. The energy indeed for the energy dashboard but I like the overview on the P1 meter better:
Schermafbeelding 2025-03-22 201823.png
Schermafbeelding 2025-03-22 201823.png (25.41 KiB) Viewed 991 times
As it states the consumed and provided energy per day.

Why do you recommend a separate meter for both consumed and provided energy?
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
gizmocuz
Posts: 2488
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: HomeWizard Battery plugin

Post by gizmocuz »

Well basically as it was not designed for this.

Let's say you have a normal (Dutch?) energy contract, with Piek/Dal tariffs, in the P1 meter report you can see this.

In your case, you don't want to see the two tariffs, you can set the P1 meter in simple mode in the settings.
But this also influences the real P1 meter device.

Maybe if we renamed the P1 smart meter to 'smart meter' and have the option to use 1 or 2 tariffs, it would make better sense

I understand the graphs are nicer and you get a better overview when you have a device that does consumption and delivery
Quality outlives Quantity!
mvdp
Posts: 15
Joined: Sunday 07 October 2018 17:21
Target OS: Linux
Domoticz version: 2025.1
Location: Bollenstreek
Contact:

Re: HomeWizard Battery plugin

Post by mvdp »

Instead of using the P1 device we should add a (Home) Battery device which is providing P1 device like features except for keeping costs and providing 1 set of import and export counters only.
Especially for the HomeWizard Battery there should be no cost involved as it only charges using solar power.
rini52
Posts: 38
Joined: Friday 10 June 2022 23:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: NL
Contact:

Re: HomeWizard Battery plugin

Post by rini52 »

This is really great stuff. I just received 3 batteries and they work great as they were designed. However the p1-senseor is not selectable from the energy dashboard the "active power" sensor is. This sensor shows the Import-Export power of the battery. Since I had 3 batteries i had to sum them and put the result in a "usage electricity" sensor. Similar for the percentage(SOC) sensors. They can both be used in the Energy Dashboard"

Below the lua code for those that are interested:

-->
return {
on = {
timer = {
'every minute' -- causes the script to be called every minute
}
},
logging = {
level = domoticz.LOG_INFO,
marker = 'HWZ_plugin_total',
},
execute = function(domoticz, device, timer)

-- domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
local battery1Value = domoticz.devices(199).actualWatt
local battery2Value = domoticz.devices(207).actualWatt
local battery3Value = domoticz.devices(215).actualWatt
local battery1Percentage = domoticz.devices(203).percentage
local battery2Percentage = domoticz.devices(211).percentage
local battery3Percentage = domoticz.devices(219).percentage
-- local battery2Value = 22
-- domoticz.log('Device Precentage found ' .. battery1Percentage .. ' (%)' , domoticz.LOG_INFO)
local totalValue = battery1Value + battery2Value + battery3Value
local totalPercentage = domoticz.utils.round( (battery1Percentage + battery2Percentage + battery3Percentage) / 3 )
domoticz.log('Overal Precentage found ' .. totalPercentage .. ' (%)' , domoticz.LOG_INFO)
-- Set the value on a dummy sensor
-- local totalValue = 1
domoticz.devices('HWZ_PlugBat_Total').updateEnergy(totalValue)
domoticz.devices('HWZ_PlugBat_TSOC').updatePercentage(totalPercentage)
end
}
--<
Attachments
Device_list.png
Device_list.png (327.77 KiB) Viewed 257 times
Devices.png
Devices.png (209.33 KiB) Viewed 257 times
Energy_board.png
Energy_board.png (100.02 KiB) Viewed 257 times
Domoticz running on Pi-4, Ubuntu(amd64), Synology Nas and VM
Hardware: RFXCOM, RFLINK, P1-smartmeter-HomeWizard, Z2M Sonoff dongle(20+ devices), Esp8266 (counters), Eaton_3S ups
JanJaap
Posts: 210
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: HomeWizard Battery plugin

Post by JanJaap »

Hey,

In my plugin for Sessy batteries I create an additional device that combines the data of the individual batteries (and also allows to set modes and power setpoints for the set). For the combined batteries to appear on the dashboard correctly it needs a device of type:
Type=243, Subtype=29
or:
type: General, Subtype: kWh
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest