HomeWizard P1 Wifi into Domoticz

Moderator: leecollings

rboerdijk
Posts: 7
Joined: Friday 20 May 2016 22:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

HomeWizard P1 Wifi into Domoticz

Post by rboerdijk »

Hello,

I have a Homewizard P1 Dongle, connected via Wifi to my LAN. When I access the device via the browser, I get something like this:

http://192.168.1.169/api/v1/data
{"smr_version":50,"meter_model":"Sagemcom XS210 ESMR 5.0","wifi_ssid":"xxx","wifi_strength":68,"total_power_import_t1_kwh":6566.39,"total_power_import_t2_kwh":5230.154,"total_power_export_t1_kwh":106.717,"total_power_export_t2_kwh":228.224,"active_power_w":-1616,"active_power_l1_w":-1616,"active_power_l2_w":null,"active_power_l3_w":null,"total_gas_m3":2154.48,"gas_timestamp":210905105000}

I'd like to get this data into Domoticz (running in Docker on a synology), but I'm not entire sure how this is done. I tried adding the "P1 Smart Meter with LAN interface" (which sounds exactly like what I want) and pointed it to the above IP on port 80. In the log I see the following entries, but when I look under Setup/Devices, there is no entry related to the P1 Lan Device - which is unexpected.

2021-09-05 02:17:19.780 Status: P1MeterTCP: attempt connect to 192.168.1.169:80
...
2021-09-05 02:17:19.787 Status: P1MeterTCP: connected to: 192.168.1.169:80


