Skip to content

Commit

Permalink
Add more devices (#62)
Browse files Browse the repository at this point in the history
- Add KeyMatic
- Add HmIP-MOD-OC8
- Add HmIP-PCBS, HmIP-PCBS2, HmIP-PCBS-BAT, HmIP-USBSM
- Remove xmlrpc calls related to ccu system variables (not supported by api)
- Update hub sensor excludes
  • Loading branch information
SukramJ authored Nov 30, 2021
1 parent 5f90ffd commit f2b8954
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 108 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Version 0.0.14 (2021-11-30)
- Add KeyMatic
- Add HmIP-MOD-OC8
- Add HmIP-PCBS, HmIP-PCBS2, HmIP-PCBS-BAT, HmIP-USBSM
- Remove xmlrpc calls related to ccu system variables (not supported by api)
- Update hub sensor excludes

Version 0.0.13 (2021-11-29)
- Add HmIP-MOD-HO, HmIP-MOD-TM
- Add sub_type to device/entity
Expand Down
176 changes: 85 additions & 91 deletions hahomematic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,114 +479,108 @@ async def _check_connection(self):

async def set_system_variable(self, name, value):
"""Set a system variable on CCU / Homegear."""
if self.central.username and self.central.password:
_LOGGER.debug("set_system_variable: Setting System variable via JSON-RPC")
try:
params = {
ATTR_NAME: name,
ATTR_VALUE: value,
}
if value is True or value is False:
params[ATTR_VALUE] = int(value)
response = await self.json_rpc_session.post(
"SysVar.setBool", params
)
else:
response = await self.json_rpc_session.post(
"SysVar.setFloat", params
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
res = response[ATTR_RESULT]
if not self.central.username and self.central.password:
_LOGGER.warning(
"set_system_variable: You have to set username ans password to set a system variable via JSON-RPC"
)
return
_LOGGER.debug("set_system_variable: Setting System variable via JSON-RPC")
try:
params = {
ATTR_NAME: name,
ATTR_VALUE: value,
}
if value is True or value is False:
params[ATTR_VALUE] = int(value)
response = await self.json_rpc_session.post("SysVar.setBool", params)
else:
response = await self.json_rpc_session.post("SysVar.setFloat", params)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
res = response[ATTR_RESULT]
_LOGGER.debug(
"set_system_variable: Result while setting variable: %s",
str(res),
)
else:
if response[ATTR_ERROR]:
_LOGGER.debug(
"set_system_variable: Result while setting variable: %s",
str(res),
"set_system_variable: Error while setting variable: %s",
str(response[ATTR_ERROR]),
)
else:
if response[ATTR_ERROR]:
_LOGGER.debug(
"set_system_variable: Error while setting variable: %s",
str(response[ATTR_ERROR]),
)
except Exception:
_LOGGER.exception("set_system_variable: Exception")
else:
try:
return await self.proxy.setSystemVariable(name, value)
except ProxyException:
_LOGGER.exception("set_system_variable: ProxyException")
except Exception:
_LOGGER.exception("set_system_variable: Exception")

async def delete_system_variable(self, name):
"""Delete a system variable from CCU / Homegear."""
if self.central.username and self.central.password:
_LOGGER.debug(
"delete_system_variable: Getting System variable via JSON-RPC"
if not self.central.username and self.central.password:
_LOGGER.warning(
"delete_system_variable: You have to set username ans password to delete a system variable via JSON-RPC"
)
try:
params = {ATTR_NAME: name}
response = await self.json_rpc_session.post(
"SysVar.deleteSysVarByName",
params,
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
deleted = response[ATTR_RESULT]
_LOGGER.info("delete_system_variable: Deleted: %s", str(deleted))
except Exception:
_LOGGER.exception("delete_system_variable: Exception")
else:
try:
return await self.proxy.deleteSystemVariable(name)
except ProxyException:
_LOGGER.exception("delete_system_variable: ProxyException")
return

_LOGGER.debug("delete_system_variable: Getting System variable via JSON-RPC")
try:
params = {ATTR_NAME: name}
response = await self.json_rpc_session.post(
"SysVar.deleteSysVarByName",
params,
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
deleted = response[ATTR_RESULT]
_LOGGER.info("delete_system_variable: Deleted: %s", str(deleted))
except Exception:
_LOGGER.exception("delete_system_variable: Exception")

async def get_system_variable(self, name):
"""Get single system variable from CCU / Homegear."""
var = None
if self.central.username and self.central.password:
_LOGGER.debug("get_system_variable: Getting System variable via JSON-RPC")
try:
params = {ATTR_NAME: name}
response = await self.json_rpc_session.post(
"SysVar.getValueByName",
params,
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
# This does not yet support strings
try:
var = float(response[ATTR_RESULT])
except Exception:
var = response[ATTR_RESULT] == "true"
except Exception:
_LOGGER.exception("get_system_variable: Exception")
else:
try:
var = await self.proxy.getSystemVariable(name)
except ProxyException:
_LOGGER.exception("get_system_variable: ProxyException")
if not self.central.username and self.central.password:
_LOGGER.warning(
"get_system_variable: You have to set username ans password to get a system variable via JSON-RPC"
)
return var

_LOGGER.debug("get_system_variable: Getting System variable via JSON-RPC")
try:
params = {ATTR_NAME: name}
response = await self.json_rpc_session.post(
"SysVar.getValueByName",
params,
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
# This does not yet support strings
try:
var = float(response[ATTR_RESULT])
except Exception:
var = response[ATTR_RESULT] == "true"
except Exception:
_LOGGER.exception("get_system_variable: Exception")

return var

async def get_all_system_variables(self):
"""Get all system variables from CCU / Homegear."""
variables = {}
if self.central.username and self.central.password:
_LOGGER.debug(
"get_all_system_variables: Getting all System variables via JSON-RPC"
if not self.central.username and self.central.password:
_LOGGER.warning(
"get_all_system_variables: You have to set username ans password to get system variables via JSON-RPC"
)
try:
response = await self.json_rpc_session.post(
"SysVar.getAll",
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
for var in response[ATTR_RESULT]:
key, value = parse_ccu_sys_var(var)
variables[key] = value
return variables

_LOGGER.debug(
"get_all_system_variables: Getting all System variables via JSON-RPC"
)
try:
response = await self.json_rpc_session.post(
"SysVar.getAll",
)
if response[ATTR_ERROR] is None and response[ATTR_RESULT]:
for var in response[ATTR_RESULT]:
key, value = parse_ccu_sys_var(var)
variables[key] = value
except Exception:
_LOGGER.exception("get_all_system_variables: Exception")

except Exception:
_LOGGER.exception("get_all_system_variables: Exception")
else:
try:
variables = await self.proxy.getAllSystemVariables()
except ProxyException:
_LOGGER.exception("get_all_system_variables: ProxyException")
return variables

def get_virtual_remote(self):
Expand Down
14 changes: 12 additions & 2 deletions hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@
"BOOST_TIME",
"BOOT",
"BURST_LIMIT_WARNING",
"CLEAR_WINDOW_OPEN_SYMBOL",
"DATE_TIME_UNKNOWN",
"DECISION_VALUE",
"DEVICE_IN_BOOTLOADER",
"DEW_POINT_ALARM",
"EMERGENCY_OPERATION",
Expand All @@ -144,12 +146,16 @@
"INCLUSION_UNSUPPORTED_DEVICE",
"INHIBIT",
"INSTALL_MODE",
"LEVEL_REAL",
"OLD_LEVEL",
"PARTY_SET_POINT_TEMPERATURE",
"PARTY_TIME_END",
"PARTY_TIME_START",
"PROCESS",
"QUICK_VETO_TIME",
"SECTION",
"RELOCK_DELAY" "SECTION",
"SET_SYMBOL_FOR_HEATING_PHASE",
"STATE_UNCERTAIN",
"STICKY_UNREACH",
"SWITCH_POINT_OCCURED",
"TEMPERATURE_LIMITER",
Expand All @@ -164,12 +170,17 @@
"OVERFLOW",
"OVERHEAT",
"OVERRUN",
"REPORTING",
"RESULT",
"STATUS",
"SUBMIT",
"WORKING",
]
IGNORED_PARAMETERS_WILDCARDS_START = [
"ADJUSTING",
"ERROR",
"PARTY_START",
"PARTY_STOP",
"STATUS_FLAG",
]

Expand Down Expand Up @@ -227,7 +238,6 @@
ATTR_HM_LOGIC = "LOGIC"
ATTR_HM_NAME = "NAME"
ATTR_HM_NUMBER = "NUMBER"
ATTR_HM_FLAGS = "FLAGS"
ATTR_HM_UNIT = "UNIT"
ATTR_HM_MAX = "MAX"
ATTR_HM_MIN = "MIN"
Expand Down
4 changes: 2 additions & 2 deletions hahomematic/devices/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,9 +483,9 @@ def make_ip_thermostat(device, address, group_base_channels: [int]):
"HmIP-BWTH*": (make_ip_thermostat, []),
"HmIP-eTRV*": (make_ip_thermostat, []),
"HmIP-HEATING": (make_ip_thermostat, []),
"HmIP-STHD": (make_ip_thermostat, []),
"HmIP-STH*": (make_ip_thermostat, []),
"HmIP-WTH*": (make_ip_thermostat, []),
"HmIPW-STHD": (make_ip_thermostat, []),
"HmIPW-STH*": (make_ip_thermostat, []),
"HmIPW-WTH*": (make_ip_thermostat, []),
"Thermostat AA*": (make_ip_thermostat, []),
"ZEL STG RM FWT": (make_simple_thermostat, []),
Expand Down
1 change: 1 addition & 0 deletions hahomematic/devices/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,5 @@ def make_rf_blind(device, address, group_base_channels: [int]):
"263 147": (make_rf_blind, []),
"HM-LC-BlX": (make_rf_blind, []),
"HM-Sec-Win": (make_rf_blind, []),
"HMW-LC-Bl1*": (make_rf_blind, []),
}
15 changes: 15 additions & 0 deletions hahomematic/devices/device_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
FIELD_LOWERING_MODE = "lowering_mode"
FIELD_MANU_MODE = "manu_mode"
FIELD_OPERATING_VOLTAGE = "operating_voltage"
FIELD_OPEN = "open"
FIELD_PARTY_MODE = "party_mode"
FIELD_POWER = "power"
FIELD_RSSI_DEVICE = "rssi_device"
Expand Down Expand Up @@ -76,6 +77,7 @@ class Devices(Enum):
IP_THERMOSTAT = "IPThermostat"
RF_COVER = "RfCover"
RF_DIMMER = "RfDimmer"
RF_LOCK = "RfLock"
RF_THERMOSTAT = "RfThermostat"
SIMPLE_RF_THERMOSTAT = "SimpleRfThermostat"

Expand Down Expand Up @@ -268,6 +270,19 @@ class Devices(Enum):
DD_FIELDS: {},
},
},
Devices.RF_LOCK: {
DD_DEVICE_GROUP: {
DD_PHY_CHANNEL: [],
DD_VIRT_CHANNEL: [],
DD_FIELDS_REP: {},
DD_FIELDS: {
1: {
FIELD_STATE: "STATE",
FIELD_OPEN: "OPEN",
}
},
},
},
Devices.RF_THERMOSTAT: {
DD_DEVICE_GROUP: {
DD_PHY_CHANNEL: [1, 2, 3, 4],
Expand Down
1 change: 1 addition & 0 deletions hahomematic/devices/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def make_ip_light_bsl(device, address, group_base_channels: [int]):
"263 132": (make_rf_dimmer, []),
"263 133": (make_rf_dimmer, []),
"263 134": (make_rf_dimmer, []),
"HSS-DX": (make_rf_dimmer, []),
"HmIPW-DRD3": (make_ip_dimmer, [1, 5, 9, 13]),
"HmIP-DRDI3": (make_ip_dimmer, [5, 9, 13]),
}
Loading

0 comments on commit f2b8954

Please sign in to comment.