Start a new topic
Answered

Push text from Eventghost to LaMetric via python

i received my device today and i could not be happier, it's really amazing, and the display is really cool. Really way above my expectations, great job guys. 


i use a software called Eventghost to automate my house, great software. it's based on python. to make it short, i want to have an app where i can send info from eventghost to LaMetric. 


i need to convert the curl code to python, i have this so far. 

 

import requests

headers = {
'Accept': 'application/json',
'X-Access-Token': 'MY-TOKEN',
'Cache-Control': 'no-cache'
}

payload = {
    "frames": [
        {
            "index": 0,
            "text": "My Text Goes Here",
            "icon": "a87"
        }
    ]
}

requests.post('https://developer.lametric.com/api/V1/(API)', headers=headers, data=payload)


i'm not getting any errors in python but the device is not updating. If any one has any suggestions please let me know. 

it'll be great to be able to push any type of info


Best Answer

As I posted on the EventGhost forums the day after you posted this (I'm adding the answer here as well for anyone who might be having the same problem), stringifying the JSON seems to help.


payload = json.dumps(myJSONVar, indent=4, separators=(",", ": "))


From there, passing "payload" into the requests.post() call should be more successful :)

1 Comment

Answer

As I posted on the EventGhost forums the day after you posted this (I'm adding the answer here as well for anyone who might be having the same problem), stringifying the JSON seems to help.


payload = json.dumps(myJSONVar, indent=4, separators=(",", ": "))


From there, passing "payload" into the requests.post() call should be more successful :)

Login or Signup to post a comment