How to start with "offline" counters (water, gas, electricity)?

On various Hardware and OS systems: pi / windows / routers / nas, etc

Moderator: leecollings

Post Reply
Nafetz
Posts: 4
Joined: Saturday 20 November 2021 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to start with "offline" counters (water, gas, electricity)?

Post by Nafetz »

Hi,

last week I "found" Domoticz, installed it on a Raspberry Pi and wanted to dive into first steps and some offline counters.

But I cant get them to work properly. This is what I did:
  • I created a hardware item for every counter with type "Dummy"
  • Then I created a device for every hardware item (Types RFXMeterCounter with Energy, Gas and Water)
  • Every day at about 7 pm I enter the value of the counter by sending /json.htm?type=command&param=udevice&idx=MyID&svalue=MyValue

And this is what is happening:
  • A few seconds later I see the usage of the day in the first line of the device item
  • Beside the icon I can see the counter value that I entered
  • In the log diagram I can see the value of the usage
But the next morning the usage value is set to 0 and has disappeared from the log diagram. Sometimes this happens every second day.
For example if I have a usage of 25 every day I will get a report like this:
  • Wednesday: Counter 100, Usage 0
  • Thursday: Counter 100, Usage 25
  • Friday: Counter 150, Usage 0
  • Saturday: Counter 150, Usage 25
The counter values of Wednesday and Friday are correct and the usage of Thursday and Saturday.

What am I doing wrong? Or is it impossible to use Domoticz this way?

Best regards, Stefan
homeJLB
Posts: 53
Joined: Tuesday 16 October 2018 23:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by homeJLB »

I think you need to use icremental counter instead off just counter
I use incremental counter and a puls sensor for counting up
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by waltervl »

If you use the normal counter you have to send the total counter value (like what you see on the physical counter).

Like every day usage 25, you send
Day 1: 25
Day 2: 50
Day 3: 75
Day 4: 100
Etc

If you do not know these total values you have to use the incremental counter and send 25 each day.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Nafetz
Posts: 4
Joined: Saturday 20 November 2021 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by Nafetz »

Thank you very much for helping!

I would prefer to send the total values per day. In my tests the incremental counter expected usage values.
waltervl wrote: Saturday 20 November 2021 14:59 Like every day usage 25, you send
Day 1: 25
Day 2: 50
Day 3: 75
Day 4: 100
Etc
That's what I did ...

Here the situation after today's update of new values in the example of my solar panel's counter
report1.png
report1.png (55.7 KiB) Viewed 1317 times
report2.png
report2.png (45.61 KiB) Viewed 1317 times
At the moment the last value is still visible, but it might disappear this night. I don't know why Sunday's and Thursday's values are still here and the other values not. The values I entered can be seen in the attachment below (Table "Meter_Calendar"). Today I entered 72964070

In the sqlite Database I have this situation
db1.png
db1.png (23.04 KiB) Viewed 1317 times
Is it possible that the database entry in the table "Meter" without the timestamp is deleting the usage at midnight? And so the value "0" is transported into the table "Meter_Calendar"? But why?
Nafetz
Posts: 4
Joined: Saturday 20 November 2021 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by Nafetz »

As expected: I got an automatic entry probably at midnight into the database table "Meter". Now my usage values from yesterday have disappeared this morning:
report3.png
report3.png (54.86 KiB) Viewed 1288 times
report4.png
report4.png (17.64 KiB) Viewed 1288 times
db5.png
db5.png (21.2 KiB) Viewed 1288 times
User avatar
waltervl
Posts: 5149
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by waltervl »

When you use an incremental counter you use

Code: Select all

/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=USAGE
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Nafetz
Posts: 4
Joined: Saturday 20 November 2021 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to start with "offline" counters (water, gas, electricity)?

Post by Nafetz »

Thank you very much.

I decided yesterday to use "Managed counters" and submit data with DzVents into the database table "Meter_Calendar".
So I created eight user variables (integer) for my four counters and one user variable (string) for the date.

So e.g. for the power counter I have powerCounter_new and powerCounter_old. Additional I have myDate.
As soon as I update the date variable, the script is passing my values of the counter variables.
(If I would manage to read the counter values of the database then the variable powerCounter_old would be not necessary. But I couldn't so far)

The script looks like this:

Code: Select all

return {
    active = true;
	on = {
		variables = {
			'myDate'
		}
	},
	execute = function(domoticz, variable)
          local powerCounter = domoticz.devices(457)
          powerCounter.updateHistory(domoticz.variables('myDate').value, tostring(tonumber(domoticz.variables('powerCounter_new').value))..';'..tostring(tonumber(domoticz.variables('powerCounter_new').value)-tonumber(domoticz.variables('powerCounter_old').value)))
	 domoticz.log('Offline-counter was updated for '..tostring(domoticz.variables('myDate').value), domoticz.LOG_INFO)
	end
}
This works very well - even for historic data. Now I have accurate logs of my usage. And I don't get additional data at midnight. The counters are displayed like "dead" in the deashboard. But thats what I wanted - only statistics of the usage ;)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests