Start a new topic

Support for getting alarm time in Device API

Support for getting if an alarm is enabled and the time of the alarm would be a great addition to the Device API. It is now only possible to set the times which allows the LaMetric to be controlled, but my use case is the inverse, where I would like to be able to set the alarm on the LaMetric and use that information to create a wake-up light.


6 people like this idea

I have tried the request with the UUID - result:


 

{
  "errors": [
    {
      "message": "Resource not found"
    }
  ]
}

 I hope, that would be a support to get the alarm times in the future.

Piotr, looking at your post where you changed the output:  "[some-string-i-changed]". That's your UUID right? 


Could you try:

$ curl -X GET -u "dev" -H "Accept: application/json" -k \
  https://<device ip address>:4343/api/v2/device/apps/com.lametric.clock/YOUR-UUID
$ Enter host password for user 'dev': <device api key>

  

Thinking a bit more about it, mweb previously mentioned that he thinks that the undocumented v1 api is used by the LaMetric app. Did you install the LaMetric app, and made use of a username/password for that app?


After you have the LaMetric app installed on a phone/tablet and established a connection to you LaMetric with the app, could you try the v1 version of that cURL that mweb posted earlier? 

Allright, too bad I couldn't help out. Sweet on the ALFA, I'd be all ears to see what you'l get out of it!

I'm going to do some more reading, still think the solution is somewhere obvious.. Maybe create an own app and use it as an alarm?

Actually I curl-ed it twice, first with 3 alarms (all of them set but disabled), then added another enabled alarm... with the same result as posted.


As for the 2nd curl, it returns


{

    "errors":[

        {

            "message":"Authorization is required"

        }

    ]

}


after entering my api key. A while ago, I actually ordered an ALFA wifi adapter in order to "MITM" my lametric, but didn't have the time yet to setup a "sniffing" AP... another one for the "home projects" backlog ;-)

That's fast! Thanks! So no real output on the set Alarm, assuming you've set an alarm time?


Probably not going anywhere, but could you try this one:


$ curl -X GET -u "dev" -H "Accept: application/json" -k \
  https://<device ip address>:4343/api/v2/device/apps/com.lametric.clock/08b8eac21074f8f7e5a29f2855ba8060
$ Enter host password for user 'dev': <device api key>

 


curl-ing and entering the api key I get { "actions" : { "clock.alarm" : { "enabled" : { "data_type" : "bool", "name" : "enabled", "required" : false }, "time" : { "data_type" : "string", "format" : "[0-9]{2}:[0-9]{2}(?::[0-9]{2})?", "name" : "time", "required" : false }, "wake_with_radio" : { "data_type" : "bool", "name" : "wake_with_radio", "required" : false } }, "clock.clockface" : { "icon" : { "data_type" : "string", "name" : "icon", "required" : false }, "type" : { "data_type" : "string", "format" : "weather|page_a_day|custom|none", "name" : "type", "required" : false } } }, "package" : "com.lametric.clock", "title" : "Clock", "triggers" : { "alarm" : { "snooze" : { "data_type" : "bool", "name" : "snooze" } } }, "vendor" : "LaMetric", "version" : "2.2.17", "version_code" : "54", "widgets" : { "[some-string-i-changed]" : { "index" : 0, "package" : "com.lametric.clock", "settings" : { "_title" : "Uhr" } } } } GET returns Can't connect to [my-lametric-adress]:4343 (certificate verify failed) SSL connect attempt failed error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed at /usr/share/perl5/LWP/Protocol/http.pm line 50. When trying the latter in my browser, I get a prompt to enter credentials (user/password), with neither of my accound name/email adress combined with the api key resulting in a succesful login

Considering to buy a LaMetric for this specific functionality. Anyone tried this?


$ curl -X GET -u "dev" -H "Accept: application/json" -k \
  https://<device ip address>:4343/api/v2/device/apps/com.lametric.clock
$ Enter host password for user 'dev': <device api key>

 

or with REST:

 

GET https://<device ip address>:4343/api/v2/device/apps/com.lametric.clock

Accept: application/json

 Or could anyone share the output it gives?

Any updates on this topic?


I, too, would love to just get the current alarm status, i.e. if and for which time an alarm is set. When trying to access the v1 API, however, I'm prompted to provide username and password (at least via web browser); neither empty credentials, nor 'dev' as user and/or my API (v2) key as password let me get past the authorisation request, resulting in the  "message":"Authorization is required" problem already described. Using curl without specifying a user results in the same error..


@mweb: Mind letting us know if You get a credential prompt and if so, how You get past it?


1 person likes this

very strange. No idea why it does not work. I believe the undocumented v1 is used by the Lametric App.

All queries using v1 gives the same results.I can set an alarm through the API using v2 and that's works. But anything v1 doesn't

try with /api/v1/apps/com.lametric.clock

That's what I get : { "errors":[ { "message":"Resource not found" } ] }

I'm using the browser. Do you use https://local-lametric-ip/v1 ... ?
What is the response?

still not working. 

V1 API calls don't work for me apparently. Only v2.


are you using curl ?

Login or Signup to post a comment