I just so happen to be working on a similar thing on a local Emoncms Version 10.2.6
I am working on a CRON job to retrieve data and put in a file.
I had to add Authorization: Bearer before the API key to get it to read.
Maybe you have a similar problem?
’
#!/bin/bash
#Enter the API Keys here
LOCAL_RO_KEY=‘xxxxxxxxxxxxxxxxxxxxxxxx’
Do you mean local “on the same machine” or “on the same LAN” to the device you are issuing the api call?
This is pointing at emoncms.org, not your local emoncms. You need to swap out the “emoncms.org” to your local emoncms IP or hostname.
Buhay’s suggestion is pointing at the local, as in the “same machine” since it uses the IP 127.0.0.1 (aka “this same” host as the api call is issued from) so if your local emoncms is on another device on your LAN you would again need to replace “127.0.0.1” with the IP or hostname of your local emoncms device.
Here some links to example scripts.
They may or may not help.
I referenced them because I am thinking about using scripting to send a email alert when Input Threshold is Reached.
Hello @poldom a good way of working out the correct API request is to first open the feed using the emoncms graph interface and then open your browsers Developer Tools > Network tab to see the requests made to create the graph.
You may need to click the ‘Reload’ button on the graph interface to see the first request:
Finally, after a lot of hours trying it, I have a new world of experiments to try.
One last question. Is it possible to generate a new feed, similar to the “use_kwh” one, but containing the data from a range of hours (for example, the energy used from 12:00 to 14:00)? Or it will be easier to retrieve this data from the general “use_kwh” feed?
Hello @poldom, the emoncms time of use app uses an API that I realise is not documented that may help with what you want to do. Again if you use the browser network tab you can see how it works.
The steps to load the time of use app are: Navigate to Apps, create new (+ New) then select the time of use app. Select a consumption feed and a cumulative kWh feed.
Note the paramaters in the /feed/data requests made.
The result gives the cumulative kWh value at midnight, 1am and 7am for each day. You can then work out what the consumption between 7am and 1am is by subtracting those values.