Skip to content

Commit

Permalink
cover states fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmpp committed Mar 27, 2024
1 parent c3200c8 commit 5200922
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 5 additions & 6 deletions custom_components/eltako/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
38 changes: 35 additions & 3 deletions tests/test_cover.py → tests/test_cover_G5_3F_7F.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
self.assertEqual(ec.current_cover_position, 0)



0 comments on commit 5200922

Please sign in to comment.