Start a new topic

App is showing push data 5 times

 Dear LaMetric Support


I have created my first app (Show REST status), I push via curl a string to the LaMetric module. The app is deployed on the LaMetric.


But now, same text is repeating 5 times, then it changes to the next app (clock, weather). How can I control that the text which I push is only showed once?


Regards, Martin

So, a couple of things...

First, in your LaMetric app check to see how long you have it set to view. Your options are default, x2, and x3. This basically specifies how much time your application will display on the screen before moving onto the next one. If you are already set for default, then that is the minimum amount of time this will show and you don't have many more options after that (assuming you want to continue to use an indicator app)

Second, if your notification is what is being displayed across the screen 5 times, then you can add the "cycles" : X, (Where X is the number of cycles you want to have your notification scroll across, default is 1, but you can specify 2 or more as well.) to the JSON request in your cURL script. This will not affect how long the app is slated to display however, so if it is still displaying for too long then you may want to consider just doing a notification instead of indicator if all you need is the notification.

If you only need the notification, then you can send out an HTTP POST with cURL but to the notifications API instead, which will just notify, then disappear forever in the ether. In order to do a notification, you will have to leverage the local API however. So send an HTTP POST to http://xxx.xxx.xxx.xxx:8080/api/v2/device/notifications (xxx.xxx.xxx.xxx is your LOCAL IP address of your LaMetric) with a Basic authentication of username of 'dev' (no quotes) and password being your API key (which you can get from My Devices in your developer portal). This will allow you to specify just how long you want it to display before going away. Your JSON request will look something like the following: 

 {
    "priority": "info",
    "model": {
        "cycles": 1,
        "frames": [
        {
            "icon": "i178",
            "text": "HELLO!"
        }],
        "sound": {
            "category": "notifications",
            "id": "cat"
        }
    }
} 

Hopefully this helps a little. The docs are available in the dev portal which can break down each of these calls line by line so you can tweak it to best suit you.

hi John


Thank you for your answer, my problem is that I cannot edit the JSON format in the App, the text is unable to edit. Do I need a special account to do that?


Regards, Martin

Hi Martin,


Actually what you are seeing in the App is just an example of what your JSON request should look like, you can actually send your LaMetric any properly formatted JSON request and it will be interpreted properly. While sending out your cURL POST command, when you send the data with -d followed by the '{"frames" [{"text": etc.' that is where you can send a custom JSON request looking like the example I displayed in the last post. so using my example your cURL command would look like the following: Note you will have a different Token, the one I'm posting is just for example  

curl -X POST \
-H "Accept: application/json" \
-H "X-Access-Token: YWosnkdnoYREsdogfoSDff734kjsfbweo7r434597FYODIoicosdonnreiuhvdciuhouerhohcd8sds89fdRw==" \
-H "Cache-Control: no-cache" \
-d '{
    "priority": "critical",
    "model": {
        "cycles": 1,
        "frames": [
        {
            "icon": "i178",
            "text": "HELLO!"
        }],
        "sound": {
            "category": "notifications",
            "id": "cat"
        }
    }
}' \
https://developer.lametric.com/api/v1/dev/widget/update/com.lametric.YOURAPPID

 OR if you want to send a notification only, then the following cURL command will work:

 

curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
    "priority": "critical",
    "model": {
        "cycles": 1,
        "frames": [
        {
            "icon": "i178",
            "text": "HELLO!"
        }],
        "sound": {
            "category": "notifications",
            "id": "cat"
        }
    }
}' \
http://dev:YOUR_API_KEY@xxx.xxx.xxx.xxx:8080/api/v2/device/notifications

Hopefully this makes sense. It took me a little trial and error before I started to really get a feel for how the system works.

Apologies, I gave you the wrong info for your Indicator POST command. Your JSON request for indicator should look slightly different from your Notification request. The cURL command should resemble the following: 


curl -X POST \
-H "Accept: application/json" \
-H "X-Access-Token: YWosnkdnoYREsdogfoSDff734kjsfbweo7r434597FYODIoicosdonnreiuhvdciuhouerhohcd8sds89fdRw==" \
-H "Cache-Control: no-cache" \
-d '{
        "frames": [
        {
            "icon": "i178",
            "text": "HELLO!"
        }
     ]
}' \
https://developer.lametric.com/api/v1/dev/widget/update/com.lametric.YOURAPPID

You won't be able to add the sound and priority info into the indicator request since those are specific for notifications. 


Login or Signup to post a comment