Reading incremental counters through svalues
Moderators: leecollings, remb0
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Reading incremental counters through svalues
Because my RS485-readout HAT at Raspberry went haywire,
no longer able to access my kWh-meters DDS238-1ZN via that route,
and obliged to find alternative routes.
The S0-interfaces being read by ESP8266s_with_ESPEasy it is not difficult to forward the values to virtual devices in Domoticz.
Other question is how to extract the data from those virtual devices.
The attached screenshots for 2 devices in Domoticz should be technically equivalent,
but question arises, how to extract 'meaningful' values from the svalue of the incremental counter.
[Note that (due to 'switch' at side of ESP8266), a small difference exists in the widgets,
because IDX=786 presently has no feed, while IDX=788 has an active feed]
Where to find an explanation for the layout of the svalue of the incremental counter?
no longer able to access my kWh-meters DDS238-1ZN via that route,
and obliged to find alternative routes.
The S0-interfaces being read by ESP8266s_with_ESPEasy it is not difficult to forward the values to virtual devices in Domoticz.
Other question is how to extract the data from those virtual devices.
The attached screenshots for 2 devices in Domoticz should be technically equivalent,
but question arises, how to extract 'meaningful' values from the svalue of the incremental counter.
[Note that (due to 'switch' at side of ESP8266), a small difference exists in the widgets,
because IDX=786 presently has no feed, while IDX=788 has an active feed]
Where to find an explanation for the layout of the svalue of the incremental counter?
Last edited by Toulon7559 on Wednesday 01 March 2023 19:45, edited 2 times in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
- waltervl
- Posts: 6689
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Reading incremental counters through svalues
Check wiki page https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Reading incremental counters through svalues
Walter,
Setting the virtual device Counter_incremental is not the question,
but reversely how to read&translate the very long string of digits in the svalue to values which represent Power or Energy, like the output from virtual device 'General,kWh'.
Or is the translation as simple as described below?
- read&store value n
- read subsequent value n+1 and the time between the values n and n+1
- subtract value n+1 and value n, determine elapsed time and scale to get output for Power and Energy like for counter 'General, kWh'
Kindly requested to be informed what is correct processing of the long digits-string of svalue Counter_incremental.
Just surprised that (for commonality) such processing not yet included in the generation of the svalue for Counter_incremental.
Setting the virtual device Counter_incremental is not the question,
but reversely how to read&translate the very long string of digits in the svalue to values which represent Power or Energy, like the output from virtual device 'General,kWh'.
Or is the translation as simple as described below?
- read&store value n
- read subsequent value n+1 and the time between the values n and n+1
- subtract value n+1 and value n, determine elapsed time and scale to get output for Power and Energy like for counter 'General, kWh'
Kindly requested to be informed what is correct processing of the long digits-string of svalue Counter_incremental.
Just surprised that (for commonality) such processing not yet included in the generation of the svalue for Counter_incremental.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
- waltervl
- Posts: 6689
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Reading incremental counters through svalues
I have never seen these strange values of incremental values. But I would not give too much value to the values in the event editor list. You are the first to ask this question, so why document?
Better check the device with an api call eg
/json.htm?type=devices&rid=IDX
Or read the source code. Or check with Lua or Dzvents what ere the values. Or even better check the SQLite database if you really feel into this.
Better check the device with an api call eg
/json.htm?type=devices&rid=IDX
Or read the source code. Or check with Lua or Dzvents what ere the values. Or even better check the SQLite database if you really feel into this.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Reading incremental counters through svalues
Walter,
Would not ask the question if just 1 Virtual Device of type Counter-incremental would show such strange svalue, but it happens at all similar Domoticz-instances being similarly fed by ESP8266s_ESPEasy which have counters reading S0-interfaces with setting Delta.
Already earlier tried
and
and that produces rather normal read-outs for CounterToday and Data, respectively for Counter and CounterToday.
However, RID=788 of type Incremental misses the output Usage (or similar), and therefore returned to have look at the layout of the svalue to find an alternative setup for data-extraction.
Anyway, perhaps found a circumventing solution by means of a small Python-script, but have to await testing tomorrow when the sun shines and the counters start ticking ......
Would not ask the question if just 1 Virtual Device of type Counter-incremental would show such strange svalue, but it happens at all similar Domoticz-instances being similarly fed by ESP8266s_ESPEasy which have counters reading S0-interfaces with setting Delta.
Already earlier tried
Code: Select all
http://192.168.0.182:8080/json.htm?type=devices&rid=786Code: Select all
http://192.168.0.182:8080/json.htm?type=devices&rid=788However, RID=788 of type Incremental misses the output Usage (or similar), and therefore returned to have look at the layout of the svalue to find an alternative setup for data-extraction.
Anyway, perhaps found a circumventing solution by means of a small Python-script, but have to await testing tomorrow when the sun shines and the counters start ticking ......
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
- waltervl
- Posts: 6689
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Reading incremental counters through svalues
Better find the root cause of the strange values. But if the api call gives normal values for the total counter (the rest is calculated by Domoticz) then it seems an issue in the event editor list.
Also check the method that the esp uses to send the data to Domoticz. Is it the S0 integration or a script or plugin or MQTT API call?
Also check the method that the esp uses to send the data to Domoticz. Is it the S0 integration or a script or plugin or MQTT API call?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Reading incremental counters through svalues
For commonality all ESP8266+ESPEasy operate with protocol = 'Domoticz_HTTP' for data transfer in the direction of Domoticz:
no problem, with (apparently) this one exception for Counter_incremental.
no problem, with (apparently) this one exception for Counter_incremental.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
- waltervl
- Posts: 6689
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Reading incremental counters through svalues
Perhaps you can find /trace /catch the http message that the esp counter device is sending to Domoticz? As this should clarify what happens.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Reading incremental counters through svalues
Perhaps found a pragmatic way out.
If the output of the ESP8266 is linked to a Virtual Device in Domoticz, the actual status & data can be read by the API-call
Required contents then to be extracted in a script, and derived values to be calculated based on those contents and auxiliary data.
In that way was able to get the Power-value from a Virtual Device only providing Energy-values,
because generally Energy = Power * Time => reversely Power = delta-Energy / delta-Time
S0PCM similarly is counting pulses from the S0-interface and periodically translating that in Power & Energy.
But
mind the bloody details of the calculations.
Now running tests to check that realistic Power-levels appear ......
The script to convert the Energy-values from a Virtual Device for an incremental kWh-meter towards applications asking Power and Energy has been laid out as described in this message: the dictionary in the json-file acts as 'persistent' data-storage for the previous values.
Periodically determine the difference between actual values and previous values, and you have required delta-values for Energy and for Time.
If that works, forget about extraction from the strange-looking s-values.
May3,2023:
Text edited, according to latest ideas.
If the output of the ESP8266 is linked to a Virtual Device in Domoticz, the actual status & data can be read by the API-call
Code: Select all
/json.htm?type=devices&rid=IDXIn that way was able to get the Power-value from a Virtual Device only providing Energy-values,
because generally Energy = Power * Time => reversely Power = delta-Energy / delta-Time
S0PCM similarly is counting pulses from the S0-interface and periodically translating that in Power & Energy.
But
Now running tests to check that realistic Power-levels appear ......
The script to convert the Energy-values from a Virtual Device for an incremental kWh-meter towards applications asking Power and Energy has been laid out as described in this message: the dictionary in the json-file acts as 'persistent' data-storage for the previous values.
Periodically determine the difference between actual values and previous values, and you have required delta-values for Energy and for Time.
If that works, forget about extraction from the strange-looking s-values.
May3,2023:
Text edited, according to latest ideas.
Last edited by Toulon7559 on Wednesday 03 May 2023 23:52, edited 7 times in total.
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
- waltervl
- Posts: 6689
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2025.1
- Location: NL
- Contact:
Re: Reading incremental counters through svalues
If your ESP device is only giving Watts as current usage/production you can use the Domoticz energy (instant and counter) device and put into the compute state and it will do the math for kWh for you. https://www.domoticz.com/wiki/Dummy_for ... counter.29
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
Toulon7559
- Posts: 859
- Joined: Sunday 23 February 2014 17:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: <2025
- Location: Hengelo(Ov)/NL
- Contact:
Re: Reading incremental counters through svalues
This is the JSON-file read from the subject ESP8266&ESPEasy.
.
Visible in the json-file that ESPEasy is not latest version, but seems no need to update for this setup:
from the sensors the basic, raw info is present.
Domoticz has the job to translate from the successively reported counter-values into the related VirtualDevice(s)' values for Power&Energy.
If the readout from Domoticz cannot be tweaked to get a Power-value,
as escape then perhaps in a script a direct translation from the periodically received 3 countervalues towards Power.
But seems a kind of duplication relative to Domoticz .......
Code: Select all
{"System":{
"Build": 146,
"Unit": 21,
"Uptime": 141,
"Free RAM": 23384
},
"Sensors":[
{
"TaskName": "ESP8266F_OLED"
},
{
"TaskName": "DHT22F",
"Temperature": 22.40,
"Humidity": 54.40
},
{
"TaskName": "Counter3_DDS238_Involar",
"Count3": 0.00,
"Total3": 63.75,
"Time3": 46188.00
},
{
"TaskName": "Rain_Analog",
"Analog": 12.10
},
{
"TaskName": "Sys_Info_VCC",
"": -1.00
}
]}Visible in the json-file that ESPEasy is not latest version, but seems no need to update for this setup:
from the sensors the basic, raw info is present.
Domoticz has the job to translate from the successively reported counter-values into the related VirtualDevice(s)' values for Power&Energy.
If the readout from Domoticz cannot be tweaked to get a Power-value,
as escape then perhaps in a script a direct translation from the periodically received 3 countervalues towards Power.
But seems a kind of duplication relative to Domoticz .......
Set1 = RPI-Zero+RFXCom433+S0PCM+Shield for BMP180/DS18B20/RS485+DDS238-1ZNs
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Set2 = RPI-3A++RFLinkGTW+ESP8266s+PWS_WS7000
Common = KAKUs+3*PVLogger+PWS_TFA_Nexus
plus series of 'satellites' for dedicated interfacing, monitoring & control.
Who is online
Users browsing this forum: Google [Bot] and 1 guest