Restoring Homewizard (LUA) after crash and restore

Please use template to report bugs and problems. Post here your questions when not sure where else to post
Only for bugs in the Domoticz application! other problems go in different subforums!

Moderators: leecollings, remb0

Forum rules
Before posting here, make sure you are on the latest Beta or Stable version.
If you have problems related to the web gui, clear your browser cache + appcache first.

Use the following template when posting here:

Version: xxxx
Platform: xxxx
Plugin/Hardware: xxxx
Description:
.....

If you are having problems with scripts/blockly, always post the script (in a spoiler or code tag) or screenshots of your blockly

If you are replying, please do not quote images/code from the first post

Please mark your topic as Solved when the problem is solved.
Post Reply
WilcoEHV
Posts: 24
Joined: Monday 02 January 2023 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven
Contact:

Restoring Homewizard (LUA) after crash and restore

Post 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
Attachments
HW P1.png
HW P1.png (37.79 KiB) Viewed 71 times
Raspberry 3B with Raspberry PI OS
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Restoring Homewizard (LUA) after crash and restore

Post 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....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
WilcoEHV
Posts: 24
Joined: Monday 02 January 2023 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: 2025.1
Location: Eindhoven
Contact:

Re: Restoring Homewizard (LUA) after crash and restore

Post 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)
Raspberry 3B with Raspberry PI OS
User avatar
waltervl
Posts: 6676
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2025.1
Location: NL
Contact:

Re: Restoring Homewizard (LUA) after crash and restore

Post 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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: heggink and 1 guest