Page 1 of 1

Restoring Homewizard (LUA) after crash and restore

Posted: Thursday 11 December 2025 20:51
by WilcoEHV
Hi,
Thanks for the previous support on the z-wave issue!
Now I'm hoping for some help on my Homewizard hardware.

Last week my sd card got corrupted so i did a fresh install and restored a recent backup.
Previously I was on OS Bullseye (RAPI 3b) and Domoticz 2025.1. After restoring I'm on Bookworm and 2025.2 (and still on RAPI 3b).

I have a homewizard P1 plug and a watermeter wich I had previously up and running with a LUA script.
Attached is a screenshot of my HW P1 under hardware. It's the same as before the crash, I don't think there's something wrong with it.

Previously I made a LUA script with a txt editor somewhere on my RAPI, don't know anymore where but after the fresh install it's gone.
I've read that a LUA script also can be under settings --> more options --> events so I made a LUA script there called P1; is this correct or what do i need to change?
I'm hoping this works this way so it is part of future backups.

Furthermore I found a script on this forum. I recycled it and changed the IDX to the IDX of my hardware and the device names to their name under devices, but nothing is happening with te meters nor is there happening anything under the settings --> devices.
Is the code under here correct?
Thx!

Code: Select all

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

--
-- HW Gas
--
local idGas = 15954
local a = domoticz_applyJsonPath(s,'.total_gas_m3')
domoticz_updateDevice(idGas,'',a*1000)

--
-- HW Elektra 2
--

-- 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 = 15956
domoticz_updateDevice(idEnergy,'',b*1000 ..";"..c*1000 ..";"..d..";"..e..";"..f..";"..'0')
------ END ------}

-- loop through all the changed variables
for variableName,variableValue in pairs(uservariablechanged) do
    print ("Variable based event fired on '"..variableName.."', value '"..tostring(variableValue).."'");
--    if (variableName=='myVariable') then
--        if variableValue == 1 then
--            commandArray['a device name'] = "On"
--            commandArray['another device name'] = "Off AFTER 10"
--  	    commandArray['Variable:myVariable'] = 'new value'
--        end
--    end
end

Re: Restoring Homewizard (LUA) after crash and restore

Posted: Thursday 11 December 2025 21:44
by waltervl
For the HTTP Poller hardware look at the wiki https://wiki.domoticz.com/HTTP/HTTPS_poller

The P1.lua script has to be placed in folder domoticz/scripts/lua_parsers

In your domoticz log there should be errors like
Error: CLuaHandler: cannot open /home/.../domoticz/scripts/lua_parsers/P1: No such file or directory

That should also give you a clue....

Re: Restoring Homewizard (LUA) after crash and restore

Posted: Friday 12 December 2025 20:56
by WilcoEHV
Thx for the help!
Put the lua script above here in the mentioned folder and got energy/ gas meter up and running.
Hopefully it registers not only delivery but als return delivery.

By the same way I got my watermeter (Homewizard, http poller) up and running.
Waterflow registers correct but usage is not ok. The device is being updated on the utility tab so there is a active connection.
I just used ~10 ltrs of water but the meter still registers 0.
Previously it would have registered that usage.
Should I multiply the registerd value somewhere? In the LUA?

This is the LUA i'm currently use.

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

--
-- Watermeter
--
local idWater = 15942
local m = domoticz_applyJsonPath(s,'.active_liter_lpm')
domoticz_updateDevice(idWater,'',m)

local idWaterTotaal = 15944
local n = domoticz_applyJsonPath(s,'.total_liter_m3')
domoticz_updateDevice(idWaterTotaal,'',n)

Re: Restoring Homewizard (LUA) after crash and restore

Posted: Friday 12 December 2025 23:06
by waltervl
It also depends on your counter divider value in menu Setup - settings - tab counters . It should be 1000 if you supply liters.

See also https://wiki.domoticz.com/Dummy_for_vir ... es#Counter