Skip to content

Commit

Permalink
Invert EnOcean contact
Browse files Browse the repository at this point in the history
  • Loading branch information
Mat931 committed Dec 8, 2023
1 parent a436d41 commit fe52757
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
14 changes: 10 additions & 4 deletions custom_components/digitalstrom/api/apartment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from .client import DigitalstromClient
from .exceptions import ServerError

INVERTED_BINARY_INPUTS = ["EnOcean single contact (D5-00-01)"]


class DigitalstromChannel:
def __init__(self, device, index):
Expand Down Expand Up @@ -39,7 +41,7 @@ class DigitalstromBinaryInputChannel(DigitalstromChannel):
def __init__(self, device, index, input_type, inverted):
super().__init__(device, index)
self.input_type = input_type
self.inverted = inverted
self.inverted = bool(inverted)


class DigitalstromOutputChannel(DigitalstromChannel):
Expand Down Expand Up @@ -173,9 +175,13 @@ def _load_sensors(self, data):

def _load_binary_inputs(self, data):
if binary_inputs := data.get("binaryInputs"):
inverted = (input_property := data.get("AKMInputProperty")) and (
input_property == "inverted"
)
inverted = False
# if (input_property := data.get("AKMInputProperty")) and (
# input_property == "inverted"
# ):
# inverted = True
if self.hw_info in INVERTED_BINARY_INPUTS:
inverted = True
for index in range(len(binary_inputs)):
input_dict = binary_inputs[index]
group = input_dict.get("targetGroup")
Expand Down
4 changes: 1 addition & 3 deletions custom_components/digitalstrom/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ async def start_event_listener(self):
if msg.type == aiohttp.WSMsgType.TEXT:
self.last_event = time.time()
event = json.loads(msg.data)
if name := event.get("name"):
# if event["name"] == "keepWebserviceAlive":
# print(f"Keepalive: {time.time()}")
if event.get("name"):
for callback in self._event_callbacks:
await callback(event)
else:
Expand Down
2 changes: 1 addition & 1 deletion custom_components/digitalstrom/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ async def async_will_remove_from_hass(self) -> None:
@property
def is_on(self) -> bool:
"""Return the state of the sensor."""
return self._state
return (not bool(self._state)) if self.inverted else bool(self._state)
2 changes: 1 addition & 1 deletion custom_components/digitalstrom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"manufacturer": "aizo ag"
}
],
"version": "0.0.3",
"version": "0.0.4",
"zeroconf": ["_dssweb._tcp.local."]
}

0 comments on commit fe52757

Please sign in to comment.