Python web interface for MQTT - python

I have been working on a project which involves multiple raspberry pi computers controlled using MQTT on a server computer.
The system is working well but at the moment I am manually publishing using the mosquitto command line interface to control the computers. I would like to set up a web interface on the local server so that I can control the computers using my phone/ipad etc.
I would like to have buttons that publish to a specific topics and also a control that will accept text and publish to a topic with the text as the payload.
I don’t have a lot of experience in web programming and I would like use python if possible as I am already familiar with it.
does anyone have any suggestions as to how i would implement it and where i can find a tutorial?
thanks for your help.

You could use something like SimpleHTTPServer to build a web interface to forward messages to MQTT
Or you could use the Paho MQTT js library and a MQTT server that supports websockets (e.g. mosquitto 1.4) and send MQTT messages directly from the webpage.

Related

Django web frame work client server chat communication project

So basically this is a client server communication application which is been written in python and been successfully executed.For the same code i need to built a client separate and a server separately. My client Server program communicate on an self written algorithm which is included separately in the code already.. So i just need a help on how to add client and server separately in a project or should i create a separate project for client and server. Please help me out . I have tried different some method but that do not work.
Thank you for advance for the help

How to send data from Android/iOS app to a python script running on a raspberry pi using Bluetooth?

So me and my friend are working on this project where a raspberry pi with certain sensors collects some data and outputs it.
Now, we want certain parameters to be passed on runtime. So we were thinking of creating a react-native app which could connect with the Pi using Bluetooth. Once connected, it could then send the arguments over Bluetooth.
The python script would then intercept these arguments and then run its program and then send its output back to the app.
While searching for libraries to help me with this, I came across this library: https://github.com/Polidea/react-native-ble-plx
While going through the documentation, I came across https://github.com/Polidea/react-native-ble-plx/wiki/Characteristic-Writing, which seems to be the method used for writing some data and sending it.
In Bluetooth terms, what exactly are these services and characteristics and do I have to create my own service and characteristic while working on my project? Or can I write to any existing characteristic so that the python script can read that?
If I have wrongly understood certain concepts, please correct me. Also if there are any better ways to architect this approach please let me know
Currently, there is no official Expo Bluetooth API. I looked up the same library you are looking at and I find it a little complicated.
I found this link https://askubuntu.com/questions/838697/share-files-between-2-computers-via-bluetooth-from-terminal, where you could open up one terminal and use Bluetoothctl to connect to a specific device. Now, open up another terminal and use the bluetooth-sendto --device= MAC:ADDRESS (read that link) to send the file from Raspberry Pi to a phone (I tested on Android and it worked).
You could also send data from the phone to Raspberry Pi. Again, check out that link.

How to use Firebase with a linux based client app for bidirectional messages communication with server

I've seen Google's documentation and a lot of examples over the internet about how to use Firebase within Android / iOS applications, but I want to develop a client Firebase application which runs on a linux machine.
My requirements are:
Client runs on linux environment (either writtern in C++ or python).
Server is written in Javascript (NodeJS).
Server and client should have bi-directional communication between them using firebase realtime database.
I've seen also the firebase REST api, but I assume that is not good enough for me since I haven't seen a client listener api that listens on a something like onValueChanged.
Question:
How can I implement a linux-based app in C++ or python that listens to messages from server (data changes) using a listener, without having to call some get function each and every few seconds (just like NodeJS have the ref.on("child_changed",...) or ref.on("value",...)?
Help is much appreciated!
Unfortunately there is not official library for Realtime Database in Python but there are some third party wrappers around REST API.
Specifically I would look at Pyrebase library which also supports listening to live changes https://github.com/thisbejim/Pyrebase#streaming
For more information, libraries or other languages look at this page https://firebase.google.com/docs/database/rest/start
Google offers a C++ SDK you can download it here.
There is also a tutorial on the bottom of the page, but if you really want to dig into some code, here is the quickstart code on github from google with examples for each category on Firebase.
Google has also implemented a Game for demonstration purposes in C++ for Desktop OSs. here There you can find more advanced features and code samples.
I have only tried it with an XCode project on Mac OS X, and it works fine. I have no code for real time database but you should find the sample project in the github repo. https://github.com/firebase/quickstart-cpp
I hope this helps!
Greetings.
Haven't you try to use a Realtime Database triggers for C++ (that's is currently on beta) that allows you to simulate the same workflow as on JS?
From my point of view, it is the best way to get it to work as you want.
https://firebase.google.com/docs/functions/database-events

Quickbooks Desktop how to integrate with Python

I am trying to communicate with the QuickBooks Desktop Application using the Quick Books Web Connector (must be done in Python). I am not very familiar with SOAP- I was wondering whether anyone had a template/guide for communicating with the QBWC. I have read QuickBooks Web Connector Program Guide but there was no sample Python code.
The only requirement for which language to use with the Web Connector is to have a functioning SOAP server. From the Programmer's Guide:
What Platforms and Languages can I use in my Implementation?
The web service should be able to run on any platform that supports standard SOAP for communication. Platforms that are known to work include Apache Tomcat (Axis)and ASP (.Net).
As long as you can roll a WSDL-first SOAP server in Python, you can interface with the Web Connector. Unfortunately, it appears that might be a significant hurdle. Check out this question for suggestions on possible ways to accomplish that.
Once you get that working, the QuickBooks SDK provides bare-bones examples of a functioning web service. That should provide a sufficient template/guide for you to successfully interface with QuickBooks through the Web Connector.

how to let my web-ui communitate(or control) my CLI program

I'm already implement a command line tool used for 802.1x authentication in python. But I want a gui frontend. I want to try a web UI this time, but I don't know how to let my webui communicate with my python app.
I only know that I need to open a socket in CLI program and receive the message send by the web ui. But I'm a newbie in web development. I don't known what to do with my web app.
Do you have any good advice? Thanks in advance.
Python official wiki page about web programming and the wikipedia list of the web frameworks written in Python are good places to start from.

Categories