HomeWizard Battery plugin
Moderator: leecollings
-
rini52
- Posts: 44
- Joined: Friday 10 June 2022 23:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.2
- Location: NL
- Contact:
Re: HomeWizard Battery plugin
thanks,
That is the type that is created by the HomeWizard Battery plugin and is called "Active Power" and possible to include in the Electricity Dashboard.
But no possibility to include more than one battery per hardware integration. So you have to do combine them in one single hardware setup,as you did apparently. But that needs a mayor update of the plugin with some extra token/ip settings. Therefor I just combine them with a dzventz script. I used a "usage electric" sensor but apparently I could have better use a "general kwh" dummy sensor.
Regards,
That is the type that is created by the HomeWizard Battery plugin and is called "Active Power" and possible to include in the Electricity Dashboard.
But no possibility to include more than one battery per hardware integration. So you have to do combine them in one single hardware setup,as you did apparently. But that needs a mayor update of the plugin with some extra token/ip settings. Therefor I just combine them with a dzventz script. I used a "usage electric" sensor but apparently I could have better use a "general kwh" dummy sensor.
Regards,
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
Hardware: RFXCOM, RFLINK, P1-smartmeter-HomeWizard, Z2M Sonoff dongle(20+ devices), Esp8266 (counters), Eaton_3S ups
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
Thanks for the feedback. I will mention in README.md that one can combine multiple batteries using some additional event handling code. I don't feel like combining multiple batteries together with the plugin.rini52 wrote: Friday 23 May 2025 11:47 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"
I myself have 2 batteries and I just configured them in domoticz as 2 separate hardware devices. And indeed I'm using a dummy device to sum the actual power together using some lua scripting. A similar script runs when the SOC of a battery changes to provide the overal SOC value.
Code: Select all
return
{
on =
{
devices = {1827, 1828}
},
execute = function(domoticz, item)
local battery1Power = domoticz.devices(1827) -- Battery set 1, existing General kwh device
local battery2Power = domoticz.devices(1828) -- Battery set 2, existing General kwh device
-- Create manually a dummy kWh, Electricity (instant and counter) device in generation mode
local totalPower = domoticz.devices(1813) -- Total, to be used in Energy dashboard configuration
totalPower.updateElectricity(
battery1Power.actualWatt + battery2Power.actualWatt,
battery1Power.WhTotal + battery2Power.WhTotal)
end
}
-
WilcoEHV
- Posts: 24
- Joined: Monday 02 January 2023 15:52
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.1
- Location: Eindhoven
- Contact:
Re: HomeWizard Battery plugin
Hi,
Great work.
I have a HW battery and i want to include it into Domoticz.
Although i'm an Domoticz enthusiast since 2017 i'n not femilliar with scripting.
Can someone guide me through setting up this plugin?
PS; I've considered following a course scripting before, any suggestions on where to start are welcome!
Great work.
I have a HW battery and i want to include it into Domoticz.
Although i'm an Domoticz enthusiast since 2017 i'n not femilliar with scripting.
Can someone guide me through setting up this plugin?
PS; I've considered following a course scripting before, any suggestions on where to start are welcome!
Raspberry 3B with Raspberry PI OS
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
Good news, with 1 battery there is no need for scripting.
To install the python plugin see this wiki page: https://wiki.domoticz.com/Using_Python_plugins
Consider using the domoticz python plugin manager, as that takes the burden away from the git checkout. To be honest, I have not used the plugin manager plugin. See https://wiki.domoticz.com/Python_Plugin_Manager
Read the readme.md of the battery plugin to get a token needed to communicate with it.
Let me know in case of questions.
-
rini52
- Posts: 44
- Joined: Friday 10 June 2022 23:19
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2025.2
- Location: NL
- Contact:
Re: HomeWizard Battery plugin
Thanks for the example.
Attached I included tthe percentage as well.
Regards
Attached I included tthe percentage as well.
Regards
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
Hardware: RFXCOM, RFLINK, P1-smartmeter-HomeWizard, Z2M Sonoff dongle(20+ devices), Esp8266 (counters), Eaton_3S ups
-
zanco
- Posts: 16
- Joined: Monday 04 January 2016 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HomeWizard Battery plugin
Thanks for your work. It works nicely, added 2 homewizzard batteries to my domoticz.
Yesterday I reworked my internal network after being forced to a double router system by my fiber company delivering a modem / router with no bridge mode possible. So yesterday I moved the Asus router to AP mode and had all my IP addresses moved to another range. The hardware setup to change the battery and P1 IP addresses are easy.
It took me however a few hours and a good night sleep AND your readme.md to get the clue why the batteries did not report since yesterday afternoon. The token generated is based on the original IP adress so I have generated 2 new tokens which I changed in the settings and all is OK now.
One little remark: excecuting the scripts for detect require me to type python3 scriptname.py instead of python (which is python2.7 on my system)
Just in case someone runs into the same problem.
Thanks again,
Ben
Yesterday I reworked my internal network after being forced to a double router system by my fiber company delivering a modem / router with no bridge mode possible. So yesterday I moved the Asus router to AP mode and had all my IP addresses moved to another range. The hardware setup to change the battery and P1 IP addresses are easy.
It took me however a few hours and a good night sleep AND your readme.md to get the clue why the batteries did not report since yesterday afternoon. The token generated is based on the original IP adress so I have generated 2 new tokens which I changed in the settings and all is OK now.
One little remark: excecuting the scripts for detect require me to type python3 scriptname.py instead of python (which is python2.7 on my system)
Just in case someone runs into the same problem.
Thanks again,
Ben
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
Thank you for the suggestion of using python3 instead of python. I’ve changed it in the readme and code.
-
DomoFlits
- Posts: 45
- Joined: Thursday 06 October 2016 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Bld16583
- Location: The Netherlands
- Contact:
Re: HomeWizard Battery plugin
Thank you for creating the plugin.
Is it possible to add a mode command / readout to the plugin as described in: https://api-documentation.homewizard.co ... /batteries
It can be used to send a "to_full" command to the battery when electricity price is =<€0 and a "zero" command when the price is >€0.
Both are momentary commands. Once the to_full command is sent, the battery will charge itself to full, and then atomatically goes back into "zero" mode.
or should this better be done with a script?
in that case, could someone guide me how to implement and use this described script from Homewizard?
will this be a function like this in Dzvents:
I'm not sure about the syntaxis and how to handle the insecure as well as the response.
I assume now that the <IP ADDRESS> is the IP address of the P1 and not the battery and I'll also need a token from the P1 (due to this information: https://gathering.tweakers.net/forum/li ... 2#82340672)
If it is indeed arranged via the P1 it might not be logic to have this in the battery plugin since the plugin needs to have the P1 address and the P1 token, which gets confusing on the hardware page.
Is it possible to add a mode command / readout to the plugin as described in: https://api-documentation.homewizard.co ... /batteries
It can be used to send a "to_full" command to the battery when electricity price is =<€0 and a "zero" command when the price is >€0.
Both are momentary commands. Once the to_full command is sent, the battery will charge itself to full, and then atomatically goes back into "zero" mode.
or should this better be done with a script?
in that case, could someone guide me how to implement and use this described script from Homewizard?
Code: Select all
curl https://<IP ADDRESS>/api/batteries \
--insecure \
-X PUT \
-H "Authorization: Bearer <TOKEN>" \
-H "X-Api-Version: 2" \
-d '{"mode": "to_full"}'
Code: Select all
return {
on = { ... }, -- some trigger
execute = function(domoticz)
domoticz.openURL({
url = 'https://<IP ADDRESS>/api/batteries',
method = 'PUT',
headers = {
['Authorisation'] = 'Bearer <TOKEN>',
['X-Api-Version'] = '2'
},
postData = '{"mode": "to_full"}'
})
end
}
I assume now that the <IP ADDRESS> is the IP address of the P1 and not the battery and I'll also need a token from the P1 (due to this information: https://gathering.tweakers.net/forum/li ... 2#82340672)
If it is indeed arranged via the P1 it might not be logic to have this in the battery plugin since the plugin needs to have the P1 address and the P1 token, which gets confusing on the hardware page.
Last edited by DomoFlits on Friday 12 September 2025 17:51, edited 1 time in total.
-
rene2716
- Posts: 21
- Joined: Friday 04 May 2018 11:53
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: HomeWizard Battery plugin
Hi when i try tp do
pip install -r requirements.txt
i get
error: externally-managed-environment
any idea whhere this comes from ?
pip install -r requirements.txt
i get
error: externally-managed-environment
any idea whhere this comes from ?
- waltervl
- Posts: 6677
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: HomeWizard Battery plugin
It is coming from recent linux distributions requiring Python Virtual Environments.rene2716 wrote: Friday 12 September 2025 15:19 Hi when i try tp do
pip install -r requirements.txt
i get
error: externally-managed-environment
any idea whhere this comes from ?
See https://wiki.domoticz.com/Using_Python_ ... ules_fails
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
-
DomoFlits
- Posts: 45
- Joined: Thursday 06 October 2016 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Bld16583
- Location: The Netherlands
- Contact:
Re: HomeWizard Battery plugin
The curl indeed has to be send to the P1, so a separate token op the P1 is needed.DomoFlits wrote: Thursday 11 September 2025 21:13
I assume now that the <IP ADDRESS> is the IP address of the P1 and not the battery and I'll also need a token from the P1 (due to this information: https://gathering.tweakers.net/forum/li ... 2#82340672)
If it is indeed arranged via the P1 it might not be logic to have this in the battery plugin since the plugin needs to have the P1 address and the P1 token, which gets confusing on the hardware page.
When testing on the commandline the below works fine:
Code: Select all
curl -X PUT https://<IP-of-P1>/api/batteries --insecure ^
-H "Authorization: Bearer <token of P1>" ^
-H "X-Api-Version: 2" ^
-H "Content-Type: application/json" ^
-d "{""mode"": ""to_full""}"
Code: Select all
{"mode":"to_full","power_w":0,"max_consumption_w":800,"max_production_w":800,"target_power_w":-48}
so the DzVents script should be something like
Code: Select all
return {
on = { ... }, -- some trigger
execute = function(domoticz)
domoticz.openURL({
url = 'https://<IP-of-the-P1>/api/batteries --insecure',
method = 'PUT',
headers = {
['Authorisation'] = 'Bearer <token-of-the-P1>',
['X-Api-Version'] = '2'
},
postData = '{"mode": "to_full"}'
})
end
}
Error opening url: https://192.168.1.212/api/batteries --insecure
any help on how to handle the --insecure part when using domoticz.openURL function in DzVents?
- waltervl
- Posts: 6677
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: HomeWizard Battery plugin
Code: Select all
postData = '{"mode": "to_full"}'Code: Select all
postData = { mode = 'to_full' }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
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
For reference you need to specify post data as `postData = { ['mode'] = 'to_full' },`
Also adding ` --insecure` to the url does not help.
Even so it seems like the dzVent http connection api renders the https call invalid for the p1 device.
As a workaround you could run a shellcommand from dzVents that calls into the curl command. See for example this wiki item: https://wiki.domoticz.com/DzVents:_next ... d_executio
Also adding ` --insecure` to the url does not help.
Even so it seems like the dzVent http connection api renders the https call invalid for the p1 device.
As a workaround you could run a shellcommand from dzVents that calls into the curl command. See for example this wiki item: https://wiki.domoticz.com/DzVents:_next ... d_executio
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
This is the dzVent script I was using to set the mode (fill in your own Bearer string).
It still fails with `2025-10-02 13:39:02.271 Error: dzVents: HTTP/1.1 response: 401 ==>> Unauthorized`
It still fails with `2025-10-02 13:39:02.271 Error: dzVents: HTTP/1.1 response: 401 ==>> Unauthorized`
Code: Select all
return {
on = { timer = {
'every minute',
},
httpResponses = { 'batteries' }
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'https://192.168.1.6/api/batteries',
method = 'PUT',
headers = {
['Authorisation'] = 'Bearer *********************',
['X-Api-Version'] = '2'
},
postData = { ['mode'] = 'to_full' },
callback = 'batteries'
})
print("batteries set to to_full")
elseif (item.isHTTPResponse) then
print('batteries: ')
print(item.ok)
print(item.json)
print('end batteries')
end
end
}
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
I (and a bit of chatgpt) managed to switch the mode using a python event script.
You may want to change the trigger type of the script to time or when a user variable changes.
You may want to change the trigger type of the script to time or when a user variable changes.
Code: Select all
import DomoticzEvents as DE
import http.client
import ssl
import json
# API details
host = "192.168.1.6" # fill in your p1 ip number
port = 443
url = "/api/batteries"
bearer_token = "**************" # fill in your bearer_token
body = '{"mode": "to_full"}'
# Create an SSL context that ignores certificate verification (-k)
context = ssl._create_unverified_context()
# Create HTTPS connection
conn = http.client.HTTPSConnection(host, port, context=context, timeout=10)
# Headers
headers = {
"Authorization": f"Bearer {bearer_token}",
"X-Api-Version": "2",
"Content-Type": "application/json",
"Accept": "*/*"
}
# Make GET request with a body
conn.request("PUT", url, body=body, headers=headers)
response = conn.getresponse()
# Print status
DE.Log(f"HTTP {response.status} {response.reason}\n")
# Read response
data = response.read()
try:
parsed = json.loads(data)
DE.Log(json.dumps(parsed, indent=2, ensure_ascii=False))
except Exception:
DE.Log(data.decode('utf-8', errors='ignore'))
-
DomoFlits
- Posts: 45
- Joined: Thursday 06 October 2016 20:33
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Bld16583
- Location: The Netherlands
- Contact:
Re: HomeWizard Battery plugin
Thanks for putting me on the right track.
It is working now with the flip of a switch in domoticz.
This is what I did:
I've made a dummy selector switch with 2 selections: "to-full" and "zero"
Action for "to-full" is: script:///home/pi/domoticz/scripts/HW_full.py
Action for "zero" is: script:///home/pi/domoticz/scripts/HW_zero.py
I've put the below 2 scripts in the scripts-folder and made them executable (update the IP adress of the P1 and insert the token)
The switch can now be used in further automation.
HW_full.py
HW_zero.py
It is working now with the flip of a switch in domoticz.
This is what I did:
I've made a dummy selector switch with 2 selections: "to-full" and "zero"
Action for "to-full" is: script:///home/pi/domoticz/scripts/HW_full.py
Action for "zero" is: script:///home/pi/domoticz/scripts/HW_zero.py
I've put the below 2 scripts in the scripts-folder and made them executable (update the IP adress of the P1 and insert the token)
The switch can now be used in further automation.
HW_full.py
Code: Select all
#!/usr/bin/python
import http.client
import ssl
import json
# API details
host = "192.168.1.212" # fill in your p1 ip number
port = 443
url = "/api/batteries"
bearer_token = "--------------" # fill in your bearer_token
body = '{"mode": "to_full"}'
# Create an SSL context that ignores certificate verification (-k)
context = ssl._create_unverified_context()
# Create HTTPS connection
conn = http.client.HTTPSConnection(host, port, context=context, timeout=10)
# Headers
headers = {
"Authorization": f"Bearer {bearer_token}",
"X-Api-Version": "2",
"Content-Type": "application/json",
"Accept": "*/*"
}
# Make GET request with a body
conn.request("PUT", url, body=body, headers=headers)
response = conn.getresponse()
Code: Select all
#!/usr/bin/python
import http.client
import ssl
import json
# API details
host = "192.168.1.212" # fill in your p1 ip number
port = 443
url = "/api/batteries"
bearer_token = "--------------" # fill in your bearer_token
body = '{"mode": "zero"}'
# Create an SSL context that ignores certificate verification (-k)
context = ssl._create_unverified_context()
# Create HTTPS connection
conn = http.client.HTTPSConnection(host, port, context=context, timeout=10)
# Headers
headers = {
"Authorization": f"Bearer {bearer_token}",
"X-Api-Version": "2",
"Content-Type": "application/json",
"Accept": "*/*"
}
# Make GET request with a body
conn.request("PUT", url, body=body, headers=headers)
response = conn.getresponse()
-
mvdp
- Posts: 24
- Joined: Sunday 07 October 2018 17:21
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Bollenstreek
- Contact:
Re: HomeWizard Battery plugin
Nice! Glad it works now.
2 small nit remarks:
* The comment says GET but the code uses PUT (my bad).
* You could improve the set up with 1 script only where the mode is provided as an program argument. This is to prevent to maintain the same information like ip and bearer token in multiple places.
2 small nit remarks:
* The comment says GET but the code uses PUT (my bad).
* You could improve the set up with 1 script only where the mode is provided as an program argument. This is to prevent to maintain the same information like ip and bearer token in multiple places.
-
gvandick
- Posts: 39
- Joined: Saturday 01 July 2017 12:48
- Target OS: Windows
- Domoticz version:
- Contact:
Re: HomeWizard Battery plugin
Thx it works great!!
Who is online
Users browsing this forum: No registered users and 1 guest