The other approach I've seen mentioned is to use a "Dummy Virtual Sensor" under Setup/Hardware and then add "Gas" and "P1 Smart Meter Electric" as sensor. These two then do appear under Setup/Devices, but don't report any data (which is kind of obvious, since I didn't find a way to point them to the correct IP to read their data from).

What is the correct way to do this, could someone give some pointers?

Thanks!
Attachments
domoticz-p1.png
domoticz-p1.png (46.5 KiB) Viewed 9981 times
User avatar
JackD
Posts: 68
Joined: Monday 02 November 2020 20:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by JackD »

Perhaps you can do something with MQTT(Mosquitto) and Node-Red to get the data to Domoticz.
The both can be run in a Docker container on a Synology.
just a thought.......


or

Does your Domoticz container have the correct port/network settings to connect to your network and the dongle
rboerdijk
Posts: 7
Joined: Friday 20 May 2016 22:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by rboerdijk »

The log says "2021-09-05 02:17:19.787 Status: P1MeterTCP: connected to: 192.168.1.169:80", so I think so... I'm going to google a bit more on this, see if there's a way to verify, just to be sure.

If it's not possible using Domoticz alone, I'll look into your other suggestion, but it seems kind of basic functionality (query a page, parse some data)... I rather suspect it's my lack of experience in getting this to work :)
rboerdijk
Posts: 7
Joined: Friday 20 May 2016 22:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by rboerdijk »

For anyone else wanting this, you need the HTTP/HTTPS poller", point it to your HomeWizard-P1 device, create two virtual devices and add a lua-script to parse the webpage the device returns, look in this post for details: viewtopic.php?f=28&t=34952&p=279299#p279299
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by FireWizard »

Hello @rboerdijk

You wrote:
I'd like to get this data into Domoticz (running in Docker on a synology), but I'm not entire sure how this is done. I tried adding the "P1 Smart Meter with LAN interface" (which sounds exactly like what I want) and pointed it to the above IP on port 80. In the log I see the following entries, but when I look under Setup/Devices, there is no entry related to the P1 Lan Device - which is unexpected.

2021-09-05 02:17:19.780 Status: P1MeterTCP: attempt connect to 192.168.1.169:80
...
2021-09-05 02:17:19.787 Status: P1MeterTCP: connected to: 192.168.1.169:80
Yes the interface will connect and will wait for a valid response. As soon as a valid answer is received the Domoticz devices are created.
But..., you will never receive a valid answer, as the answer from the Homewizard P1 dongle is completely different from what Domoticz expects.
The "P1 Smart Meter with LAN interface" expects a protocol from Netbeheer Nederland B.V.
See: https://www.netbeheernederland.nl/_uplo ... fce1f1.pdf

But what you receive is very nice and is excellent for Node Red.
I copy/pasted your example in an "Inject" node and it gives a nice JSON output.

Screenshot_electicity.png
Screenshot_electicity.png (43.42 KiB) Viewed 9949 times
If you replace the "Inject" node with a HTTP request node, followed by a "Function" node, where you convert the values to the suitable format for Domoticz, you can use either HTTP or MQTT to Domoticz.

You will need:

- Virtual Electricity P1 smart meter
- Virtual Gas meter
- 3 virtual Electricity (instant and counter) meters (1 for each phase, unless you have a Single Phase kWh meter)

I also see that alternatives, such as HTTP poller, has been mentioned, but if you want to use Node Red, with or without MQTT, I'm happy to support you.

Regards
rboerdijk
Posts: 7
Joined: Friday 20 May 2016 22:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by rboerdijk »

Thanks for the replies, I'm getting data which appears valid using http-polling and the lua-script - inside domoticz, so that's something already.

Vaguely heard of mqtt but never heard of node-red. Since multiple people mentioned it I'm curious.
What is the advantage of using mqtt/node-red compared to just letting domoticz handle everything?

Taking a first glance, MQTT is the 'thing' which gathers data from 'somewhere' (e.g. the HomeWizard-P1) and broadcasts data to 'subscribed devices' (so node-red, or domoticz). Node-red then provides a visualizer to interpret the data.. which then somehow lands in Domoticz?
Om a High-level, how would it looks if we go for the full mqtt/node-red/domoticz solution?

I guess I'd need these docker containers (besides the domoticz one which is already running)?
https://registry.hub.docker.com/r/nodered/node-red
https://registry.hub.docker.com/_/eclipse-mosquitto
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by FireWizard »

Hi, @rboerdijk,

Just to answer some of your questions.
What is the advantage of using mqtt/node-red compared to just letting domoticz handle everything?
If Domoticz would be able to handle everything, it would be the best Home Automation platform, that would exist.
Domoticz is very strong in scripting, especially if you use dzVents. Also the lua language is very useful, but both need a learning curve.

As you might have seen already, quite a lot of Python scripts and/or plugins are used.

But still Domoticz cannot handle everything.

This is where Node Red comes in. It is a visual low code programming tool and has far more "nodes", than that Domoticz supports natively.
If you are known to the principle, you are able with a number of mouse clicks and some Javascript to create an "interface" to Domoticz.

For myself, I have even replaced some plugins and Python scripts with a "Node-Red" flow. Some for the reason that the Python script was not longer maintained by the original creator and others, because I was not satisfied with the script and want to have more control myself.

I know this is a personal opinion and for others users it may be completely different.

The MQTT protocol is a lightweight publish/subscribe protocol.

Just to read a comparison between HTTP and MQTT, see: https://medium.com/mqtt-buddy/mqtt-vs-h ... 68169b3105
Taking a first glance, MQTT is the 'thing' which gathers data from 'somewhere' (e.g. the HomeWizard-P1) and broadcasts data to 'subscribed devices' (so node-red, or domoticz).
No, MQTT does nothing. it does not collect anything.

A client has to publish a payload to some topic.
Another client is able to subscribe to that topic and will receive the payload.

Simply said, this payload can be anything.

Suppose that your "HomeWizard-P1" would be able to send MQTT messages, it would be the responsibility of the "HomeWizard-P1" to publish the data, e.g as shown in your post and my example. Another device can subscribe to that topic. So the MQTT server, sometimes also called broker, does not broadcast anything.

Domoticz supports MQTT, but the messages should be compliant to a specific format.

And that is the moment, where Node Red appears, as with NR it is very simple to convert between the different formats.
An example of your flow would consist of a HTTP request node, one Function node with probably 5 lines of code and then a MQTT out node for Domoticz. Estimated time, about 5-10 minutes, not more. Some testing, of course, excluded. In addition an Inject node as a timer to poll your "HomeWizard-P1" IP address.
I guess I'd need these docker containers (besides the domoticz one which is already running)?
Correct, install them and see, if they function correctly.

If they do, I'm happy to support you of creating the flow.

Regards
Last edited by FireWizard on Friday 06 January 2023 15:06, edited 1 time in total.
Eraser
Posts: 24
Joined: Friday 13 January 2017 9:24
Target OS: Windows
Domoticz version: 3.8153
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by Eraser »

For those who are looking for a Python plugin for the Wifi P1 meter, it is right here: HomeWizard WiFi p1 meter Domoticz plugin
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by waltervl »

Eraser wrote: Wednesday 26 October 2022 11:08 For those who are looking for a Python plugin for the Wifi P1 meter, it is right here: HomeWizard WiFi p1 meter Domoticz plugin
Thanks! I added it to the wiki plugins overview https://www.domoticz.com/wiki/Plugins
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

Eraser wrote: Wednesday 26 October 2022 11:08 For those who are looking for a Python plugin for the Wifi P1 meter, it is right here: HomeWizard WiFi p1 meter Domoticz plugin
Is there someone who used this already?
I'am getting error on starting script?

Greetings,

Mike
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by waltervl »

Check the troubleshooting section for using python plugins in wiki https://www.domoticz.com/wiki/Using_Pyt ... leshooting
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

I've used this link https://github.com/Eraser3/HomeWizard-W ... /plugin.py and made a new file with it.
If I start this manual I 'am getting error:

root@Domoticz:/home/pi/domoticz/plugins/HomeWizard# ./HomeWizard-Wifi-p1.py
./HomeWizard-Wifi-p1.py: regel 48: syntaxfout nabij onverwacht symbool '('
./HomeWizard-Wifi-p1.py: regel 48: ` <param field="Mode3" label="Usage value (Watt)" width="100px" required="false" default="0" />

What can I do to sort this out? Never used Python to active Domoticz Devices.

Thanks in advanced for the support.

Greetings,

Mike
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
willemd
Posts: 621
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by willemd »

Is there a reason you want to use the python plugin instead of the http poller setup?
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

willemd wrote: Monday 19 December 2022 19:08 Is there a reason you want to use the python plugin instead of the http poller setup?
No not realy...

I'am starting for the first time with this device. (Yesterday installed) and thought it is the quick solution :-), possibly not.
What would you recomment to follow (steps)?

Greetings,

Mike
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by waltervl »

With a plugin you only need to download the python source. It should the take care of device creation and data updates.
So normally a plugin should be easier to use then setting up the http poller with parsing script. There is also no repository for http poller scripts so everyone has to program again. For plugins there is a wiki page for a lot of possible plugins.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

waltervl wrote: Monday 19 December 2022 19:25 With a plugin you only need to download the python source. It should the take care of device creation and data updates.
I read about those Python scripts:
------------------------------------
So. is my assumption correct that i need to make a extra Folder inDomoticz:/home/pi/domoticz/plugins#
Let say; with name of Device like 'HomeWizard' an place the Python script at this location?

Code: Select all

root@Domoticz:/home/pi/domoticz/plugins/HomeWizard# ls -al
totaal 24
drwxr-xr-x 2 root root  4096 dec 17 12:33 .
drwxr-xr-x 5 pi   pi    4096 dec 17 11:07 ..
-rwxr-xr-x 1 root root 16246 dec 17 10:58 HomeWizard-Wifi-p1.py
What should there be done/tested further?

Thanks for youre time to this noob in scripting :-)

Mike
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by waltervl »

The filename should be plugin.py and the plugin.py should be executable (but already is it seems)
and after that restart Domoticz with

Code: Select all

sudo service domoticz restart
Then the Homewizard hardware should be visible in the pull down list device type in menu Setup - Hardware for adding new Hardware gateways.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

waltervl wrote: Tuesday 20 December 2022 9:25 The filename should be plugin.py and the plugin.py should be executable (but already is it seems)
and after that restart Domoticz with

Code: Select all

sudo service domoticz restart
Then the Homewizard hardware should be visible in the pull down list device type in menu Setup - Hardware for adding new Hardware gateways.
THx again Walter, for the support, I knew it has to be something small :-)

It's working

Loggin Domoticz:
---------------------
2022-12-20 16:59:13.513 Status: P1 HomeWizard: TCP/IP Worker stopped...
2022-12-20 16:59:13.514 Status: P1 HomeWizard: Entering work loop.
2022-12-20 16:59:13.515 Status: P1 HomeWizard: Started.
2022-12-20 16:59:14.140 Status: P1 HomeWizard: Initialized version 0.0.2, author 'Eraser'

Cheers,

Mike
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
AthomeDomotica
Posts: 25
Joined: Monday 26 December 2016 14:20
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Utrecht
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by AthomeDomotica »

After 2 weeks I' am getting this error?'

Error: P1 HomeWizard: Failed to read response data

Set DEBUG ON
---------------
2023-01-06 14:42:00.041 P1 HomeWizard: Pushing 'onHeartbeatCallback' on to queue
2023-01-06 14:42:00.091 P1 HomeWizard: Processing 'onHeartbeatCallback' message
2023-01-06 14:42:00.091 P1 HomeWizard: Acquiring GIL for 'onHeartbeatCallback'
2023-01-06 14:42:00.091 P1 HomeWizard: Calling message handler 'onHeartbeat' on 'module' type object.
2023-01-06 14:42:00.204 P1 HomeWizard: Acquiring GIL for 'onHeartbeatCallback'
2023-01-06 14:42:00.204 Error: P1 HomeWizard: Failed to read response data
--------------------
Anyone experienced this ?

Domoticz restarted, same issue

At the end of the Python script is this activated!
-------------
if ( self.dataIntervalCount >= self.dataInterval or self.switchIntervalCount >= self.switchInterval ):
try:
self.smr_version = Data['smr_version']
self.meter_model = Data['meter_model']
self.wifi_ssid = Data['wifi_ssid']
self.wifi_strength = Data['wifi_strength']
self.total_power_import_t1_kwh = int(Data['total_power_import_t1_kwh'] * 1000)
self.total_power_import_t2_kwh = int(Data['total_power_import_t2_kwh'] * 1000)
self.total_power_export_t1_kwh = int(Data['total_power_export_t1_kwh'] * 1000)
self.total_power_export_t2_kwh = int(Data['total_power_export_t2_kwh'] * 1000)
self.active_power_w = Data['active_power_w']
self.active_power_l1_w = Data['active_power_l1_w']
self.active_power_l2_w = Data['active_power_l2_w']
self.active_power_l3_w = Data['active_power_l3_w']
self.total_gas_m3 = int(Data['total_gas_m3'] * 1000)
self.gas_timestamp = Data['gas_timestamp']

if ( self.active_power_w >= 0):
self.import_active_power_w = self.active_power_w
self.export_active_power_w = 0
else:
self.import_active_power_w = 0
self.export_active_power_w = self.active_power_w * -1
except:
Domoticz.Error("Failed to read response data")

=====================
How to debug this issue?

Thanks for youre time to responce
Domoticz, Controlicz, Philips HUE Gateway and bulbs, Z-Wave (Aecotec Stick) and Fibaro Dimmers, RFLink Gateway.
azonneveld
Posts: 153
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: HomeWizard P1 Wifi into Domoticz

Post by azonneveld »

AthomeDomotica wrote: Friday 06 January 2023 14:48 How to debug this issue?
What is the output when you request the url from a browser? http://<P1 IP ADDRESS>/api/v1/data


See description: viewtopic.php?p=297369#p297369
Last edited by azonneveld on Friday 06 January 2023 20:25, edited 1 time in total.
rpi4 - zigbee2mqtt - roborock - espeasy - rfxcom - homewizard p1 - otgw - homebridge - surveillance station - egardia - goodwe - open weather map - wol - BBQ detection - rsync backup
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest