Page 1 of 1

How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 21:13
by imautohuttraeger
I have a “Hichi IR reading head” (Tasmota) attached to my electricity meter. Today I have three devices as shown in the Screenshot. All other Tasmota idx numbers are sending nothing.

Now I want to merge everything to use it in the (phantastic) new Energy Dashboard - but how?

Thanks in advance for any hint.

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 22:28
by imautohuttraeger
OK, so let me simplify my question: Is it possible to use the data of a smart meter with infrared-reading rather than P1?

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 22:37
by waltervl
You will have to make a dummy P1 meter and make a dzvents script that is combining the data of import and export and actual watt into this dummy P1 device.

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 22:42
by imautohuttraeger
Thx! Will try to deep dive into this. Is there any sample code for combining devices that I can use and make amendements?

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 23:33
by waltervl
Something like this (not tested and could have type errors

Code: Select all

return {

	on = {
	    timer = { 'every 1 minutes' }
	},
	
	execute = function(domoticz, item)
	    
	    local importcounter = domoticz.devices(111) 
	    local exportcounter= domoticz.devices(222) 
	    local poweractual= domoticz.devices(333)
	    local dummyP1 = domoticz.devices(444)
	    local actualusage = 0
	    local actualprod = 0
	            
	    if poweractual.actualWatt < 0 then 
	                actualprod = 0 - poweractual.actualWatt
	        else
	                 actualusage = poweractual.actualWatt 
	     end
	    dummyP1.updateP1(importcounter.WhTotal,0,
	    exportcounter.WhTotal,0,actualusage,actualprod)
	    
    end
}

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Friday 12 July 2024 23:51
by imautohuttraeger
I am afk now but saw your reply on the smartphone. Wow! Thank you very much. Will adopt this maybe even tomorrow and give feedback. I am pretty sure that you have saved my live (once again).

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Saturday 13 July 2024 12:49
by imautohuttraeger
I have added the hardware "P1 Smart Meter with LAN interface" with the IP-adresse of the tasmota IR reading head and Port 80 (8080 like shown in the wiki gives an error in the logfile) - Screenshot attached

Then I have created the dummy P1 device and it looks OK (still with zero values of course) - Screenshot attached

But the following error occurs:
Error: GetJSonDevices: exception occurred : 'stoull'

When I then activate the script (I only replaced the idx numbers, see code), Domoticz is freezed.
I have to restart Domoticz via SSH terminal and quickly deactivate the script in Domoticz to avoid further freezing. The dummy P1 device then has a reduced appearance - Screenshot attached.

Code: Select all

return {

	on = {
	    timer = { 'every 1 minutes' }
	},
	
	execute = function(domoticz, item)
	    
	    local importcounter = domoticz.devices(367) 
	    local exportcounter= domoticz.devices(362) 
	    local poweractual= domoticz.devices(447)
	    local dummyP1 = domoticz.devices(448)
	    local actualusage = 0
	    local actualprod = 0
	            
	    if poweractual.actualWatt < 0 then 
	                actualprod = 0 - poweractual.actualWatt
	        else
	                 actualusage = poweractual.actualWatt 
	     end
	    dummyP1.updateP1(importcounter.WhTotal,0,
	    exportcounter.WhTotal,0,actualusage,actualprod)
	    
    end
}
And after the restart of Domoticz, a new error occurs (every 5 minutes):
Error: UpdateMultiMeter: Error converting sValue values! (IDX: 448, sValue: 'nil;0;nil;0;502.6;0', dType: 250, sType: 1)

Sorry that I can only provide this amateurish information... Any idea?

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Saturday 13 July 2024 19:53
by waltervl
The P1 hardware gateway is not needed you can remove it. It will automatically remove the associated P1 device. You only need the dummy P1 device.

Also make sure you fill in the correct device IDX numbers.
Also it seems the export device uses negative counter values, a P1 cannot handle that. So perhaps also invert that to a positivevalue ( 0 - negativevalue).

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Sunday 14 July 2024 11:56
by imautohuttraeger
Merci!

OK, I have deleted the P1 hardware gateway.

Meanwhile I have made some trial an errors an found out, that

actualusage and actualprod and poweractual

are working fine and the dashboard flows as expected. Only the counters

importcounter and exportcounter

are causing domoticz to crash. Eleminating the negative value for export is not the cause. Maybe it's because the counters only count up whole numbers step by step. But I can't find where to change that.

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Sunday 14 July 2024 12:51
by waltervl
Ah, I think I made a mistake here, these counters are real counters and not electric devices

Modify the updateP1 command into

Code: Select all

dummyP1.updateP1(importcounter.counter,0,
	    exportcounter.counter,0,actualusage,actualprod)
It still could give negative values for export counter so perhaps this could also work

Code: Select all

dummyP1.updateP1(importcounter.counter,0,
	    (exportcounter.counter * -1),0,actualusage,actualprod)

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Sunday 14 July 2024 18:56
by imautohuttraeger
Bingo! This was the essential hint. Rather than .counter I took .counterToday and now everything is perfekt.

In case someone somewhen is stumbling over this post and needs inspiration, I wright down the final code that works in my case:

Code: Select all

return {
    
    on = {
		devices = {
			367, 362, 447
		}
	},
	
	execute = function(domoticz, item)
	    
	    local importcounter = domoticz.devices(367) 
	    local exportcounter = domoticz.devices(362) 
	    local poweractual = domoticz.devices(447)
	    local dummyP1 = domoticz.devices(453)
	    local actualusage = 0
	    local actualprod = 0
	            
	    if poweractual.actualWatt < 0 then 
	                actualprod = 0 - poweractual.actualWatt
	        else
	                 actualusage = poweractual.actualWatt 
	     end
	    dummyP1.updateP1((importcounter.counterToday * 1000),0,
	    (exportcounter.counterToday * 1000),0,actualusage,actualprod)
	
	    
    end
}
waltervl: I am so grateful that you almost instantly helped me with your expert knowledge - thank you!

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Monday 15 July 2024 0:25
by waltervl
Do not use Countertoday!!!
It will give weird results on midnight. Use counter
And probably the * 1000 is also not needed unless counter is giving kWh instead of Wh.

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Monday 15 July 2024 10:16
by imautohuttraeger
But ".counter" gives (at least in my case) the total meter reading that has ever been measured since the meter was installed by the electricity supply company. Without any relation to a certain period of time. So ".counterTody" works here. Will watch what happes at midnight.

Maybe the basic data from my Domoticz counters that are fed by the Tasmota infrared reading head are different from the normal standard of P1 ...

According to multiplication by 1000: In the general setting for meters/counters I have to set a divider of 1000, otherwise the kWh figure of the house item in the energy dashboard is weird.

Everything seems to be a little bit confused in my system ...

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Monday 15 July 2024 10:48
by waltervl
counter should be updating during the days. Domoticz needs those rolling counters. It will calculate the daily values itself.
The first day you will get en extremely high value (the total unmeasured before). You can delete that high value after a couple of days so you will get normal graphs again.
Delete value with shift-click on the value in the graph

Re: How to use "Hichi" IR head with new energy dashboard?

Posted: Monday 15 July 2024 11:53
by imautohuttraeger
Yes, the counter update seems to work and went to Zero at midnight. Let's see during the next days how the rolling count will work.

And I was even already able to delete the starting value with shift click.