Update / Replace value in database Topic is solved

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Update / Replace value in database

Post by PieterS »

I run Domoticz V4.9700 on a Synology with DSM 6.2

Since yesterday I can do a scheduled upload of the value of my gassensor to Mindergas.nl. But that is not the actual value of the gasmeter itself. Reason is that the sensor is there for about a year.. :|
So time to replace the value in the database (703.357m3) to the real value of the gasmeter. That is 34997,463m3

In the wiki on https://www.domoticz.com/wiki/Domoticz_ ... _URL's#Gas is written:
Gas

/json.htm?type=command&param=udevice&idx=IDX&nvalue=0&svalue=USAGE

USAGE= Gas usage in liter (1000 liter = 1 m³)

So if your gas meter shows f.i. 145,332 m³ you should send 145332.
The USAGE is the total usage in liters from start, not f.i. the daily usage.
So I think my command to replace the gasvalue should be:

Code: Select all

http://xxx.xxx.xxx.xxx:8084/json.htm?type=command&param=udevice&idx=734&nvalue=0&svalue=34997463
This is the screenshot before the command in my browser:
Image

And is the result of the JSON-command:

Code: Select all

curl -s “http://xxx.xxx.xxx.xxx:8084/json.htm?type=devices&rid=734

Code: Select all

{
   "ActTime" : 1548613479,
   "AstrTwilightEnd" : "19:15",
   "AstrTwilightStart" : "06:27",
   "CivTwilightEnd" : "17:55",
   "CivTwilightStart" : "07:47",
   "DayLength" : "08:55",
   "NautTwilightEnd" : "18:36",
   "NautTwilightStart" : "07:06",
   "ServerTime" : "2019-01-27 19:24:39",
   "SunAtSouth" : "12:05",
   "Sunrise" : "08:23",
   "Sunset" : "17:18",
   "app_version" : "4.9700",
   "result" : [
      {
         "AddjMulti" : 1.0,
         "AddjMulti2" : 1.0,
         "AddjValue" : 0.0,
         "AddjValue2" : 0.0,
         "BatteryLevel" : 255,
         "Counter" : "702.857m3",
         "CounterToday" : "4.23 m3",
         "CustomImage" : 0,
         "Data" : "702.857m3",
         "Description" : "Via ESP8266 unit 4",
         "Favorite" : 1,
         "HardwareID" : 21,
         "HardwareName" : "Gasmeter",
         "HardwareType" : "Dummy (Does nothing, use for virtual switches only)",
         "HardwareTypeVal" : 15,
         "HaveTimeout" : false,
         "ID" : "82734",
         "LastUpdate" : "2019-01-27 19:24:36",
         "Name" : "Gasmeter",
         "Notifications" : "false",
         "PlanID" : "0",
         "PlanIDs" : [ 0 ],
         "Protected" : false,
         "ShowNotifications" : true,
         "SignalLevel" : "-",
         "SubType" : "Counter Incremental",
         "SwitchTypeVal" : 1,
         "Timers" : "false",
         "Type" : "General",
         "TypeImg" : "counter",
         "Unit" : 1,
         "Used" : 1,
         "ValueQuantity" : "",
         "ValueUnits" : "",
         "XOffset" : "0",
         "YOffset" : "0",
         "idx" : "734"
      }
   ],
   "status" : "OK",
   "title" : "Devices"
}
When I try to replace the value of the Device Gasmeter with IDX 734 I got wrong results with the value 34997463:

Image

It looks that there is a mix of Counter today and the total counter

I don't understand what I did wrong. Who can explain what's wrong and give a solution? :roll:

Thanks in advance!
Synology with Domoticz build (V2024.7) in Docker
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Update / Replace value in database

Post by waaren »

PieterS wrote: Sunday 27 January 2019 19:47

Code: Select all

http://xxx.xxx.xxx.xxx:8084/json.htm?type=command&param=udevice&idx=734&nvalue=0&svalue=34997463
When I try to replace the value of the Device Gasmeter with IDX 734 I got wrong results with the value 34997463:
I don't understand what I did wrong. Who can explain what's wrong and give a solution? :roll:
Some meters and counters in domoticz use dividers to correct the decimal point position or amount of zero's of incoming values. You set these dividers in the GUI via [setup] [settings][meters/counters]On my system the divider for Gas is 10000.
if I set my gasmeter 2461976 with the json you describe the Gas device will show 2461.976
The day total displayed on the GUI is a calculation of the current value minus the value
If I look in the domoticz database I see for my gas device:

Code: Select all

select sValue from devicestatus where id=36;
sValue
2461976

select Counter,Date from meter_calendar where devicerowid = 36 and date = "2019-01-27";
Counter|Date
2461808|2019-01-27
And my daytotal on the GUI shows 0.168 M3 // which is (2461808 - 2361976) /1000
I have no idea why domoticz calculates with 1000 when I set the divider to 10000 but it does and if you know that it does not matter anymore.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
PieterS
Posts: 197
Joined: Wednesday 31 May 2017 16:06
Target OS: NAS (Synology & others)
Domoticz version: 2024.7
Location: NL
Contact:

Re: Update / Replace value in database

Post by PieterS »

Thanks Waaren for reply. It didn't help much to solve my problem.. I did a check on my system: Gas is set to 100 but gives good results for readings.

I figured out what happens when I use a simple value in the command:

Code: Select all

http://xxx.xxx.xxx.xxx:8084/json.htm?type=command&param=udevice&idx=734&nvalue=0&svalue=1000
It added 10 m3 to the counter Today and also to the Total Counter.
So when I add the difference what is needed to get the right total usage at my gasmeter than my problem is solved. :idea:
Quick and dirty. :geek:

The only problem is the resolution of the value in the dashboard. It has less decimals. :roll:
Synology with Domoticz build (V2024.7) in Docker
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest