update historic data via api

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
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

update historic data via api

Post by JanJaap »

I had a problem with the plugin for one of my solarpanels. I have the data from the app and now want to load that via the json api as per instructions here:
https://wiki.domoticz.com/Domoticz_API/ ... ed_counter

So I compile the following URL:
http://<my ip>:8080/json.htm?type=command&param=udevice&idx=490&nvalue=0&svalue=5349003;26900;2025-05-22

Response in the browser:
Schermafbeelding 2025-06-04 221836.png
Schermafbeelding 2025-06-04 221836.png (2.78 KiB) Viewed 308 times
However no data added for May 22:
Schermafbeelding 2025-06-04 221931.png
Schermafbeelding 2025-06-04 221931.png (44.31 KiB) Viewed 308 times
What am I doing wrong? Tried for different date's, same result
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: update historic data via api

Post by waltervl »

Is there already data for the 25th? Because then you will get 2 database entries for the same date in the meter_calendar table and that cause trouble. It will not over write the data it will add an entry and probably just use the first one it will find (the old one)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: update historic data via api

Post by JanJaap »

ok, so I deleted the 0 data via the json api successfully. Shows now the following on:
http://<my iP>:8080/json.htm?type=command&param=graph&sensor=counter&idx=490&range=2025-05-17T2025-05-25
Schermafbeelding 2025-06-14 215204.png
Schermafbeelding 2025-06-14 215204.png (19.23 KiB) Viewed 220 times
but when trying to update a value for the 18th using:
http://<my ip>:8080/json.htm?type=command&param=udevice&idx=490&nvalue=0&svalue=5247603;17600;2025-05-18
and reply:
Schermafbeelding 2025-06-14 215347.png
Schermafbeelding 2025-06-14 215347.png (1.94 KiB) Viewed 220 times
Then there is no change still. Not in the graph, not in the API. Any idea's?
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: update historic data via api

Post by jvdz »

http://<my ip>:8080/json.htm?type=command&param=udevice&idx=490&nvalue=0&svalue=5247603;17600;2025-05-18
This is just updating that actual sValue of the device with (probably) invalid data, but not as you expect do an update for a certain date in the history.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: update historic data via api

Post by JanJaap »

Wel it is listed as the option to update the device history on the wiki. So I would expect updating the svalue to be reflected in the graph?

Additionally, I'd expect a NOK on invalid data (but maybe that's just me being optimistic ;) )
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
jvdz
Posts: 2328
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: update historic data via api

Post by jvdz »

JanJaap wrote: Saturday 14 June 2025 22:27 Wel it is listed as the option to update the device history on the wiki. So I would expect updating the svalue to be reflected in the graph?
You're right ..... I see it now too and learned something today. Sorry about that.
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: update historic data via api

Post by JanJaap »

OK I ran some test with bogus data: Still getting the same, nice 'ok' reply so guess that does not give much guidance......
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: update historic data via api

Post by waltervl »

Check the database values. I think update here means adding a row for that date as I explained before. So not overwriting the existing value. At least that is what happens on my counter device that I maintain this way.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
JanJaap
Posts: 215
Joined: Thursday 12 October 2017 20:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Dev
Location: the Netherlands
Contact:

Re: update historic data via api

Post by JanJaap »

That's just what i did: delete the old values first, check (on te api) there's no value and the try to onsert e new one. Still, no success. Can you share you're method?
RPi 3, Domoticz dev version, Aeon ZWave stick (with a whole bunch of slaves), Zigbee using Zigbee2MQTT, Nest thermo, P1 smart meter on RPi Zero
User avatar
waltervl
Posts: 5842
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: update historic data via api

Post by waltervl »

I use the same method as you for a kwh General Instant and counter device::

Code: Select all

http://MY-IP:8080/json.htm?type=command&param=udevice&idx=407&nvalue=0&svalue=187721000;-368000;2025-05-31
The value will always be added to the end of the table so it depends of the sorting you use when you see it.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Kedi
Posts: 575
Joined: Monday 20 March 2023 14:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Somewhere in NL
Contact:

Re: update historic data via api

Post by Kedi »

My solution is add the missing or change wrong data in the right table with 'phpliteadmin.php' manually, and that did always work so far.
You have to install the php file which you will find here: https://www.phpliteadmin.org/download/
On some distributions you can just install it.
Logic will get you from A to B. Imagination will take you everywhere.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest