What I am trying to do is a quite basic task: to send event triggers from different services to Raspberry pi and do some tasks when these triggers are received, in other words to make "home automation".
I searched for many websites and links but all projects about ifttt and raspberry pi do the reverse job: raspberry pi posts a web request and another service receives this trigger and does something.
There are some projects to receive requests from google assistant on raspberry pi but google assistant posts a request which contains https://raspberry_ip_address:port/bla_bla which works locally, but I want to send request from my phone even if it is not connected to my home wi-fi.
I found that ProtaOS on rpi works for these tasks and there are some projects with node-red but I don't want to use both of these solutions, I want to write python code on my own.
Is there any api or library for getting requests from maker ifttt trigger events for Python?
Any help would be appreciated. Thanks!
If i understood your question correctly, You want to trigger something with your phone and then on raspi you will excecute something with that trigger generated from phone or any other device.
One way of doing this is to use an external api like thinkspeak or ifttt, for that you have to continiously read a particular field which your trigger will change
check this
Another way can be making your own api and using it both from your services to post data and your raspi to read data. Python Flask ia a very simple framework for building web api. For hosting there are many free services like heroku, pythonanywhere.
Flask 101 and Free Hosting!!!
Another way is to host your trigger listener in your raspi and port forward your raspi IP with Ngrok or any other services of such kind.Ngrok
Comment below if you have any other specific query.
Keep Hacking :)
There are a number of solutions I use in this scenario, depending on what the problem is and how frequently I need to push requests to the Pi. Here is my portfolio:
Get a 3G module like SIM900: https://www.amazon.co.uk/Aihasd-Quad-Band-Development-Wireless-Raspberry/dp/B01IBGDDVM/. This will allow you to receive SMS in real time and receive instructions with a push from your phone. I like this option for remote sensing and homes with a weak or unstable internet connection.
continuous calls to a server to check for updates (a method you sound familiar with). This works well if Wifi is good and data is cheap.
Web sockets: this allows a continuous connection to be kept open between Raspberry Pi and server, though it requires a stable and continuous connection. https://www.jaredwolff.com/raspberry-pi-getting-interactive-with-your-server-using-websockets/
Related
I am trying to create a python program that takes input of what homework assignments I have and stores all of that information so that I can send a notification to my phone when assignments are coming up. I want to be able to give input from my phone throughout the day and cant seem to find a way to interact with my script on my computer from my phone. Any ideas? Ps: if you know a way that I can send notifications to my phone that would also be cool.
It looks like you should create a classic client/server architecture. This is quite a big task. Your program running on your Windows computer acts as a server waiting for client (mobile application) requests. I propose to create a widely used REST API service using e.g. the Flask framework (server side) and use the Retrofit framework for the Android application.
Remember that when using the application on the Internet, you will have to ensure the availability of the server.
To send notifications from the server to the app, use Firebase Cloud Messaging
The project I am working on involves two hardware video encoders and decoders communicating through a device called Mikrohard.
The problem is that there is a lot of devices in this configuration
each one of which has its own web-host hosting a simple web page where you can edit the configurations of the device.
the official way to access the configurations is very tedious on field as it requires the user to connect each device by Ethernet to his laptop which takes a considerable amount of time.
The proposed solution was to place a router and connect all devices to it, then connecting a raspberry pi that is hosting a configuration web-page.
The web-page will include buttons that when pressed will send the packet to each one of the devices on the network .
then users can simply connect to the raspberry pi that is acting as an access point
and access the web-page.
I tried using CORS to allow raspberry-pi page to embed all devices pages into itself
but I soon realized I can’t unless other devices allow cross origin access.
so I am thinking about reverse engineering what packets are sent to each device on its own web-page then try crafting that packet .
though this looks very tedious and will take a long time.
I would like to know whats your opinions or if you have a better idea
I'm trying to build a notification system that would be triggered initially from an api call made on the cloud, and should trigger a notification on one of my agents' pc (assuming running windows 10)
I'd like to do that in python as this is my knowledge
How should I structure this ?
The hardest part I can't figure out and couldn't find anything online is how to link the "local" pc to the "server"/cloud system (i'm using aws if that is useful) which would store the notification and dispatch them for each one of my agent.
My ultimate goal is to use a phone solution like aircall and to show the contact name of the caller through a notification popup in windows (aircall does offer that natively but can't access my contact datrabase so i'm trying to override the same function of displaying the caller name)
any help or suggesiton appreciated
One solution could be to build a simple ElectronJS frontend app that runs on your agents' computer AND a Python web server that listens to Aircall's Webhook events.
The web server would listen to call.ringing_on_agent Webhook events sent from Aircall and send a WebSocket push event (using Pusher for example) to your ElectronJS app.
The ElectronJS app installed by your agents would listen to WebSockets from your Python web server and would trigger a native Windows notification with the information you want (check the doc here).
I'm developing a product where it shows information about stuff, the product involves a raspberry pi which automatically runs a python program on boot. When it's the users first time using this product they will have to set it up (log into their account etc.). I'd like it for the IOS app to recognize that the product is nearby and allow the user to enter the necessary data (WiFi information, login credentials, etc.) for that product through the app on their phone.
Basically, what I'm trying to ask is that is there any way where I can exchange data between my IOS app and my python program, running on my raspberry pi? I can't do anything through databases since there would be no way of knowing which device needs to connect to what, so I'm guessing something like Bluetooth, just to send the first bits of data (like Wifi information) to get the two linked?
MORE INFO:
An example would be setting up a device like Alexa, how does Alexa connect to your devices to obtain Wifi information so that it can do everything else by itself?
Thanks, Nathan.
If you want to prototype a solution quickly, try Blynk. I've managed to do this type of link using NodeJS and a Raspberry Pi with Blynk previously but their web page suggests you could also use Python or MicroPython. The downside is that, beyond doing basic UI elements, you need to pay for it.
Another approach is to set up a WiFi access point with a web-based system that supports configuration. An example of a device that does this is the open source energy monitor. It might be the case that you can look at how they set up their AP and web server as it is all open source.
I'm trying to build a webserver using Apache and I want to establish two-way of communication between my python application and webserver where I can listen for requests from apache and return data back, in the same time I want the client to interact only with the webserver.
In my python program I'm using python python-twisted and pymodbus (MODBUS-TCPIP) to get some data from a PLC.
I have already configured a websocket in python using
from autobahn.twisted.websocket import WebSocketServerProtocol, \
WebSocketServerFactory
I'm thinking to configure a intermediate web which will be initiated upon http request of the main website and open websocket connection with python and start receiving data, where the clients (browsers) can still request data using jquery.
I don't know if this is the right way to go. Do you guys have better way to pass data variable between python and apache back and forth?
If I understood correctly, you want to make PLC data accessible on a web page.
The right way to develop a web application in Python is to use a web framework like Django, or (if you want something lighter) bottle
With this, you can develop a web page where you connect to your PLC over Modbus, query some values, disconnect and return a response with data as json.
But I think, this is not the best architecture because if you have several people accessing your web page, it will cause several connections to your PLC and you may have poor performance for your web app.
I think you had better develop a modbus program which is reading the data from the PLC and store it into a database. Then your web app just gets the data from the database.
I hope it helps