Live data WebSocket REST API (for Python client)

My Project

I am trying to create a Smart Home device controlled by Google Assistant using a Raspberry Pi. I am using a service called IFTTT to handle the Google Assistant part and my idea for getting that event onto my Raspberry Pi is to use a Backendless service. IFTTT will POST a request regarding the event to my Backendless server and the my idea is that the Pi will either:

  1. Poll the Pub/Sub system
  2. Register for push notifications
  3. Register a listener on a live-data object.

My Approach

As this project is going to be battery powered and my connection will be long lived (permanent if all goes well) and from some research it would seem that WebSockets are the most efficient type of connection (over Long/Short Polling) as well as offering benefits in better latency. From what I understand the Live-Data API offered by Backendless SDK makes use of WebSockets to keep objects up-to-date.

My Problem

Due to the nature of Raspberry Pi my solution is going to be written using Python and I can’t find a Backendless python implementation (not a problem, REST to the rescue); but I also can’t find anything about how to connect to a Live-Data object using the REST API.

My Plee

Any advice on how to achieve a WebSocket connection into a live-data object without using an SDK would be much appreciated. Or; if WebSockets are a bad idea in the first place, I am also happy to take suggestions on alternative approaches to receiving events from Backendless.

Thanks all!

Hello @Nicholas_Robinson

Welcome to our community and thanks for trying Backendless.

Your task is very interesting but unfortunately, we do not have a solution for Python. Under the hood, we are using socket.io, and there is a socket.io library for Python. So it is possible to create backendless-rt-client library for Python, to do that you should port js rt client GitHub - Backendless/RT-Client: RT Client for connect to Backendless RT Server.

The other way is to use node js on Raspberry Pi, I have found some tutorial that shows how to install node Node.js and Raspberry Pi but I am not sure if it will works good enough.

One more solution. As I understand you want to use messing because you will have more than one raspberry Pi to handle one event. So you create a service on backendless that register your devices. When IFTTT will POST a request regarding the event to some other backendless service, the service takes the list of Pi devices and makes an HTTP call to each Pi device

@sergey.kuk could you elaborate on this?

Is there any documentation showing how I can set up the js rt client + connect with socket.io?

Thanks in advance :slight_smile:

Hi, @Robin_Platte

Please take a look at our JS documentation on RT connections: Overview - Backendless SDK for JavaScript API Documentation.
There is a lot of information about setting up an RT connection

Regards,
Marina

Thanks for the fast response @Marina.Kan

@Marina.Kan I read through half of the documentation.
My question is rather if through this I can let Python code run and let BL server execute what I’m trying to do.

You can combine your code with the REST API. There is a link to documentation Overview - Backendless REST API Documentation

Regards,
Marina