The short answer is that it is possible to get those values. There are two different facilities for extracting data, and it will depend on what you want/need.
I do intend to document the data extraction API, but I have been holding off because what is there now is just a modification of the Emoncms get/feed/data API and maybe could be made more flexible and SQL like. Havenāt had time to think that through, so maybe the way forward is to document the existing APIs and plan to leave them in place if I add newer ones.
But back to your problem. In the subsequent post you are using the status API to get input and output values. That can work but you have already picked up on the problem that input channels are numbered and donāt have the names included in the Json. But the real problem with the status API is that the value is damped, so it is not a true indication of the present measurement. It is intended for use in the status display, not for record keeping. Also, it doesnāt matter what you specify for inputs=, you will get all of the inputs. Same for outputs.
I think the most useful API is the modified feed APIās that are used by the graph program. It can provide accurately timed data for one or more time periods, and for one or more inputs/outputs by name. IoTaWatt has implemented only a subset of those APIs:
feed/list.json will return a Json feed list just as Emoncms does. The difference is in the values for the various Json objects: The ātagā object, which is used by Emoncms to provide node, is used to specify which tab to organize by - Voltage, Power, Energy, Other.
The ID object, used by Emoncms to pass the feed ID, is the ID by which IoTaWatt will identify the input or output. The first character is āIā or āOā to indicate Input or Output. The second character is āVā for Voltage, āPā for Power, āEā for Energy, āOā for Other. The rest of the ID is the same as the ānameā object. So if you have an input name ākitchenā the ID to get power (Watts) wouold be āIPkitchenā. To get cumulative kWh use āIEkitchenā.
These feed/data.json requests from Emoncms are supported, with a few modifications:
- The ID can be a single input/output or it can be a Json array of IDs.
- The times can be UNIXTIME_MILLISECONDS as specified, or they can be UNIXTIME_SECONDS.
- Because the ID can be an array, the returned data is a json array of arrays with the inner arrays being an array of the values for the requested IDs at that time.
- Finally, unlike Emoncms, IoTaWatt does not return the UNIXTIME_MILLISECONDS for each interval. The requester should know what they asked for, and should be able to understand the response. Itās hugely redundant and adds more than 13K to the response. The IoTaWatt graph adaptation does all this easily.
So to use this to get current values, you need to know the current unixtime rounded to a five second interval (ending in 0 or 5). You can ask for one measurement by setting start and end to the same value, and interval to the time period that you want an average value for. So for instance if you are going to request the value every 15 seconds, you would set interval to 15 so that the value returned would be the average for the last 15 seconds.
Sorry if this is a bit rambling, but I wanted to give you something to go on. There is always the code as well. The feed/list.json handler is in module webServer.cpp. Itās pretty straightforward making extensive use of arduinojson.
The feed/data.json handler is the getFeedData.cpp module. Itās maybe a little harder to follow because it rolls itās own Json and does chunked response, but the setup code in the beginning is pretty easy to follow and thatās what parses the request.