本文介绍了通过 IFTTT 在树莓派中运行 bash 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行 Alexa (amazon echo) 的树莓派,它可以立即将触发器推送到 IFTTT,例如,我说Alexa,将电子邮件发送到 blablabla",然后我立即收到一封电子邮件.

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.

我的目标我想通过 IFTTT 使用语音命令(由 Alexa)在同一个树莓派上执行 bash 脚本.是否有任何 IFTTT 配方可以立即触发我的树莓派?(以便我可以立即运行 bash 脚本)(注意:Dropbox 不支持 raspberry pi,但有一个上传器/下载器,并且下面的脚本将它与 cronjob 一起使用).

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).

我发现一个 (Raspi Runner) 每隔几分钟运行一次 cronjob,但我不是确定我是否可以每秒设置 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!!

我该怎么做?

推荐答案

简答:
如果
T他的 - Alexa
T母鸡
T帽子 - Adafruit/Maker Webhook

Short Answer:
IF
This - Alexa
Then
That - Adafruit/Maker Webhook

更长的答案:
有两种选择:
1)Alexa 会通知 IFTTT 触发事件已经发生.为此,选择的操作是发布 MQTT 消息.这个 MQTT 通道是由 Adafruit 创建的.不用说,您需要在 RPi 上编写一个 MQTT 提要阅读器.

2) Maker web-hooks.您将您的 RPi 暴露给网络,让服务器在其上运行.公开可以从 Maker Webhook 调用的网络服务.这是我个人的首选选项,但设置可能很麻烦,即从调制解调器、路由器等进行端口转发.

参考资料:
1) Adafruit 官方网站
2) MQTT Java 库
3) 黑客教程 - 使用选项 #1
4) 黑客教程 - 使用选项 #2

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

这篇关于通过 IFTTT 在树莓派中运行 bash 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 11:49