Habe das Plugin nun lauffähig. Da es mein erstes Plugin ist, kann vielleicht einer nochmal drüber sehen, ich denke der Code wird verbesserungs würdig sein, vor allem was das Logging betrifft. Für den Anfang ist es für mich ausreichend.
Infos zur API gibt es hier:
https://joaoapps.com/join/api/
Der Vorteil an Join ist, man kann direkt mit Tasker kommunizieren und direkt Aktionen am Handy oder Tablet ausführen. Es ist auch möglich das Handy mit SmarthomeNG fernzusteuern.
Werde das noch weiter entwickeln und würde mich auf Ideen oder Hilfen freuen.
Die plugin.conf:
Das Plugin:
logic example:
Alle mir bekannten Variabelen habe ich im Code. Diese können bei Bedarf gemischt werden. Bitte die Join API lesen!
Viele Grüsse
Knxfan
Infos zur API gibt es hier:
https://joaoapps.com/join/api/
Der Vorteil an Join ist, man kann direkt mit Tasker kommunizieren und direkt Aktionen am Handy oder Tablet ausführen. Es ist auch möglich das Handy mit SmarthomeNG fernzusteuern.
Werde das noch weiter entwickeln und würde mich auf Ideen oder Hilfen freuen.
Die plugin.conf:
Code:
[Join] class_name = Join class_path = plugins.Join device_id = <your deviceid> api_key = <your apikey>
Code:
#!/usr/bin/env python3 # ######################################################################### # Copyright 2017 Pierre Scheibke pierre(a)scheibke.com ######################################################################### # # This file is part of SmartHomeNG. # # SmartHomeNG is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # SmartHomeNG is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with SmartHomeNG. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### import logging import json import requests import magic import os import re import urllib.parse import http.client from lib.model.smartplugin import SmartPlugin class Join(SmartPlugin): SEND_URL = 'https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?apikey=' LIST_URL = 'https://joinjoaomgcd.appspot.com/_ah/api/registration/v1/listDevices?apikey=' PLUGIN_VERSION = "1.0" ALLOW_MULTIINSTANCE = False def __init__(self, smarthome, api_key=None, device_id=None, debug=True): logging.getLogger("requests").setLevel(logging.WARNING) self._api_key = api_key self._device_id = device_id self._sh = smarthome self._debug = debug self.logger = logging.getLogger(__name__) def run(self): pass def stop(self): pass def send(self, title=None, text=None, icon=None, find=None, smallicon=None, device_id=None, device_ids=None, device_names=None, url=None, image=None, sound=None, group=None, clipboard=None, file=None, callnumber=None, smsnumber=None, smstext=None, mmsfile=None, wallpaper=None, lockWallpaper=None, interruptionFilter=None, mediaVolume=None, ringVolume=None, alarmVolume=None): req_url = self.SEND_URL + self._api_key if title: req_url += "&title=" + title if text: req_url += "&text=" + text if icon: req_url += "&icon=" + icon if find: req_url += "&find=" + find if smallicon: req_url += "&smallicon=" + smallicon if device_ids: req_url += "&deviceIds=" + device_ids if device_names: req_url += "&deviceNames=" + device_names if url: req_url += "&url=" + url if image: req_url += "&image=" + image if sound: req_url += "&sound=" + sound if group: req_url += "&group=" + group if clipboard: req_url += "&clipboard=" + clipboard if file: req_url += "&file=" + file if callnumber: req_url += "&callnumber=" + callnumber if smsnumber: req_url += "&smsnumber=" + smsnumber if smstext: req_url += "&smstext=" + smstext if mmsfile: req_url += "&mmsfile=" + mmsfile if wallpaper: req_url += "&wallpaper=" + wallpaper if lockWallpaper: req_url += "&lockWallpaper=" + lockWallpaper if interruptionFilter: req_url += "&interruptionFilter=" + interruptionFilter if mediaVolume: req_url += "&mediaVolume=" + mediaVolume if ringVolume: req_url += "&ringVolume=" + ringVolume if alarmVolume: req_url += "&alarmVolume=" + alarmVolume if device_id: req_url += "&deviceId=" + device_id else: req_url += "&deviceId=" + self._device_id self.logger.info(req_url) requests.get(req_url)
Code:
if (sh.your.item() == 1): sh.Join.send(smsnumber="0123456789, smstext="Hello World") to write a SMS if (sh.your.item() == 1): sh.Join.send(title="0123456789, text="Hello World") to write a notification if (sh.your.item() == 1): sh.Join.send(find="true") to find your device
Viele Grüsse
Knxfan
Kommentar