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

Anbindung Webservice IP-Symcon #31

Closed
motom001 opened this issue Jan 18, 2015 · 1 comment
Closed

Anbindung Webservice IP-Symcon #31

motom001 opened this issue Jan 18, 2015 · 1 comment

Comments

@motom001
Copy link
Owner

Hallo Thomas,

habe damit begonnen doorpi mit einer Anbindung zum IP-Symcon (http://www.ip-symcon.de) auszustatten. IP-Symcon ist ein Smarthome Anwendung, welche verschiedene Hardware miteinander verbinden kann.

Die Kommunikation zu IP-Symcon lässt sich über ein API (siehe hierzu Forenbeitrag: http://www.ip-symcon.de/forum/threads/26516-JSON-RPC-%C3%BCber-Python?highlight=python+rpc) herstellen.

Beschreibung der API in IP-Symcon findet man hier: http://www.ip-symcon.de/service/dokumentation/entwicklerbereich/datenaustausch/

Mein Ziel ist es eventgesteuert aus doorpi Variablen in IP-Symcon zu verändern.

Dazu folgender Eintrag in der doorpi.cfg

[EVENT_OnCallStateConnect]
10 = out:1,1
20 = ipsrpc:40276,TRUE

[EVENT_OnCallStateDisconnect]
10 = out:1,0
20 = ipsrpc:40276,FALSE[/code]

40276 ist meine Variablennummer des Typs BOOLEAN in IP-Symcon.

und folgendes script im Ordner: /home/pi/doorpi/doorpi/action/SingleActions/ipsrpc.py

#!/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 IpsRpc(methodIps, paramIps):
    try:
        url = "http://192.168.178.5:82/api/"
        auth=HTTPBasicAuth('user', 'password')
        headers = {'content-type': 'application/json'}

        payload = {
           "method": methodIps,
           "params": paramIps,
           "jsonrpc": "2.0",
           "id": 0,
        }
        response = requests.post(url, auth=auth, data=json.dumps(payload), headers=headers).json
        logger.debug(response)
    except:
        logger.exception("couldn't send IpsRpc")
        return False
    return True

def get(parameters):
    parameter_list = parameters.split(',')
    if len(parameter_list) is not 2: return None

    variable = parameter_list[0]
    value = parameter_list[1]

    return IpsRpcAction(IpsRpc, "SetValue", [variable,value])

class IpsRpcAction(SingleAction):
    pass

Die Events werden im doorpi.log geladen und auch beim entsprechenden event ausgelöst, jedoch geht keine Message an IP-Symcon. Ich bin mit meinem "Latein" am Ende und komme hier nicht weiter.

Mit Wireshark kann ich keinen Netzwerkverkehr zwischen doorpi (192.168.178.9) und IP-Symcon (192.168.178.5) feststellen.

Hast Du evtl eine Idee ?

Falls wir das hinkriegen würde ich im IP-Symcon Forum mal die Brücke zu Deinem doorpie Projekt schlagen, da dort auch öfters nach einer intelligenten "Klingellösung" gesucht wird. Wäre doch gelacht, wenn Du die 10 Votes für den Banana Pi nicht zusammenkriegen würdest ;-)

Gruß,
Hermann

@motom001
Copy link
Owner Author

Konfiguration innerhalb der Config-Datei mittels

[IP-Symcon]
server = http://192.168.178.5:82/api/
username = user
password = password
jsonrpc = 2.0

Genutzt kann es in der Config-Datei z.B. mittels:

[EVENT_OnCallStateConnect]
10 = out:1,1
20 = ipsrpc_setvalue:40276,TRUE

[EVENT_OnCallStateDisconnect]
10 = out:1,0
20 = ipsrpc_setvalue:40276,FALSE

motom001 added a commit that referenced this issue Jan 18, 2015
…den typ abfragen und dann versuchen value zu konvertieren
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

1 participant