Giter Club home page Giter Club logo

Comments (10)

hermanthegerman2 avatar hermanthegerman2 commented on July 22, 2024

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.

motom001 avatar motom001 commented on July 22, 2024

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.

hermanthegerman2 avatar hermanthegerman2 commented on July 22, 2024

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.

motom001 avatar motom001 commented on July 22, 2024

@hermanthegerman2: Bitte mal testen :)

from doorpi.

hermanthegerman2 avatar hermanthegerman2 commented on July 22, 2024

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.

hermanthegerman2 avatar hermanthegerman2 commented on July 22, 2024

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

from doorpi.

motom001 avatar motom001 commented on July 22, 2024

Heute Abend im IRC an bekannter Stelle?

from doorpi.

hermanthegerman2 avatar hermanthegerman2 commented on July 22, 2024

abgemacht!

from doorpi.

wuppi83 avatar wuppi83 commented on July 22, 2024

Moin,

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

from doorpi.

wuppi83 avatar wuppi83 commented on July 22, 2024

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.