Using P1-device form Dutch Homewizard

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

florisjan
Posts: 2
Joined: Wednesday 23 December 2020 0:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Using P1-device form Dutch Homewizard

Post by florisjan »

Hi,

I try to connect the P1-device (that is connected to my LAN via WiFi) to my Domoticz-application on my NAS (Synology).

I use the type P1-meter with LANinterface combined with remote address: localIP//api/v1/data:20000

In the logs I find this errors:
2020-12-23 00:47:24.298 Error: Restarting: Homewizard
2020-12-23 00:47:29.641 Error: SolarEdgeAPI: Error getting http data!
2020-12-23 00:47:38.493 Error: P1MeterTCP: Host not found (authoritative)
2020-12-23 00:48:08.549 Error: P1MeterTCP: Host not found (authoritative)
2020-12-23 00:48:33.935 Error: Homewizard hardware (13) nothing received for more than 1 Minute!....
2020-12-23 00:48:34.946 Error: Restarting: Homewizard
2020-12-23 00:48:38.580 Error: P1MeterTCP: Host not found (authoritative)
2020-12-23 00:48:40.148 Error: SolarEdgeAPI: Error getting http data!
2020-12-23 00:49:08.613 Error: P1MeterTCP: Host not found (authoritative)
2020-12-23 00:49:43.653 Error: P1MeterTCP: Host not found (authoritative)
2020-12-23 00:49:44.510 Error: Homewizard hardware (13) nothing received for more than 1 Minute!....
2020-12-23 00:49:45.518 Error: Restarting: Homewizard

Is it posible to connect this device?
P1-meter_Homewizard.jpg
P1-meter_Homewizard.jpg (118.57 KiB) Viewed 7920 times
Regards,
Florisjan
smaus
Posts: 84
Joined: Sunday 18 February 2018 9:32
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by smaus »

I will follow this
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by SanderRoelofs »

Hi,

You need to use the HTTP/HTTPS poller.

Method = GET
ContentType = application/JSON
url = http://{p1 ipadres}/api/v1/data
Command = p1.lua
Interval = {value in seconds}

Two virtual sensors (Gas and Smart Energy Meter)

and lua script saved in scripts folder

p1.lua script:
------ BEGIN ------
-- Read API values
s = request['content'];

--
-- Gasmeter
--
local idGas = 101
local a = domoticz_applyJsonPath(s,'.total_gas_m3')
domoticz_updateDevice(idGas,'',a*1000)

--
-- Energiemeter
--

-- Dal import value
local b = domoticz_applyJsonPath(s,'.total_power_import_t1_kwh')
-- Piek import value
local c = domoticz_applyJsonPath(s,'.total_power_import_t2_kwh')
-- Dal return value
local d = domoticz_applyJsonPath(s,'.total_power_export_t1_kwh')
-- Piek return value
local e = domoticz_applyJsonPath(s,'.total_power_export_t2_kwh')
-- Active Watt Usage
local f = domoticz_applyJsonPath(s,'.active_power_w')
local g = domoticz_applyJsonPath(s,'active_power_l1_w')
local h = domoticz_applyJsonPath(s,'active_power_l2_w')
local i = domoticz_applyJsonPath(s,'active_power_l3_w')
--

local idEnergy = 100
domoticz_updateDevice(idEnergy,'',b*1000 ..";"..c*1000 ..";"..d..";"..e..";"..f..";"..'0')
------ END ------

It's a simple script to read the values (it is not perfect because I'm not a script person but it works

lookup your idx numbers for the sensors and replace in script

local idGas = 101
local idEnergy = 100
User avatar
waltervl
Posts: 6678
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Using P1-device form Dutch Homewizard

Post by waltervl »

General HTTP/HTTPS Poller instructions here: https://www.domoticz.com/wiki/HTTP/HTTPS_poller
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by SanderRoelofs »

waltervl wrote: Thursday 11 March 2021 11:46 General HTTP/HTTPS Poller instructions here: https://www.domoticz.com/wiki/HTTP/HTTPS_poller
Thanks for your update. SO use general information about General HTTP/HTTPS Poller instruction and use mine p1.lua script for reading the values.
rboerdijk
Posts: 7
Joined: Friday 20 May 2016 22:53
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by rboerdijk »

