Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telefonnummern richten sich nach Anwesenheit #32

Closed
motom001 opened this issue Jan 22, 2015 · 10 comments
Closed

Telefonnummern richten sich nach Anwesenheit #32

motom001 opened this issue Jan 22, 2015 · 10 comments

Comments

@motom001
Copy link
Owner

Wünsche von hier:
http://www.ip-symcon.de/forum/threads/26739-DoorPI-VoIP-Door-Intercomstation-with-Raspberry-Pi?p=245497#post245497

Meine Wünsche wären ...

V1. Ist wer zu Hause = Haustelefon und Videostream auf dem Monitor
V2. ist keiner zu Hause = Videostream auf dem Handy

VG

Andreas

@hermanthegerman2
Copy link
Contributor

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?

@motom001
Copy link
Owner Author

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?

@hermanthegerman2
Copy link
Contributor

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.

@motom001
Copy link
Owner Author

@hermanthegerman2: Bitte mal testen :)

@hermanthegerman2
Copy link
Contributor

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!

@hermanthegerman2
Copy link
Contributor

Zwischenstand: IPS_Variable wird geholt, make_call macht Probleme! benötige Hilfe

@motom001
Copy link
Owner Author

Heute Abend im IRC an bekannter Stelle?

@hermanthegerman2
Copy link
Contributor

abgemacht!

@wuppi83
Copy link

wuppi83 commented Jan 28, 2015

Moin,

leider klappt das Script von hermanthegerman2 nicht mehr. Hast du ne Idee woran das liegen könnte?

@wuppi83
Copy link

wuppi83 commented Jan 28, 2015

´´´
#!/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
´´´

@motom001 motom001 added this to the v2.0 RC2 milestone Feb 2, 2015
hermanthegerman2 referenced this issue Feb 2, 2015
Zeile 49  response = ips_rpc_fire('GetValue', config, key) editiert.

Danach erfolgreich getestet. Issue kann geschlossen werden.
@motom001 motom001 closed this as completed Feb 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants