Page 1 of 1

District warming

Posted: Wednesday 31 January 2024 10:17
by remko2000
I managed to read all the data from my Kamstrup 601. I now see, among other things, the total consumption in GJ. However, I also want to see what my daily consumption is. What is the simplest way to add this to domoticz with an extra dummy sensor?

Re: District warming

Posted: Wednesday 31 January 2024 12:23
by waltervl
If you use the proper Domoticz device you should see your daily consumption already.
What device do you use to monitor the heating?

Re: District warming

Posted: Wednesday 31 January 2024 12:48
by remko2000

Re: District warming

Posted: Wednesday 31 January 2024 13:22
by waltervl
Yes, that is a bummer... They instruct to make custom sensors instead of counters for Heating GJ.

Better try to have them change that.

Can you post a couple of JSON messages from your meter trough

Code: Select all

http://ip_address_gateway:82/kamst-ir/api/read
Lets see if we can make up something.

Re: District warming

Posted: Wednesday 31 January 2024 13:35
by remko2000
yes that is exactly the problem. But isn't it possible to work around this with, for example, some kind of script that passes the volume of the current day to a separate day counter?

Re: District warming

Posted: Wednesday 31 January 2024 13:51
by waltervl
I am wondering what data this sensor creates. So that is why I asked for some sample jsons from you.

Re: District warming

Posted: Wednesday 31 January 2024 14:09
by waltervl
The most interesting value is heat_energy. Is that an increasing value over days or is it reset to 0 every day?

Re: District warming

Posted: Wednesday 31 January 2024 14:19
by remko2000
The rest api gives me this:
{"mac_address":"C0_49_EF_CE_E6_C4","gateway_model":"connectix_kamst-ir_gateway_v1.0","startup_time":"2024-01-27T19:05:12Z","firmware_running":"2024011002","firmware_available":"2024011002","firmware_update_available":"false","wifi_rssi":"-48","mqtt_configured":"false","heat_energy":"210.310","power":"0.000","temp1":"59.16","temp2":"51.24","tempdiff":"7.92","flow":"0.00","volume":"1491.420","minflow_m":"0.00","maxflow_m":"441.00","minflowdate_m":"240109.00","maxflowdate_m":"240109.00","minpower_m":"0.00","maxpower_m":"18.10","avgtemp2_m":"42.00","minpowerdate_m":"240101.00","maxpowerdate_m":"240109.00","minflow_y":"0.00","maxflow_y":"441.00","minflowdate_y":"240109.00","maxflowdate_y":"240109.00","minpower_y":"0.00","maxpower_y":"18.10","avgtemp1_y":"18.10","avgtemp2_y":"42.00","minpowerdate_y":"240101.00","maxpowerdate_y":"240109.00","temp1xm3":"109199.00","temp2xm3":"57580.00","infoevent":"1.00","hourcounter":"116625.00","power_act":""}
I think my kamstrup gives me every 900 sec a total of 'heat energy'

Re: District warming

Posted: Wednesday 31 January 2024 15:00
by waltervl
Thanks!
Now the issue is, what does "heat_energy":"210.310" mean? Is it the Energy used for today or the total Energy value from when this meter is running? Similar like your electricity counter in your house.

So if tomorrow it shows for example "heat_energy":"210.710" It means you have used 210.710-210.310=0.400 GJ today. Then we can use this value for a counter.
If it tomorrow shows "heat_energy":"10.710" it means it is reset at night and you need scripting to get something done here.

Re: District warming

Posted: Wednesday 31 January 2024 15:34
by remko2000
210.310 is the total energy.
So if tomorrow it shows for example "heat_energy":"210.710" It means you have used 210.710-210.310=0.400 GJ today. Then we can use this value for a counter.
This is right.

Re: District warming

Posted: Wednesday 31 January 2024 16:21
by waltervl
Ah OK that seems promising

Then you could make a Dummy Counter named Heating (or what you wish) see also https://www.domoticz.com/wiki/Dummy_for ... es#Counter
After creation, press on Edit and make it a Custom Counter (type = Counter)
Value Quantity: Heating Energy
Value Units: GJ
Counter divider: 1000 (this is important).

Add in your Lua parser script kamstrup.lua in /domoticz/scripts/lua_parsers the following. It could be that the multiply 1000 line gives an error as the value is a string and perhaps not recognized as a fractal. Please report back if it gives an error.

Code: Select all

local idx = [IDX of new Counter]
local heat_energy = domoticz_applyJsonPath(request['content'], '.heat_energy')
heat_energy = heat_energy * 1000
domoticz_updateDevice(idx, '' , heat_energy)
First value could be high as it could report complete history. you can delete this high value the next day (shift+ mouse click on value in the Graph) and then you have normal values.

When everything works well you can delete the custom sensor and the lua code that fills this custom sensor.

Re: District warming

Posted: Wednesday 31 January 2024 16:49
by remko2000
Thx
what I have now

IDX 251 is called 'heat_energy' (and gives 210,31GJ)
IDX 263 is my new dummy, zie screenshot
Image

My code (in events, lua, type 'all'):

Code: Select all

local idx = 263
local heat_energy = domoticz_applyJsonPath(request['content'], '.heat_energy')
heat_energy = heat_energy * 1000
domoticz_updateDevice(idx, '251' , heat_energy)
I get an error:
' 2024-01-31 16:48:46.011 Error: EventSystem: in Dagtellerwarmte: [string "local idx = 263 ..."]:2: attempt to index a nil value (global 'request')'

Re: District warming

Posted: Wednesday 31 January 2024 16:54
by waltervl
remko2000 wrote: Wednesday 31 January 2024 16:49 Thx
what I have now

IDX 251 is called 'heat_energy' (and gives 210,31GJ)
IDX 263 is my new dummy, zie screenshot
Image

My code (in events, lua, type 'all'):

Code: Select all

local idx = 263
local heat_energy = domoticz_applyJsonPath(request['content'], '.heat_energy')
heat_energy = heat_energy * 1000
domoticz_updateDevice(idx, '251' , heat_energy)
I get an error:
' 2024-01-31 16:48:46.011 Error: EventSystem: in Dagtellerwarmte: [string "local idx = 263 ..."]:2: attempt to index a nil value (global 'request')'

Code: Select all

domoticz_updateDevice(idx, '251' , heat_energy)
should be

Code: Select all

domoticz_updateDevice(idx, '' , heat_energy)
You will have 2 Devices showing the GJ values. If it all works you can remove device 251 and the script part belonging to it.

Re: District warming

Posted: Wednesday 31 January 2024 17:03
by waltervl
Beside my previous remark. You should not create a new script!!!
You should modify the Lua parser script kamstrup.lua in /domoticz/scripts/lua_parsers that you created according this instruction: https://haprofs.com/kamstrup-multical-s ... -domoticz/

Re: District warming

Posted: Wednesday 31 January 2024 17:04
by remko2000
me wrong.

I changed it. Still error:
'2024-01-31 17:02:50.182 Error: EventSystem: in Dagtellerwarmte: [string "local idx = 263 ..."]:2: attempt to index a nil value (global 'request')'

Is LUA by events, type ' lua', type ' All' ......correct?

Re: District warming

Posted: Wednesday 31 January 2024 17:05
by waltervl
waltervl wrote: Wednesday 31 January 2024 17:03 Beside my previous remark. You should not create a new script!!!
You should modify the Lua parser script kamstrup.lua in /domoticz/scripts/lua_parsers that you created according this instruction: https://haprofs.com/kamstrup-multical-s ... -domoticz/

Re: District warming

Posted: Wednesday 31 January 2024 17:10
by remko2000
sorry.

I edit the script kamstrup.lua and add your script at the bottom. Now I get indeed:
Image

so far so good.....

Re: District warming

Posted: Wednesday 31 January 2024 17:33
by waltervl
Lets let it run for at least 2 days.

Re: District warming

Posted: Thursday 01 February 2024 17:38
by waltervl
So after 1 day, do you see some usage graphs in the log page now? Device page showing some normal results?

Re: District warming

Posted: Monday 05 February 2024 13:52
by connectix
waltervl wrote: Wednesday 31 January 2024 16:21 Ah OK that seems promising

Then you could make a Dummy Counter named Heating (or what you wish) see also https://www.domoticz.com/wiki/Dummy_for ... es#Counter
After creation, press on Edit and make it a Custom Counter (type = Counter)
Value Quantity: Heating Energy
Value Units: GJ
Counter divider: 1000 (this is important).

Add in your Lua parser script kamstrup.lua in /domoticz/scripts/lua_parsers the following. It could be that the multiply 1000 line gives an error as the value is a string and perhaps not recognized as a fractal. Please report back if it gives an error.

Code: Select all

local idx = [IDX of new Counter]
local heat_energy = domoticz_applyJsonPath(request['content'], '.heat_energy')
heat_energy = heat_energy * 1000
domoticz_updateDevice(idx, '' , heat_energy)
First value could be high as it could report complete history. you can delete this high value the next day (shift+ mouse click on value in the Graph) and then you have normal values.

When everything works well you can delete the custom sensor and the lua code that fills this custom sensor.
Hi Walter!

Thanks for the script adjustments. I updated the instruction for the Kamstrup Multical for Domoticz so other users can benefit from it too.
Keep up the good work!

Greetings, Roel