For the newbies (like me), script needs to be under in the folder /scripts/lua_parsers and you want to use the "Idx" value as shown under devices (not "ID") ;)

Also, the values look a bit mess up, is this expected?
docker-p1-energy.png
docker-p1-energy.png (40.69 KiB) Viewed 7330 times
brax
Posts: 2
Joined: Sunday 26 September 2021 0:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by brax »

rboerdijk wrote: Sunday 05 September 2021 14:28 For the newbies (like me), script needs to be under in the folder /scripts/lua_parsers and you want to use the "Idx" value as shown under devices (not "ID") ;)

Also, the values look a bit mess up, is this expected?
docker-p1-energy.png
Hi
i got the same issue with negative values coming from the P1 meter
I found this solution...
https://github.com/domoticz/domoticz/issues/4521
brax
Posts: 2
Joined: Sunday 26 September 2021 0:55
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by brax »

brax wrote: Sunday 26 September 2021 0:56
rboerdijk wrote: Sunday 05 September 2021 14:28 For the newbies (like me), script needs to be under in the folder /scripts/lua_parsers and you want to use the "Idx" value as shown under devices (not "ID") ;)

Also, the values look a bit mess up, is this expected?
docker-p1-energy.png
Hi
i got the same issue with negative values coming from the P1 meter
I found this solution...
https://github.com/domoticz/domoticz/issues/4521
Hi
I found the solution in the Lua script (a little bit trial & error)
don't forget to change the idx numbers

------ BEGIN ------
-- Read API values
s = request['content'];

--
-- Gasmeter
--
local idGas = 5
local a = domoticz_applyJsonPath(s,'.total_gas_m3')
domoticz_updateDevice(idGas,'',a*1000)

--
-- Energiemeter
--

-- Dal import value
local b = domoticz_applyJsonPath(s,'.total_power_import_t1_kwh')
-- Piek import value
local c = domoticz_applyJsonPath(s,'.total_power_import_t2_kwh')
-- Dal return value
local d = domoticz_applyJsonPath(s,'.total_power_export_t1_kwh')
-- Piek return value
local e = domoticz_applyJsonPath(s,'.total_power_export_t2_kwh')
-- Active Watt Usage
local f = domoticz_applyJsonPath(s,'.active_power_w')
local g = math.abs(domoticz_applyJsonPath(s,'.active_power_w'))
if f<0 then f = 0 elseif f>0 then g = 0 end
local h = domoticz_applyJsonPath(s,'active_power_l1_w')
local i = domoticz_applyJsonPath(s,'active_power_l2_w')
local j = domoticz_applyJsonPath(s,'active_power_l3_w')

--

local idEnergy = 4
domoticz_updateDevice(idEnergy,'',b*1000 ..";"..c*1000 ..";"..d*1000 ..";"..e*1000 ..";"..f..";"..g)
------ END ------

works great for my belgian digital meter with the homewizard P1-meter
pauldune
Posts: 1
Joined: Wednesday 04 November 2020 8:42
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by pauldune »

The solution from Brax works perfectly! With the LUA script provided, and the right Idx (you'll need the Idx and not the ID!) and the http/https poller, I get now perfect results.
Even better, I used this method to make a sensor for the Shelly EM1 too, works perfect, no node red or mqtt necessary.
Thanks Brax!
Pheinstra
Posts: 1
Joined: Wednesday 28 September 2022 20:38
Target OS: -
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by Pheinstra »

I know it has been quite some time since this post was active.
I have just purchased a Homewizard P1 meter and used this method and it works like a charm! So thanks for that.

I was wondering if it is also possible to get readings on the seperate fases.......does anyone know how to do that properly? I have managed to get readings on the current usage for the different fases by changing the "f" (in the "domoticz_updateDevice" part) in the letters of the fases (so, 1 for G, 1 for H and 1 for I). but the graphs in the log of the device still show the total usage of the 3 fases combined...... as i sometimes have weird peaks in the total amount i want to find out on which fase they occur.
I am quite a noob (or maybe even a total noob :) ) on scripting........

