mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 10:17:51 +00:00
Fix ads integration after 0.113 (#38402)
This commit is contained in:
parent
79055487ed
commit
0136c565eb
@ -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("<?", bytearray(data)[:1])[0])
|
||||
value = bool(struct.unpack("<?", bytearray(data))[0])
|
||||
elif notification_item.plc_datatype == self.PLCTYPE_INT:
|
||||
value = struct.unpack("<h", bytearray(data)[:2])[0]
|
||||
value = struct.unpack("<h", bytearray(data))[0]
|
||||
elif notification_item.plc_datatype == self.PLCTYPE_BYTE:
|
||||
value = struct.unpack("<B", bytearray(data)[:1])[0]
|
||||
value = struct.unpack("<B", bytearray(data))[0]
|
||||
elif notification_item.plc_datatype == self.PLCTYPE_UINT:
|
||||
value = struct.unpack("<H", bytearray(data)[:2])[0]
|
||||
value = struct.unpack("<H", bytearray(data))[0]
|
||||
elif notification_item.plc_datatype == self.PLCTYPE_DINT:
|
||||
value = struct.unpack("<i", bytearray(data)[:4])[0]
|
||||
value = struct.unpack("<i", bytearray(data))[0]
|
||||
elif notification_item.plc_datatype == self.PLCTYPE_UDINT:
|
||||
value = struct.unpack("<I", bytearray(data)[:4])[0]
|
||||
value = struct.unpack("<I", bytearray(data))[0]
|
||||
else:
|
||||
value = bytearray(data)
|
||||
_LOGGER.warning("No callback available for this datatype")
|
||||
|
@ -2,6 +2,6 @@
|
||||
"domain": "ads",
|
||||
"name": "ADS",
|
||||
"documentation": "https://www.home-assistant.io/integrations/ads",
|
||||
"requirements": ["pyads==3.1.3"],
|
||||
"requirements": ["pyads==3.2.1"],
|
||||
"codeowners": []
|
||||
}
|
||||
|
@ -1202,7 +1202,7 @@ py_nextbusnext==0.1.4
|
||||
# py_noaa==0.3.0
|
||||
|
||||
# homeassistant.components.ads
|
||||
pyads==3.1.3
|
||||
pyads==3.2.1
|
||||
|
||||
# homeassistant.components.hisense_aehw4a1
|
||||
pyaehw4a1==0.3.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user