I have a raspberry pi running Alexa (amazon echo) that can instantly push a trigger to IFTTT, for an example I say "Alexa, trigger email to blablabla" and I immediately receive an email.
My Goal I want to execute a bash script on the same raspberry pi with voice command (by Alexa) via IFTTT. Is there any IFTTT recipe that can instantly push a trigger to my raspberry pi? (so that I can instantly run a bash script) (Note: Dropbox doesn't support raspberry pi, though there is an uploader/downloader and the below script uses it with cronjob).
I found one (Raspi Runner) that runs cronjob every few minutes, but I'm not sure if I can setup cronjob for every second and use this script!!
How can I do this?
Short Answer:
IF
This - Alexa
Then
That - Adafruit/Maker Webhook
Longer Answer: There are two options:1)Alexa will notify IFTTT that trigger event has occurred. Against which, the action chosen is publishing an MQTT message. This MQTT channel is created by Adafruit. Needless to say, you need to write an MQTT feed reader at the RPi.
2) Maker web-hooks. You expose your RPi to the web, keep a server running on it. Expose a web-service which may be called from the Maker Webhook. This is personally my preferred option, but setup could be a pain, i.e. port forwarding from modem, router etc.
References:
1) Adafruit Official Site
2) MQTT Java Library
3) Hackster Tutorial - With option #1
4) Hackster Tutorial - With option #2
Related
I'm running a streaming radio on my Raspberry Pi 3 using MPD (Music Player Daemon).
We are only 2 to use this radio, and most of the time, neither of us are connected to listen to the radio, which means that the service is running for nothing.
I checked that MPD is idling at 5% CPU and goes up to close to 40% when anyone connects, but in a more general way, I was wondering if there was some interruption, system notification or something like that which could be used to trigger a command, say, when someone connects on a specific port, or disconnects from it.
The goal would be to only run a service when needed.
I am using nginx as server, if that's of any help.
Only thing I could gather is a constant polling like what is mentioned here : https://www.tecmint.com/find-all-clients-connected-to-http-or-https-ports/
But, of course, I would need to be "instantly" reactive and not wait in between two pollings.
I have an small Linux tvbox with working remote control (LIRC). The socket (/run/lirc/lircd) is respond everything works like a charm. If I run irw command I get button code etc...
My question: Is it possible to prepare some Linux command which simulate like I pushed the physical remote button (simulate key press events programmatically)?
Maybe I should use lircd SOCKET COMMAND INTERFACE, any example?
Thank you for your time any feedback welcome!
I have a website hosted on Heroku and Firebase (front (react) and backend(nodejs)) and I have some "long running scripts" that I need to perform. I had the idea to deploy a node process to my raspberry pi to execute this (because I need resources from inside my network).
How would I set this up securely?
I think I need to create a nodejs process that checks the central server regularly if there are any jobs to be done. Can I use sockets for this? What technology would you guys use?
I think the design would be:
1. Local agent starts and connects to server
2. Server sends messages to agent, or local agent polls with time interval
EDIT: I have multiple users that I would like to serve. The user should be able to "download" the agent and set it up so that it connects to the remote server.
You could just use firebase for this right? Create a new firebase db for "tasks" or whatever that is only accessible for you. When the central server (whatever that is) determines there's a job to be done, it adds it to your tasks db.
Then you write a simple node app you can run on your raspberry pi that starts up, authenticates with firebase, and listens for updates on your tasks database. When one is added, it runs your long running task, then removes that task from the database.
Wrap it up in a bash script that'll automatically run it again if it crashes, and you've got a super simple pubsub setup without needing to expose anything on your local network.
I want to build a Raspberry Pi (RPi) based device similar to the Nest Thermostat, except that I want to control light switches. I know I could easily code up a Node.js script on the RPi and then just hook it up to my local router and control it with a PC hooked up to the same router.
But, I want to make it more like a Nest. I want to be able to control 20 (or more) RPis across different subnets through a cloud provider like Heroku.
The Nest thermostat does not require the user to open a port on their router so that the Nest server can communicate with it.
How is Nest able to control customer's thermostats over the web without enabling port forwarding in the customer's router?
Blog post Nest Thermostat API using Node JS and Nest API Update discusses the API
between the thermostat and the nest lab servers. In particular:
The API uses mostly JSON formatted data POSTed to their web servers.
So there is your answer. By periodically POSTing data to the nest web servers using HTTPS, Nest is able to avoid having the user open any ports on their router.
For what it's worth, the unofficial API (in node.js!) from the blog post is available on github: Unofficial Nest API on Node.
I think the thermostat periodically posts a request with the thermostat serial number to nest. It may have timeouts in the http headers set to infinity or more likely, the nest server simply closes the connection after a minute or so if no command for that device has come in. Whenever nest closes the connection the thermostat opens a new one. When a command request comes in with serial number, its a quick lookup to find the thread currently connected to that thermostat. The command is sent in the payload of the current thermostat request, which is executed, the connection is closed, and the thermostat opens a new request to nest .
Take a look at eventSource in the HTML 5 standard. It does everything that is required.
I want to a Java ME application that transfers any SMS received to a PC using bluetooth. The PC can then direct the Java ME application via bluetooth to send a response SMS. Is there library available for this architecture or I have to design it myself?
Is this approach correct or a better one exists? I want to use bluetooth as then I will not have dependency on the cable.
You'll need to create this yourself, however you'll find that you can't do what you want with J2ME.
J2ME can't access any old SMS that the handset receives, only ones sent to a specific port upon which the MIDlet is listening. So to get all the other SMSes, create a bluetooth serial/dial-up connection to your handset in the way I've described in this answer.
Create a PC client which repeatedly issues AT+CGML commands (as described in the AT command set document linked to in the answer above), to see when an SMS has been received. Use AT+CGMR to read and parse the message text. Then use AT+CGMS to sent a response. This can all be done over bluetooth.
It's better to use the serial connection to send a response, because a MIDlet cannot usually be triggered to open based on incoming bluetooth data.
Hope this helps.
You may have already achieved your task, anyway for the reference I think it is much better if you try using Gammu . I'm using it for the same task (Send / receive SMS through PC ) with a simple bat file I have written, works like a charm.
Anyway you don't need any J2me program for this.
Wammu takes care of making the connection to phone and sending AT commands.