info-beamer

Using the API to post setup's to devices

#1

Here is my code as of now:

import requests, sys
import json
from requests.auth import HTTPBasicAuth

newSetup = 'Kona-VidWall-Tuesday'
payload={}
payload[u'setup'] = []
payload[u'setup'].append({
	u'name': u'Kona-Vidwall-Monday',
	})
r=requests.get("https://info-beamer.com/api/v1/device/list",auth=HTTPBasicAuth('',api_key))
devicelists=r.json()['devices']
for outputList in devicelists:
	print(outputList['serial'])
	#print a
	url = 'https://info-beamer.com/api/v1/device/'+ outputList['serial']
	print(url)
	r=requests.post(url,auth=HTTPBasicAuth('',api_key), data=json.dumps(payload))
print(payload)

It seems to work properly except when I login to my dashboard it doesn’t show the devices running the setup that I am looking for. Thoughts?

#2

I recently modified to print the json response from the post and it is 403 which says that i’s forbidden. Not sure why that is.

#3

Device specific information uses the device’s id, not its serial. So you’d have to use device['id'] for that. In that case the call seems redundant as the /list call already returns all information about all your devices.

If you want to assign a setup to a device, you’d call

r = requests.post(
   url = "https://info-beamer.com/api/v1/device/%d" % device_id,
   auth = HTTPBasicAuth('',api_key),
   data = {"setup_id": new_setup_id}
)
r.raise_for_status()

with device_id and new_setup_id set to the ids of the device/setup.

PS: If you paste code, surround it by ``` at the top/bottom. That way it get formatted properly and even colored. I’ve modified your post, so check out the edit button to see my changes.

#4

I did this and it works now! I have a scheduling program running now and it works perfect! Thank you!!
I am wondering though, you’ve discussed that I can keep files locally and push them somehow to the PIs via the API. Not seeing that in the API documentation but maybe I’m missing it. Can you point me in the right direction to start looking at that?

#5

There is no need to do this explicitly. If you assign a setup to a device (using for example an API call like the one above), the Pi will download all required files. This includes the assigned assets.

When you switch between setups, the Pi will also check if a file is already locally available from a previous download. If you have multiple setups and assign one of them on a daily cycle, almost no bandwidth is used once they have been all assigned once as all files are already cached locally.

Does that answer your question?

#6

It helps answer the question of if the assets will be downloaded every time but I do see that it is a extra charge for space to store assets online, right? I also was unable to upload an asset the other day because it was too large. It was about a gigabyte I believe. Is that true? If that’s true won’t me storing locally and pushing to the PIs via an API help with that?

#7

There’s a 512MB limit for videos right now. In most cases that was good enough so far as bigger videos either mean it’s really long or has an excessively high bitrate. Is that a single video or one that combines (for example) multiple ads into one big video?

Regardless of that: any content uses on the devices has to be stored in the info-beamer services. The content can’t be only on the devices as that would prevent (for example) automatic self-repairs and other features.