LaMetric Time: Local Push instead of Cloud Push

Greetings all, new to Home Assistant after several years with SmartThings and IFTTT (and not that happy with either). Recently added a LaMetric Time, and am designing my first Node Red Flow to push notifications to it.

Right now, when my flow runs, it can take 3 minutes for the notification to push to the LaMetric cloud and get back to the device (meanwhile my Google Home devices are near instantaneous). Obviously, not the optimal thing when you want a time sensitive alert to go off. I started doing some digging, and found that LaMetric has published an API for Local Push for notifications, so you aren’t dependant on the cloud.

https://lametric-documentation.readthedocs.io/en/latest/guides/first-steps/first-local-notification.html

Would it be possible to have a version of the integration that would do local push? Likewise there are some options (alarms, repeat sound, etc.) that the current integration doesn’t yet support that could easily be incorporated in as well.

Thoughts?

I have made it work locally with the rest_command. Here is my code:
In configuration.yaml:

### shell command curl for local LaMetric notification
rest_command:
  lametric: 
    url: "http://192.168.1.24:8080/api/v2/device/notifications" #change ip to own HA ip
    method: POST
    username: dev
    password: !secret lametric_device_api
    content_type: 'application/json'
    payload: "{ \"priority\": \"{{ priority }}\",\"icon_type\":\"none\",\"model\": { \"frames\": [ { \"icon\":\"{{ icon }}\", \"text\":\"{{ text }}\"} ], \"sound\": { \"category\":\"{{ sound_category }}\", \"id\":\"{{ sound_id }}\", \"repeat\":{{ sound_repeat_count | int }} },\"cycles\":{{ cycles | int }} } }" 
    # The following variables have to be passed as data:
    # priority: [info|warning|critical]
    # icon: <icon_id> acc. lametric gallery. Examples: a87: smiley; a82: clock; a66: calendar; a35: call; i69: visitor; a112: alarm; i620: info; i1237: alert; a2710: warning
    # text: Text to show on Lametric
    # sound_category: [alarms|notifications]
    # sound_id: <sound_id> acc. to lametric developer page, examples for notifications: notification, notification2, notification3, notification4, knock-knock, energy; examples for alarms: alarm1 to alarm13
    # sound_repeat_count: <repeat count>; if 0: repeat until confirmation

Here is a test script:

### Lametric Testscript
lametric_test:
  alias: "Lametric Test"
  sequence:
    - service: rest_command.lametric
      data: 
        text: "Test Display"
        icon: "a2710"
        priority: "info"
        cycles: 3
        sound_category: "notifications"
        sound_id: "notification2"
        sound_repeat_count: 2

This is not error resistant and you have to always use all data variables. However it fulfills my needs and works within 1 or 2 seconds.

1 Like

Hi !
I’m trying your rest command and script because I want to use the alarms sound, notifications sounds are too soft and too low for my use.
The IP in your URL is the IP of the LaMetric not HA ?
How do you get the lametric_device_api ? In the official implementation I get a client id and a client secret.
And last but not least when trying to test your script, I get a Message malformed: extra keys not allowed @ data[‘lametric_test’]
Help will be appreciated :slight_smile:

I confirm the IP is the IP of LaMetric
You can get the device API here : LaMetric: Web
And I remade your script :

alias: LaMetric Test
sequence:
  - service: rest_command.lametric
    data:
      text: Test Display
      icon: a2710
      priority: critical
      cycles: 3
      sound_category: alarms
      sound_id: alarm7
      sound_repeat_count: 1

Thanks again for the code !