Start a new topic

Ability to switch APP from API

Hi,


Currently the iOS/Android App allow you to switch between application. In order to integrate Lametric time in my home automation setup, I'd like to be able to switch from an application to another using the API.


For instance, I'd like to show blanc frame (like sleep mode for the screen) when nobody is at home. So this way I can save life time to the display.


What I have found so far:


The device provide the rest API through fastGCI scrip running on localhost, lighthttpd is taking care of the authentication:


  • First the client need to provide a client certificate in order to establish SSL connection (each application Android/iOS is embedding it's own cert)
  • Then a Basic user/password is required to use the internal API.


I'm pretty sure I can achieve to get access to the internal API but this is not the way to go.


Thanks to consider Internal API access :)



5 people like this idea

@Cyril Were you ever able to figure this out? I am trying to intercept some calls myself to be able to switch between applications programatically as well but I keep running into the SSL Client Cert error. Any luck in being able to spoof the cert, or even extracting it from the app so we can make REST calls ourselves to switch between applications?

The widget ID seems to be device specific, my ID for the countdown is different.


I wrote a simple PHP script for my local web-server that I call from my home automation setup and pass package and widget as URL variables (replace IP of LaMetric and API Key with your own in the script).

php
(840 Bytes)

Forgot to mention: package variable is only the last part as com.lametric always stays the same

Nice! 

For a NodeJS based app for the Homey (by Athom) platform i wrote this library: https://github.com/irritanterik/com.theswifties.lametric/blob/master/lib/lametric.js


It escapes the device/install unique widgetId by looking for the right widget. For example you can show a widget by:


var lametric = require('lametric.js')

lametric.device.showApp(ipv4, apiKey, 'com.lametric.clock')


Or set a timer with:


var lametric = require('lametric.js')

lametric.device.doAppAction(ipv4, apiKey, 'com.lametric.countdown', 'countdown.configure', {duration: 3600, start_now: true})

Also waiting for this. Really want to start timers with REST calls.

After the 1.7.3 changelog stated


"Extended local API that allows controlling device programmatically. Documentation on that is coming a little bit later."


I was curious and checked what changed and I found some new API endpoints which probably allow switching between apps and setting timers/countdowns etc. They don't work at the moment, but I guess they will be activated with the next update.

External API for cloud to cloud integration could also works.

Check the new available endpoints on :

GET http://<your device ip>:8080/api/v2/


View available apps and widgets:

GET http://<your device ip>:8080/api/v2/device/apps/


Switch directly to countdown app:

PUT http://<your device ip>:8080/api/v2/device/apps/com.lametric.countdown/widgets/f03ea1ae1ae5f85b390b460f55ba8061/activate

not sure if widgetid is created on install, thus device specific. Got it from the GET on /apps/


Switch to next view:

PUT http://<your device ip>:8080/api/v2/device/apps/next/


I now try to figure out how to set configuration parameters, so I can start / stop / set the countdown timer remotely.

Got the action working after some brute force guessing. 

The action requires a POST call with a JSON body containing the id of the action and optionally parameter values. 


Example configurating and starting the countdown:


POST http://<local ip>:8080/api/v2/device/apps/com.lametric.countdown/widgets/f03ea1ae1ae5f85b390b460f55ba8061/action/


with body:

 "id": "countdown.configure",

 "params":{

  "duration": 600,

  "start_now": true

 }

}

Wow, cool! Thanks for sharing!

I'm also waiting for these features, to control at least the built-in apps, like radio, timer, alarms, etc.

For integration in a smart home automation, this is a must. ;-)

Any information from LaMetric on these features?


I suppose LaMetric need this API for the announced or already published Alexa Skill to control the LaMetric via Amazon Echo.

I guess it's both. I was told the documentation will be updated this month.

This still requires you to be on the same LAN?


Is there a way to do this remotely?

Login or Signup to post a comment