Comments (10)
Da die Anforderung aus dem IP-Symcon Lager kommt evtl. über die JSON API Get eine oder mehrere Anwesenheits Variablen auslesen. In dieser steht idealerweise schon die Nummer, welche angerufen werden soll. Evtl über die Timeticks zyklisch auslesen lassen, falls in der doorpi.cfg angegeben. Würde das funktionieren Thomas?
from doorpi.
Hab meine Antwort dort noch nicht einmal gepostet, da geht es hier schon weiter - Wahnsinn...
Natürlich ist es per API möglich eine Variable auszulesen und:
- entweder zeigt diese nur die Anwesenheit an
- es steht dort die vollständige Nummer
Mir gefällt die erste Lösung besser, da es dann eine Rückfallebene gibt, wenn das IP-Symcon nicht verfügbar wäre.
Das zyklische auslesen ist auch eine Möglichkeit. Allerdings belastet das die Systeme (unnötig) und ist ggf. ungenau. Zu hohe Belastung wenn es im Sekundentakt ausgelesen wird, zu ungenau, wenn es im Tagesrythmus ausgelesen wird.
Irgendwo ist ein gesunder Mittelweg und dafür wäre es interessant, wie bisher Anwesenheit symbolisiert wird. Wo wird wann und wie welches Bit gesetzt?
from doorpi.
Viele setzen über die Anwesenheit des Handy´s (banal, oder?) die Anwesenheitsvariable. Diese alle 2-5min auszulesen würde IMHO die Systeme nicht belasten und ausreichend genau sein.
from doorpi.
@hermanthegerman2: Bitte mal testen :)
from doorpi.
hast eine PM. Sieht aber schon mal sehr gut aus. Hattest übrigens Recht, dass simplejson nicht unbedingt benötigt wird. Habe es heute nochmal getestet!
from doorpi.
Zwischenstand: IPS_Variable wird geholt, make_call macht Probleme! benötige Hilfe
from doorpi.
Heute Abend im IRC an bekannter Stelle?
from doorpi.
abgemacht!
from doorpi.
Moin,
leider klappt das Script von hermanthegerman2 nicht mehr. Hast du ne Idee woran das liegen könnte?
from doorpi.
´´´
#!/usr/bin/env python
-- coding: utf-8 --
import logging
logger = logging.getLogger(name)
logger.debug("%s loaded", name)
import doorpi
import requests
import json
from requests.auth import HTTPBasicAuth
from action.base import SingleAction
def ips_rpc_create_config():
config = {}
config['webservice_url'] = doorpi.DoorPi().config.get('IP-Symcon', 'server')
config['username'] = doorpi.DoorPi().config.get('IP-Symcon', 'username')
config['password'] = doorpi.DoorPi().config.get('IP-Symcon', 'password')
config['jsonrpc'] = doorpi.DoorPi().config.get('IP-Symcon', 'jsonrpc', '2.0')
config['headers'] = {'content-type': 'application/json'}
return config
def ips_rpc_fire(method, config, *parameters):
payload = {
"method": method,
"params": parameters,
"jsonrpc": config['jsonrpc'],
"id": 0,
}
return requests.post(
config['webservice_url'],
headers = config['headers'],
auth = HTTPBasicAuth(config['username'], config['password']),
data = json.dumps(payload)
)
def ips_rpc_check_variable_exists(key, config = None):
if config is None: config = ips_rpc_create_config()
response = ips_rpc_fire('IPS_VariableExists', config, key)
logging.debug("IPS_VariableExists: %s", response.json['result'])
return response.json['result']
def ips_rpc_get_variable_type(key, config = None):
if config is None: config = ips_rpc_create_config()
response = ips_rpc_fire('IPS_GetVariable', config, key)
logging.debug("IPS_GetVariable: %s", response.json['result'])
return response.json['result']['VariableValue']['ValueType']
def ips_rpc_get_variable_value(key, config = None):
if config is None: config = ips_rpc_create_config()
response = ips_rpc_fire('GetValue', config, key)
logging.debug("IPS_GetValue: %s", response.json['result'])
return response.json['result']
def ips_rpc_call_phonenumber_from_variable(key, config = None):
try:
if config is None: config = ips_rpc_create_config()
if ips_rpc_check_variable_exists(key, config) is not True: raise Exception("var %s doesn't exist", key)
type = ips_rpc_get_variable_type(key, config)
if type is None: raise Exception("type of var %s couldn't find", key)
# http://www.ip-symcon.de/service/dokumentation/befehlsreferenz/variablenverwaltung/ips-getvariable/
# Variablentyp (0: Boolean, 1: Integer, 2: Float, 3: String)
elif type is not 3: raise Exception("phonenumber from var %s is not a string", key)
phonenumber = ips_rpc_get_variable_value(key, config)
logging.debug(phonenumber)
from action.SingleActions.call import make_call
make_call(phonenumber)
except Exception as ex:
logger.exception("couldn't get phonenumber from IpsRpc (%s)", ex)
return False
return True
def get(parameters):
parameter_list = parameters.split(',')
if len(parameter_list) is not 1: return None
key = int(parameter_list[0])
return IpsRpcCallPhonenumberFromVariableAction(ips_rpc_call_phonenumber_from_variable, key)
class IpsRpcCallPhonenumberFromVariableAction(SingleAction):
pass
´´´
from doorpi.
Related Issues (20)
- Commit to SQLite missing in handler.py HOT 1
- Anleitung ist an einer Stelle irreführend HOT 1
- RasPi Temperatur in der WebIf HOT 2
- FriendlyElec NanoPi Neo Kompatibilität HOT 1
- button_pressed HOT 3
- Probleme mit DoorPi / und SIP -Fone HOT 2
- alternativer SIP client zu linphone HOT 5
- USB Keyboard intregration HOT 2
- how to configure user id HOT 1
- [Wunsch] event network connection changed HOT 2
- Link zur Installationsanleitung HOT 3
- DoorPi successfully shut down HOT 2
- Installation von pjsip nicht möglich HOT 1
- [Feature request] Supporting MQTT
- Umstellung Build System Interface
- Integration pylint bei PR zu master HOT 1
- Integration test-suite bei PR zu master
- Integration PyPI-Veröffentlichung bei merge auf master
- Integration i18n und i10n
- SQLite aus DoorPi entfernen
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doorpi.