Thanks in advance for your help!!

Regards,

Koen
guidohuijnen
Posts: 1
Joined: Monday 19 September 2016 18:44
Target OS: -
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by guidohuijnen »

I'm a complete noob with Lua...

Can someone help why I get this error:

input:3: attempt to index a nil value (global 'request')

Thnx & regards,
Guido
willemd
Posts: 735
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: Using P1-device form Dutch Homewizard

Post by willemd »

guidohuijnen wrote: Saturday 01 October 2022 18:32 I'm a complete noob with Lua...

Can someone help why I get this error:

input:3: attempt to index a nil value (global 'request')

Thnx & regards,
Guido
You need to add some more info before anyone can help.
What have you done/configured? When do you get this error? What is the code/script used that produces this error?
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by SanderRoelofs »

Hi,

Little late response but I have readings for 3 phases and extra.
since my first script I've now solar panels, 3 phase system and waiting for water meter. So I have updated my first script several times now.

Code: Select all

-- Read API values
s = request['content'];

--
-- Gasmeter
--
local idGas = {idx value}
local a = domoticz_applyJsonPath(s,'.total_gas_m3')
domoticz_updateDevice(idGas,'',a*1000)

--
-- Energiemeter
--

-- Dal import value
local b = domoticz_applyJsonPath(s,'.total_power_import_t1_kwh')
-- Piek import value
local c = domoticz_applyJsonPath(s,'.total_power_import_t2_kwh')
-- Dal return value
local d = domoticz_applyJsonPath(s,'.total_power_export_t1_kwh')
-- Piek return value
local e = domoticz_applyJsonPath(s,'.total_power_export_t2_kwh')
-- Active Watt Usage
local w = domoticz_applyJsonPath(s,'.active_power_w')
if w > 0 then f = w g = 0 else f = 0 g = w end
local L1 = domoticz_applyJsonPath(s,'active_power_l1_w')
local L2 = domoticz_applyJsonPath(s,'active_power_l2_w')
local L3 = domoticz_applyJsonPath(s,'active_power_l3_w')
--

local idEnergy = {idx value}
domoticz_updateDevice(idEnergy,'',b*1000 ..";"..c*1000 ..";"..d*1000 ..";"..e*1000 ..";"..f..";"..g*-1)

-- Actual Watt Usage incl Fase 1,2,3
local idWatt = {idx value}
domoticz_updateDevice(idWatt,'',w)
local idWatt = {idx value}
domoticz_updateDevice(idWatt,'',L1)
local idWatt = {idx value}
domoticz_updateDevice(idWatt,'',L2)
local idWatt = {idx value}
domoticz_updateDevice(idWatt,'',L3)

-- Actual Usage 2
local idWatt = {idx value}
domoticz_updateDevice(idWatt,'',w)

--
-- Watermeter
--
local idWater = {idx value}
local m = domoticz_applyJsonPath(s,'.active_liter_lpm')
domoticz_updateDevice(idWater,'',m)

local idWaterTotaal = {idx value}
local n = domoticz_applyJsonPath(s,'.total_liter_m3')
domoticz_updateDevice(idWaterTotaal,'',n)

BTW it's also possible to read voltage from phase 1 upto 3 through Telegram values in DZVentz

Code: Select all

