diff --git a/changes.md b/changes.md index ed795e25..8f5dee90 100644 --- a/changes.md +++ b/changes.md @@ -3,7 +3,7 @@ ## Version 1.4.1 Support for sending arbritrary messages * Added Service for sending arbritrary ESP2 messages * 🐞 Fix for TargetTemperatureSensor (EEP: A5-10-06 and A5-10-12) -* 🐞 Fix for unknow cover positions. +* 🐞 Fix for unknow cover positions and intermediate state + unit-tests added. * Unit-Tests added and improved for EEP A5-04-01, A5-04-02, A5-10-06, A5-10-12, A5-13-01, and F6-10-00. * EEP A5-04-03 added for Eltako FFT60 (temperature and humiditry) * EEP A5-06-01 added for light sensor (currently twilight and daylight are combinded in one illumination sensor/entity) diff --git a/custom_components/eltako/cover.py b/custom_components/eltako/cover.py index 7657e43b..106a20ae 100644 --- a/custom_components/eltako/cover.py +++ b/custom_components/eltako/cover.py @@ -241,7 +241,9 @@ def value_changed(self, msg): if self.dev_eep in [G5_3F_7F]: LOGGER.debug(f"[cover {self.dev_id}] G5_3F_7F - {decoded.__dict__}") - ## is received as response when button pushed + ## is received as response when button pushed (command was sent) + ## this message is received directly when the cover starts to move + ## when the cover results in completely open or close one of the following messages (open or closed) will appear if decoded.state == 0x02: # down self._attr_is_closing = True self._attr_is_opening = False @@ -261,7 +263,8 @@ def value_changed(self, msg): self._attr_is_closed = False self._attr_current_cover_position = 100 - ## is received when cover stops at a position + ## is received when cover stops at the desired intermediate position + ## if not close state is always open (close state should be reported with closed message above) elif decoded.time is not None and decoded.direction is not None and self._time_closes is not None and self._time_opens is not None: time_in_seconds = decoded.time / 10.0 @@ -288,10 +291,6 @@ def value_changed(self, msg): self._attr_is_closed = True self._attr_is_opening = False self._attr_is_closing = False - # elif self._attr_current_cover_position == 100: - # self._attr_is_closed = False - # self._attr_is_opening = False - # self._attr_is_closing = False else: self._attr_is_closed = False self._attr_is_opening = False diff --git a/tests/test_cover.py b/tests/test_cover_G5_3F_7F.py similarity index 83% rename from tests/test_cover.py rename to tests/test_cover_G5_3F_7F.py index 66fddd9b..4b217595 100644 --- a/tests/test_cover.py +++ b/tests/test_cover_G5_3F_7F.py @@ -25,8 +25,8 @@ def create_cover(self) -> EltakoCover: dev_id = AddressExpression.parse('00-00-00-01') dev_name = 'device name' device_class = "shutter" - time_closes = 3 - time_opens = 3 + time_closes = 10 + time_opens = 10 eep_string = "G5-3F-7F" sender_id = AddressExpression.parse("00-00-B1-06") @@ -79,6 +79,35 @@ def test_cover_value_changed(self): self.assertEqual(ec._attr_current_cover_position, 100) + def test_cover_intermediate_cover_positions(self): + ec = self.create_cover() + + msg = Regular4BSMessage(address=b'\x00\x00\x00\x01', status=b'\x20', data=b'\x00\x1e\x01\x0a', outgoing=False) + ec._attr_current_cover_position = 10 + ec.value_changed(msg) + self.assertEqual(ec._attr_is_closing, False) + self.assertEqual(ec._attr_is_opening, False) + self.assertEqual(ec._attr_is_closed, False) + self.assertEqual(ec._attr_current_cover_position, 40) + + msg = Regular4BSMessage(address=b'\x00\x00\x00\x01', status=b'\x20', data=b'\x00\x0a\x01\x0a', outgoing=False) + ec._attr_current_cover_position = 0 + ec.value_changed(msg) + self.assertEqual(ec._attr_is_closing, False) + self.assertEqual(ec._attr_is_opening, False) + self.assertEqual(ec._attr_is_closed, False) + self.assertEqual(ec._attr_current_cover_position, 10) + + msg = Regular4BSMessage(address=b'\x00\x00\x00\x01', status=b'\x20', data=b'\x00\x5a\x02\x0a', outgoing=False) + ec._attr_current_cover_position = 100 + ec.value_changed(msg) + self.assertEqual(ec._attr_is_closing, False) + self.assertEqual(ec._attr_is_opening, False) + self.assertEqual(ec._attr_is_closed, False) + self.assertEqual(ec._attr_current_cover_position, 10) + + + def test_open_cover(self): ec = self.create_cover() @@ -199,4 +228,7 @@ def test_initial_loading_closed(self): self.assertEqual(ec.is_opening, False) self.assertEqual(ec.is_closing, False) self.assertEqual(ec.state, 'closed') - self.assertEqual(ec.current_cover_position, 0) \ No newline at end of file + self.assertEqual(ec.current_cover_position, 0) + + +