baumi's blog

baumi's personal blog … Linux, OS X, Windows, Random things, …

smart-me.com REST API curl examples – Smart Meter for KAMSTRUP DK-8660 – EV solar charging – PV Überschussladen

For API documentation see https://smart-me.com/swagger/ui/index and/or https://www.any-api.com/smart_me_com/smart_me_com/docs/API_Description

Current energy usage (update every minute for free *or* every second for a small subscription fee or a one time payment, see https://web.smart-me.com/en/cloud-services-pricing/ …. also updates each second while running smart-me mobile app or website live data):

curl -s --user "username:password" -H "Accept: application/json" "https://smart-me.com:443/api/Values/a1b1c1d1-abcd-1234-abcd-a1b2c3e4g5h6"

example output:

{"DeviceId":"a1b1c1d1-abcd-1234-abcd-a1b2c3e4g5h6","Date":"2022-02-05T17:53:16.3596015Z","Values":[{"Obis":"1-0:1.8.0*255","Value":15492250.0},{"Obis":"1-0:2.8.0*255","Value":4154730.0},{"Obis":"1-0:1.8.1*255","Value":10728380.0},{"Obis":"1-0:1.8.2*255","Value":4763870.0},{"Obis":"1-0:1.8.3*255","Value":0.0},{"Obis":"1-0:1.8.4*255","Value":0.0},{"Obis":"1-0:2.8.1*255","Value":4153930.0},{"Obis":"1-0:2.8.2*255","Value":800.0},{"Obis":"1-0:2.8.3*255","Value":0.0},{"Obis":"1-0:2.8.4*255","Value":0.0},{"Obis":"1-0:1.7.0*255","Value":2456.0},{"Obis":"0-0:96.14.0*255","Value":1.0},{"Obis":"1-0:32.7.0*255","Value":236.0},{"Obis":"1-0:52.7.0*255","Value":235.0},{"Obis":"1-0:72.7.0*255","Value":236.0},{"Obis":"1-0:31.7.0*255","Value":1.07},{"Obis":"1-0:51.7.0*255","Value":7.89},{"Obis":"1-0:71.7.0*255","Value":2.18}]}

where

{"Obis":"1-0:1.7.0*255","Value":2623.0}

means 2623.0 Watt, i.e. 1-0:1.7.0*255 is what you are looking for (see Obis Codes). You can use jq to parse it, e.g.

curl -s --user "username:password" -H "Accept: application/json" "https://smart-me.com:443/api/Values/a1b1c1d1-abcd-1234-abcd-a1b2c3e4g5h6" | jq -r '.Values[] | select(.Obis == "1-0:1.7.0*255") | .Value'

outputs:
2623

for 2623 Watt …

Interesting Obis Codes:

1-0:1.7.0*255 Active Power Total (W)
1-0:32.7.0*255 Voltage Phase L1 (V)
1-0:52.7.0*255 Voltage Phase L2 (V)
1-0:72.7.0*255 Voltage Phase L3 (V)
1-0:11.7.0*255 Current Total (A)
1-0:31.7.0*255 Current Phase L1 (A)
1-0:51.7.0*255 Current Phase L2 (A)
1-0:71.7.0*255 Current Phase L3 (A)

Counter totals (updated once per minute):

curl -s --user "username:password" -H "Accept: application/json" "https://smart-me.com:443/api/MeterValues/a1b1c1d1-abcd-1234-abcd-a1b2c3e4g5h6?date=2022-2-5T15:00:01Z"

or simply:

curl -s --user "username:password" -H "Accept: application/json" "https://smart-me.com:443/api/MeterValues/a1b1c1d1-abcd-1234-abcd-a1b2c3e4g5h6?date=$(date --iso-8601=ns | cut -d ',' -f 1)Z"

Notes:
username:password are your https://web.smart-me.com/login/ credentials, and a1b1c1d1-abcd-1234-abcd-a1b2c3d4e5f6 is the GUID of your smart meter. You can obtain it by inspecting the network traffic in their web view.

This is what smart-me.com website is doing for their live view (needs login and /tmp/smart-me/cookies.txt set accordingly):

curl --cookie /tmp/smart-me/cookies.txt 'https://www.smart-me.com/Details/GetDetailsNew.ashx?id=abcdef01-1234-5678-9abc-0123456ab&language=de&energy=&all=false&_=1624455861846' \
-H 'authority: www.smart-me.com' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="98"' \
-H 'accept: application/xml, text/xml, */*; q=0.01' \
-H 'dnt: 1' \
-H 'x-requested-with: XMLHttpRequest' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36' \
-H 'sec-ch-ua-platform: "Linux"' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://www.smart-me.com/Details/V2/All.aspx' \
-H 'accept-language: de-DE,de;q=0.9,en;q=0.8,en-US;q=0.7,nl;q=0.6,da;q=0.5,fr;q=0.4,nb;q=0.3,es;q=0.2,it;q=0.1,lb;q=0.1' \
--compressed \
--silent

which would return:

Another alternative is creating a public link inside smart-me clientarea which creates html iframe for your meter, which itself is updating via repeated calls to https://www.smart-me.com/embed/GetData.ashx?id=f97c7fbb-b926-460d-a2b7-44a339a5e979 which will return XML that looks like this:

Comments are currently closed.