local scriptVar = 'readTelegram'

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
        httpResponses =
        {
            scriptVar,
        },
    },

    logging =
    {
        level = domoticz.LOG_DEBUG,
        marker = scriptVar,
    },

    execute = function(dz, item)

        local debug = _G.logLevel == dz.LOG_DEBUG

        local voltL1 = dz.devices('Input Voltage L1') -- change to name of your virtual voltage device
        local voltL2 = dz.devices('Input Voltage L2') -- change to name of your virtual voltage device
        local voltL3 = dz.devices('Input Voltage L3') -- change to name of your virtual voltage device

        local frequency = 6 -- every 60 / frequency seconds
        local P1Reference =
        {
             voltageL1 = '32.7.0',
             voltageL2 = '52.7.0',
             voltageL3 = '72.7.0',
        }

        local function openURL(delay)
            dz.openURL(
            {
                url = 'http://{ipaddress_from_meter}/api/v1/telegram',
                callback = scriptVar,
            }).afterSec(delay or 0)
        end

        function table.invert(t)
           local it = {}
           for k,v in pairs(t) do
             it[v]=k
           end
           return it
        end

        local function readResult( telegram, it )

            local function crLines(s)
                return s:gsub('\r\n?', '\n'):gmatch('(.-)\n') -- Normalize CR/LF
            end

            local lines = {}
            for line in crLines(telegram) do
                if line:find(':') then
                    key = it[line:match(':(%d+.%d+.%d+)')]
                    if key then
                        lines[key] = math.floor((line:match('%b()%s*%c*$'):match('%d+%.*%d*') or -1) * 1000)
                    end
                end
            end

            if debug then dz.utils.dumpTable(lines) end

            return lines

        end

        local function updateDevices(t)
            
            voltL1.updateVoltage( dz.utils.round( t.voltageL1 / 1000 ,1 ) )
            voltL2.updateVoltage( dz.utils.round( t.voltageL2 / 1000 ,1 ) )
            voltL3.updateVoltage( dz.utils.round( t.voltageL3 / 1000 ,1 ) )

        end

        local function showResults(t, it)
            if not(debug) then return end
            for code, value in pairs(t) do
                if it[code] then
                    dz.log(it[code] .. ' ==>> ' .. value, dz.LOG_DEBUG)
                end
            end
        end

        -- main code
        if item.isTimer then
            openURL()

            local interval = math.floor(60/frequency)
            for secondsDelay = interval, (60 - interval), interval do
                openURL(secondsDelay)
            end
        elseif item.isHTTPResponse and item.ok then
            local invertedTable = table.invert(P1Reference)

            local actual = readResult(item.data, invertedTable)
            showResults(actual, invertedTable)
            updateDevices(actual, invertedTable)
        else
            dz.log('Problem reading the telegram', dz.LOG_ERROR)
            dz.log(tostring(item.data), dz.LOG_DEBUG)
        end
    end
}










Pheinstra wrote: Wednesday 28 September 2022 20:48 I know it has been quite some time since this post was active.
I have just purchased a Homewizard P1 meter and used this method and it works like a charm! So thanks for that.

I was wondering if it is also possible to get readings on the seperate fases.......does anyone know how to do that properly? I have managed to get readings on the current usage for the different fases by changing the "f" (in the "domoticz_updateDevice" part) in the letters of the fases (so, 1 for G, 1 for H and 1 for I). but the graphs in the log of the device still show the total usage of the 3 fases combined...... as i sometimes have weird peaks in the total amount i want to find out on which fase they occur.
I am quite a noob (or maybe even a total noob :) ) on scripting........

Thanks in advance for your help!!

Regards,

Koen
Last edited by SanderRoelofs on Monday 02 January 2023 15:26, edited 1 time in total.
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by SanderRoelofs »

I had the same error with my new meter. This problem occurs because the gas meter isn't connected to the p1 meter.
you can disable gasmeter readings until it works or i did this

if a == not nil then domoticz_updateDevice(idGas,'',a*1000) else domoticz_updateDevice(idGas,'',{manual_value}*1000) end

update my readings once a day manual.
guidohuijnen wrote: Saturday 01 October 2022 18:32 I'm a complete noob with Lua...

Can someone help why I get this error:

input:3: attempt to index a nil value (global 'request')

Thnx & regards,
Guido
User avatar
waltervl
Posts: 6678
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Using P1-device form Dutch Homewizard

Post by waltervl »

@SanderRoeloefs

It would be nice if you modified your posts with code so that the code comes in code brackets and becomes readable.... :D

Code: Select all

code
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
SanderRoelofs
Posts: 17
Joined: Thursday 11 March 2021 10:03
Target OS: Windows
Domoticz version:
Contact:

Re: Using P1-device form Dutch Homewizard

Post by SanderRoelofs »

Sorry and done
waltervl wrote: Monday 02 January 2023 14:33 @SanderRoeloefs

