Skip to content

Commit

Permalink
Simple switch timer v2: Mark dp 38 optional in available check.
Browse files Browse the repository at this point in the history
The check is against null, but the dp was not marked optional, as it
was in the original location.

Update unit test to check the available logic correctly for this file.
  • Loading branch information
make-all committed Nov 23, 2024
1 parent 51f4a0b commit cca905a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ secondary_entities:
- id: 38
type: string
name: available
optional: true
mapping:
- dps_val: null
value: false
Expand Down
9 changes: 9 additions & 0 deletions tests/devices/test_simple_switch_with_timerv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

SWITCH_DPS = "1"
TIMER_DPS = "9"
INITIAL_STATE_DPS = "38"


class TestTimedSwitch(BasicNumberTests, SwitchableTests, TuyaDeviceTestCase):
Expand All @@ -32,3 +33,11 @@ def test_extra_state_attributes_set(self):
self.subject.extra_state_attributes,
{},
)

def test_available(self):
for id, e in self.entities.items():
if id == "select_initial_state":
self.dps[INITIAL_STATE_DPS] = None
self.assertFalse(e.available)
self.dps[INITIAL_STATE_DPS] = "on"
self.assertTrue(e.available)

0 comments on commit cca905a

Please sign in to comment.