diff --git a/homeassistant/components/ads/__init__.py b/homeassistant/components/ads/__init__.py index 15d58eb4620..b17a066eba7 100644 --- a/homeassistant/components/ads/__init__.py +++ b/homeassistant/components/ads/__init__.py @@ -230,7 +230,13 @@ class AdsHub: hnotify = int(contents.hNotification) _LOGGER.debug("Received notification %d", hnotify) - data = contents.data + + # get dynamically sized data array + data_size = contents.cbSampleSize + data = (ctypes.c_ubyte * data_size).from_address( + ctypes.addressof(contents) + + pyads.structs.SAdsNotificationHeader.data.offset + ) try: with self._lock: @@ -241,17 +247,17 @@ class AdsHub: # Parse data to desired datatype if notification_item.plc_datatype == self.PLCTYPE_BOOL: - value = bool(struct.unpack("