It would be nice if you modified your posts with code so that the code comes in code brackets and becomes readable.... :D

Code: Select all

code
fdemees
Posts: 30
Joined: Sunday 29 March 2020 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Belgium, close to Brussels
Contact:

Re: Using P1-device form Dutch Homewizard

Post by fdemees »

Hello,

I am from Belgium. In our country we get the same model of smart meters as in Netherlands and other European countries, with the P1 port being a non-standard unidirectional reversed-polarity serial port, and a 5V power supply, fed via an RJ12.

I quickly purchased this device: https://smartgateways.nl/en/product/sma ... i-gateway/
2025-11-28 14_42_50-Smart Meter WiFi Gateway - SmartGateways.nl — Mozilla Firefox.png
2025-11-28 14_42_50-Smart Meter WiFi Gateway - SmartGateways.nl — Mozilla Firefox.png (61.09 KiB) Viewed 354 times
This device acts in a transparent way. Telnet to it, the TCP connection stays open and you receive every second a "telegram" containing all the readings of the meter.
In Domoticz you use the hardware "P1 Smart Meter with LAN interface" and it works fine.
However the small thingie is unreliable, loses often its Wifi connection and vanishes from the network. (*more on this later)

Finally I decided to replace it with the HomeWizard dongle https://www.homewizard.com/fr-be/p1-meter/ .
2025-11-28 14_43_18-Découvrez notre compteur Wi-Fi P1 ici - HomeWizard — Mozilla Firefox.png
2025-11-28 14_43_18-Découvrez notre compteur Wi-Fi P1 ici - HomeWizard — Mozilla Firefox.png (23.17 KiB) Viewed 354 times
It works quite differently. The digital meter feeds it every second, and it constantly stores the readings in its internal variables.
Your application has to poll the dongle via its API, the reply is formatted with JSON.

That's why I jump here in this thread which has been dormant some time.

I have found a plugin (github.com/Eraser3/HomeWizard-Wifi-p1-plugin).
I think that it does more or less the same as the LUA poller mentioned above.

The plugin works but I will have to dig in the code, because the electricity consumption shown in Dz is ten times the real value.

(*) about the Wifi problems and SmartGateways.nl -- I have deployed a Mesh wifi network in my home, with 3 routers. All 3 have the same SSID and same credentials, and support from 802.11 b/g/n up to Wifi 6.
The basic 802.11 devices such as ESP's discover multiple independent routers instead of a unique entity. Maybe did the dongle try to switch from one router to another, as two of them are in the range of my basement ? No logfile, no display, no diagnostic possible.
Domoticz on Rpi 3B+, ZigbeeforDomoticz, Sonoff Zigbee coordinator, several Sonoff/ESPEasy/Tasmota, IPX800, several Zigbee things, Ksenia Lares
User avatar
waltervl
Posts: 6678
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Using P1-device form Dutch Homewizard

Post by waltervl »

for the plugin, also check topic viewtopic.php?p=293717#p293717
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
fdemees
Posts: 30
Joined: Sunday 29 March 2020 17:33
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.7
Location: Belgium, close to Brussels
Contact:

Re: Using P1-device form Dutch Homewizard

Post by fdemees »

waltervl wrote: Friday 28 November 2025 15:22 for the plugin, also check topic viewtopic.php?p=293717#p293717
Thanks @waltervl ;) Unfortunately there is no useful info for me in this thread.

The Homewizard dongle reports correct values for instant watt consumption, but Domoticz shows values multiplied by 10 (except in the device log).
So the hardware is not to be blamed.

The plugin has initially created a device of Type=243, Subtype=29 . Is this correct ? Where can I find a reference of Types and Subtypes ?

Anyway thanks for your reply !
Domoticz on Rpi 3B+, ZigbeeforDomoticz, Sonoff Zigbee coordinator, several Sonoff/ESPEasy/Tasmota, IPX800, several Zigbee things, Ksenia Lares
azonneveld
Posts: 179
Joined: Wednesday 02 October 2019 7:37
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Location: Netherlands
Contact:

Re: Using P1-device form Dutch Homewizard

Post by azonneveld »

See my earlier post
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