Moin,
doch noch heute (Beispielcode):
Code: Alles auswählen
#!/usr/bin/env python
# encoding: utf-8
#
# Beispiele, die allerdings ohne die entsprechenden Geräte/Variablen nicht funktionieren!
# ohne Gewähr für Richtigkeit etc.
# (angepasst auf die Standard pmatic - Bibliothek)
#
from __future__ import print_function
import sys
sys.path.append("/opt/pmatic/module_py")
import pmatic.api
# Anmeldung --------------------------------------------------------------------
API = pmatic.api.init(
address="http://<IP-Adresse",
credentials=("<User>", "<Passwort>"),
connect_timeout=3,
)
# Methoden auflisten ---------------------------------------------------------
API.print_methods()
# Devices auflisten ------------------------------------------------------------
try:
devices = API.device_list_all_detail()
except:
pass
#devices = API.device_list_all()
line_fmt = "%-30s %s"
# Print the header
print(line_fmt % ("Name", "State"))
print(line_fmt % ("-" * 30, "-" * 6))
# Loop all devices, only care about shutter contacts
for device in devices:
print (device["name"], device["type"], device["address"])
for c in device["channels"]:
print (device["name"], c["channelType"], c["deviceId"])
# Devices auflisten Ende -------------------------------------------------------
# Systemvariable auslesen/Setzen ------------------------------------------------------
try:
print ("svb_Test_sv: ", API.sys_var_get_value_by_name(name="svb_Test_sv"))
API.sys_var_set_bool(name="svb_Test_sv", value="0")
print ("svb_Test_sv: ", API.sys_var_get_value_by_name(name="svb_Test_sv"))
API.sys_var_set_bool(name="svb_Test_sv", value="1")
print ("svb_Test_sv: ", API.sys_var_get_value_by_name(name="svb_Test_sv"))
except Exception, err:
print ("svb_Test_sv_Fehler:", Exception, err)
# Achtung, zum Setzen bei anderem Datentyp anderer Aufruf!
# Anzahl Servicemeldungen ------------------------------------------------------
try:
svc_anz = API.interface_get_service_message_count(interface="BidCos-RF")
print ("Svc_Anz:", svc_anz)
except Exception, err:
print ("Svc_Anz_Fehler:", Exception, err)
# Lichtsensor ------------------------------------------------------------------
try:
Lichtsensor_Wert = float(API.channel_get_value(id="Lichtsensor:1"))
print ("Lichtsensor:", Lichtsensor_Wert)
except Exception, err:
print ("Lichtsensor_Fehler:", Exception, err)
# 8Kanal Empfänger (Typ: HM-MOD-Re-8, SN:<SN>, Name:Test_Receiver)
try:
Schalter01 = API.channel_get_value(id="Test_Receiver:1")
print ("Schalter01a:", Schalter01)
Ergebnis=API.interface_set_value(interface="BidCos-RF", address="<SN>:1", valueKey="STATE", type="bool", value="true")
Schalter01 = API.channel_get_value(id="Test_Receiver:1")
print ("Schalter01b:", Schalter01)
except Exception, err:
print ("Schalter01_Fehler:", Exception, err)
# Rollladen/Markise (Typ: HM-LC-Bl1PBU-FM, SN: <SN>, Name: Rollladen)------
try:
rollostand = float(API.channel_get_value(id="Rollladen:1"))
print ("Rollladen: ",rollostand)
Ergebnis=API.interface_set_value(interface="BidCos-RF", address="<SN>:1", valueKey="LEVEL", type="string", value="1.0")
except Exception, err:
print ("Rollladen_Fehler:", Exception, err)
# Lampe (Typ: HM-LC-Sw1-Pl-DN-R1, SN: <SN>, Name=Lampe) ------------------------
try:
lampe_anaus = API.channel_get_value(id="Lampe:1")
print ("Lampe: ",lampe_anaus)
Ergebnis=API.interface_set_value(interface="BidCos-RF", address="<SN>:1", valueKey="STATE", type="bool", value="true")
except Exception, err:
print ("Lampe_Fehler:", Exception, err)
API.close
Auf der CCU (org, YAHM, piVCCU, piVCCU3) braucht nichts installiert zu werden.
piVCCu3 funktioniert bisher auch; Tests gehen aber noch weiter.
Viel Spaß beim Testen ....