Hallo,
ich habe grosses Interrese an Google Home, welcher nächsten Monat bei uns auf den Markt kommen soll und würde ihn gerne auf Smarthome NG einsetzten.
Das ganze läuft ähnlich wie das Speech Plugin und benötigt folgende Apps:
- Tasker
- Auto Voice
- Join
- IFTTT
- Ein Konto bei htps://api.ai
Als Sprache wäre das Speech Plugin weiterhin nutzbar, allerdings wäre es jetzt ein wenig oversized. Die Antworten sowie die Keywords werden bei api.ai hinterlegt, da dieser auf Asisstant Antwortet.
Um das System mit einem eigenen Keyword ansprechen zu können, brauchen wir IFTTT. Das ganze sieht dann so aus z.B "Ok Google" "2. Keyword" "Befehl". Das zur Spracheingabe!
Zur Sprachausgabe ist die App Join und Tasker. Ähnlich wie bei Notify my Android oder andere kann man hier eine Message senden, die der Tasker wiederum in Sprache ausgibt. Ausgewählt werden können bestimmte Geräte wie bei Pushbullet.
Möglich mit Join: Handy zum suchen Klingeln lassen, SMS, Url senden, File senden uvm.
Diesen Teil habe ich bis zum Plugin stehen, woran es im Moment bei mir hängt. (Es ist mein 1. Plugin)
Ich habe:
Fehler:
Worin liegt der Fehler?
Viele Grüsse
KNX Fan
ich habe grosses Interrese an Google Home, welcher nächsten Monat bei uns auf den Markt kommen soll und würde ihn gerne auf Smarthome NG einsetzten.
Das ganze läuft ähnlich wie das Speech Plugin und benötigt folgende Apps:
- Tasker
- Auto Voice
- Join
- IFTTT
- Ein Konto bei htps://api.ai
Als Sprache wäre das Speech Plugin weiterhin nutzbar, allerdings wäre es jetzt ein wenig oversized. Die Antworten sowie die Keywords werden bei api.ai hinterlegt, da dieser auf Asisstant Antwortet.
Um das System mit einem eigenen Keyword ansprechen zu können, brauchen wir IFTTT. Das ganze sieht dann so aus z.B "Ok Google" "2. Keyword" "Befehl". Das zur Spracheingabe!
Zur Sprachausgabe ist die App Join und Tasker. Ähnlich wie bei Notify my Android oder andere kann man hier eine Message senden, die der Tasker wiederum in Sprache ausgibt. Ausgewählt werden können bestimmte Geräte wie bei Pushbullet.
Möglich mit Join: Handy zum suchen Klingeln lassen, SMS, Url senden, File senden uvm.
Diesen Teil habe ich bis zum Plugin stehen, woran es im Moment bei mir hängt. (Es ist mein 1. Plugin)
Ich habe:
Code:
# Url Format: https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?title=<TITLE> Nachricht&icon=http://www.smartvisu.de/data/smartvisu_l.png&text==:=<MESSAGE> text=:=etc&url=<ADRESSSENDER>&clipboard=Some+Text& file=http://publicurl.com/image.jpg,http://publicurl.com/image2.jpg&deviceId=<DEVICEID>&apikey=<APIKEY> #[Join] # class_name = Join # class_path = plugins.Join # deviceid = <your-default-device-id> # apikey = <your-api-key>
Code:
import requests
import logging
from lib.model.smartplugin import SmartPlugin
logger = logging.getLogger('Join')
class Join(SmartPlugin):
SEND_URL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?apikey="
PLUGIN_VERSION = "1.0"
ALLOW_MULTIINSTANCE = False
def __init__(self, smarthome, apikey=None, deviceid=None, debug=False):
logging.getLogger("requests").setLevel(logging.WAR NING)
self.api_key = apikey
self._deviceId = deviceid
self._sh = sh
self._debug = debug
self.logger = logging.getLogger(Join)
def run(self):
self.alive = True
def stop(self):
self.alive = False
def get_devices(api_key):
response = requests.get(LIST_URL + api_key).json()
if response.get('success') and not response.get('userAuthError'):
return [(r['deviceName'], r['deviceId']) for r in response['records']]
return False
def send_notification(api_key, text, device_id=None, device_ids=None, device_names=None, title=None, icon=None, smallicon=None, vibration=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&text=" + text
if title: req_url += "&title=" + title
if icon: req_url += "&icon=" + icon
if smallicon: req_url += "&smallicon=" + smallicon
if vibration: req_url += "&vibration=" + vibration
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
def ring_device(api_key, device_id=None, device_ids=None, device_names=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&find=true"
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
def send_url(api_key, url, device_id=None, device_ids=None, device_names=None, title=None, text=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&url=" + url
if title: req_url += "&title=" + title
req_url += "&text=" + text if text else "&text="
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
def set_wallpaper(api_key, url, device_id=None, device_ids=None, device_names=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&wallpaper=" + url
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
def send_file(api_key, url, device_id=None, device_ids=None, device_names=None, title=None, text=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&file=" + url
if title: req_url += "&title=" + title
req_url += "&text=" + text if text else "&text="
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
def send_sms(api_key, sms_number, sms_text, device_id=None, device_ids=None, device_names=None):
if device_id is None and device_ids is None and device_names is None: return False
req_url = SEND_URL + api_key + "&smsnumber=" + sms_number + "&smstext=" + sms_text
if device_id: req_url += "&deviceId=" + device_id
if device_ids: req_url += "&deviceIds=" + device_ids
if device_names: req_url += "&deviceNames=" + device_names
requests.get(req_url)
Code:
2017-07-11 15:49:03 ERROR Main Plugin Join exception: unindent does not match any outer indentation level (__init__.py, line 56)
Traceback (most recent call last):
File "/usr/local/smarthome/lib/plugin.py", line 90, in __init__
plugin_thread = PluginWrapper(smarthome, plugin, classname, classpath, args, instance)
File "/usr/local/smarthome/lib/plugin.py", line 127, in __init__
exec("import {0}".format(classpath))
File "<string>", line 1, in <module>
File "/usr/local/smarthome/plugins/Join/__init__.py", line 56
def run(self):
^
IndentationError: unindent does not match any outer indentation level
Viele Grüsse
KNX Fan


Kommentar