Skip to content

Commit

Permalink
Merge pull request #107 from aturri/dev
Browse files Browse the repository at this point in the history
fixes on capabilities:
  • Loading branch information
kloknibor committed Apr 8, 2022
2 parents b333c73 + 216a215 commit 700825e
Show file tree
Hide file tree
Showing 4 changed files with 302 additions and 267 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
**/*.pyc
.idea/
*.iml
264 changes: 264 additions & 0 deletions custom_components/miele/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,270 @@
extra=vol.ALLOW_EXTRA,
)

CAPABILITIES = {
"1": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"signalInfo",
"signalFailure",
"remoteEnable",
"elapsedTime",
"spinningSpeed",
"ecoFeedback.energyConsumption",
"ecoFeedback.waterConsumption",
],
"2": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"signalInfo",
"signalFailure",
"remoteEnable",
"elapsedTime",
"dryingStep",
"ecoFeedback.energyConsumption",
],
"7": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"signalInfo",
"signalFailure",
"remoteEnable",
"elapsedTime",
"ecoFeedback.energyConsumption",
"ecoFeedback.waterConsumption",
],
"12": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"13": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"14": ["status", "signalFailure", "plateStep"],
"15": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"16": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"17": [
"ProgramID",
"status",
"programPhase",
"signalInfo",
"signalFailure",
"remoteEnable",
],
"18": [
"status",
"signalInfo",
"signalFailure",
"remoteEnable",
"ventilationStep",
],
"19": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"20": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"21": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"23": [
"ProgramID",
"status",
"programType",
"signalInfo",
"signalFailure",
"remoteEnable",
"batteryLevel",
],
"24": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"signalInfo",
"signalFailure",
"remoteEnable",
"elapsedTime",
"spinningSpeed",
"dryingStep",
"ecoFeedback.energyConsumption",
"ecoFeedback.waterConsumption",
],
"25": [
"status",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"elapsedTime",
],
"27": ["status", "signalFailure", "plateStep"],
"31": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"32": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"33": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"34": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
],
"45": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"67": [
"ProgramID",
"status",
"programType",
"programPhase",
"remainingTime",
"startTime",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"signalDoor",
"remoteEnable",
"elapsedTime",
],
"68": [
"status",
"targetTemperature",
"temperature",
"signalInfo",
"signalFailure",
"remoteEnable",
],
}

def request_configuration(hass, config, oauth):
"""Request Miele authorization."""
Expand Down
14 changes: 11 additions & 3 deletions custom_components/miele/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from custom_components.miele import DATA_DEVICES
from custom_components.miele import DOMAIN as MIELE_DOMAIN
from custom_components.miele import CAPABILITIES

PLATFORMS = ["miele"]

Expand All @@ -14,6 +15,12 @@
ALL_DEVICES = []


def state_capability(type, state):
type_str = str(type)
if state in CAPABILITIES[type_str]:
return True


def _map_key(key):
if key == "signalInfo":
return "Info"
Expand All @@ -30,13 +37,14 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
devices = hass.data[MIELE_DOMAIN][DATA_DEVICES]
for k, device in devices.items():
device_state = device["state"]
device_type = device["ident"]["type"]["value_raw"]

binary_devices = []
if "signalInfo" in device_state:
if "signalInfo" in device_state and state_capability(type=device_type, state="signalInfo"):
binary_devices.append(MieleBinarySensor(hass, device, "signalInfo"))
if "signalFailure" in device_state:
if "signalFailure" in device_state and state_capability(type=device_type, state="signalFailure"):
binary_devices.append(MieleBinarySensor(hass, device, "signalFailure"))
if "signalDoor" in device_state:
if "signalDoor" in device_state and state_capability(type=device_type, state="signalDoor"):
binary_devices.append(MieleBinarySensor(hass, device, "signalDoor"))

add_devices(binary_devices)
Expand Down
Loading

0 comments on commit 700825e

Please sign in to comment.