LaMetric Firmware 1.6.0 and local push

Posted on Jul 17, 2016

UPDATE (08.08.2016): Apparently you can get your api key at https://developer.lametric.com/user/devices now.

With the LaMetric Time Firmware update 1.6.0 the API for local push notifications changed and my tutorial for the 1.5.0 firmware does’t work anymore. The new firmware offers the possibility to show notifications without installing an extra app.

For this to work you have to create an “notifications app” in the developer backend. This is similar to creating the old apps, but you don’t have to add it to your LaMetric Time. Go to the developer backend and create a new notifications app. Choose a name, enter a short description and set the redirect url to a dummy domain – e.g. http://dfgdgddfdfg.de (in this case, it doesn’t really matter, because we use this only for ourself). Then click “Save” and your app is ready. Get the “Client ID” from the info page of the app.

To communicate with the LaMetric Time in a local network we need the api key. With the 1.6.0 firmware this has to be obtained by getting an access token via OAuth2. With your client id at hand open the following URL in a browser after replacing the CLIENT-ID with your client id.

This should open a website, asking you if you want to authorize your new app to access your LaMetric account. Click “ALLOW” and you should be redirected to the redirect url you entered before. If you used facebook.com, you probably see an error messsage, 404 site not found, but that’s ok. We’re only interested in the current URL – this should look like

Copy the access token part from the url – in the example above it’s “xyz”. Using this access token we can get the api key from our LaMetric Time with the following php script – again, replace the CLIENT-ID with your client-idaccess token from before. Make sure you run this script shortly after getting the access token, since it expires after few minutes.

The result should look like

The two important parts are the api_key and the ipv4_internal. With those two things we can send notifications directly to the LaMetric Time. To use the api key, it has to be prefixed by “dev:” and the whole string needs to be base64 encoded – if you don’t know what this means, don’t worry, it’s easy to do:

  1. api key from above: 123123123
  2. new api key with prefix: dev:123123123
  3. Copy the whole string and paste it on https://www.base64encode.org and click “ENCODE”: ZGV2OjEyMzEyMzEyMw==

This is your api key you need to use whenever you interact with the LaMetric Time. Using the following script you can see all available api endpoints on your device – meaning all the things you can interact with.

The output of this script looks like

To sent a notification use the following script as an example:

When you run this script, you should see a “Hello” notification that stays until you hit the Action button. To get more information about notifications (e.g. setting sound) have a look at the new documentation for firmware 1.6.0.