PySwitchbot 0.55.3__tar.gz → 0.55.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PKG-INFO +1 -1
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PySwitchbot.egg-info/PKG-INFO +1 -1
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/setup.py +1 -1
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/relay_switch.py +10 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/tests/test_relay_switch.py +15 -1
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/LICENSE +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/MANIFEST.in +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PySwitchbot.egg-info/SOURCES.txt +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PySwitchbot.egg-info/dependency_links.txt +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PySwitchbot.egg-info/requires.txt +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/PySwitchbot.egg-info/top_level.txt +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/README.md +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/setup.cfg +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/__init__.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parser.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/__init__.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/blind_tilt.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/bot.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/bulb.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/ceiling_light.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/contact.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/curtain.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/hub2.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/humidifier.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/keypad.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/leak.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/light_strip.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/lock.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/meter.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/motion.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/plug.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/adv_parsers/relay_switch.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/api_config.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/const.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/__init__.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/base_cover.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/base_light.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/blind_tilt.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/bot.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/bulb.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/ceiling_light.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/contact.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/curtain.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/device.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/humidifier.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/keypad.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/light_strip.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/lock.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/meter.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/motion.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/devices/plug.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/discovery.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/enum.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/switchbot/models.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/tests/test_adv_parser.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/tests/test_base_cover.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/tests/test_blind_tilt.py +0 -0
- {pyswitchbot-0.55.3 → pyswitchbot-0.55.4}/tests/test_curtain.py +0 -0
|
@@ -17,6 +17,7 @@ COMMAND_TURN_OFF = f"{COMMAND_HEADER}0f70010000"
|
|
|
17
17
|
COMMAND_TURN_ON = f"{COMMAND_HEADER}0f70010100"
|
|
18
18
|
COMMAND_TOGGLE = f"{COMMAND_HEADER}0f70010200"
|
|
19
19
|
COMMAND_GET_VOLTAGE_AND_CURRENT = f"{COMMAND_HEADER}0f7106000000"
|
|
20
|
+
COMMAND_GET_SWITCH_STATE = f"{COMMAND_HEADER}0f7101000000"
|
|
20
21
|
PASSIVE_POLL_INTERVAL = 10 * 60
|
|
21
22
|
|
|
22
23
|
|
|
@@ -87,6 +88,15 @@ class SwitchbotRelaySwitch(SwitchbotEncryptedDevice):
|
|
|
87
88
|
}
|
|
88
89
|
return None
|
|
89
90
|
|
|
91
|
+
async def get_basic_info(self) -> dict[str, Any] | None:
|
|
92
|
+
"""Get the current state of the switch."""
|
|
93
|
+
result = await self._send_command(COMMAND_GET_SWITCH_STATE)
|
|
94
|
+
if self._check_command_result(result, 0, {1}):
|
|
95
|
+
return {
|
|
96
|
+
"is_on": result[1] & 0x01 != 0,
|
|
97
|
+
}
|
|
98
|
+
return None
|
|
99
|
+
|
|
90
100
|
def poll_needed(self, seconds_since_last_poll: float | None) -> bool:
|
|
91
101
|
"""Return if device needs polling."""
|
|
92
102
|
if self._force_next_update:
|
|
@@ -53,8 +53,22 @@ async def test_turn_on():
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
@pytest.mark.asyncio
|
|
56
|
-
async def
|
|
56
|
+
async def test_turn_off():
|
|
57
57
|
relay_switch_device = create_device_for_command_testing()
|
|
58
58
|
relay_switch_device._send_command = AsyncMock(return_value=b"\x01")
|
|
59
59
|
await relay_switch_device.turn_off()
|
|
60
60
|
assert relay_switch_device.is_on() is False
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
@pytest.mark.asyncio
|
|
64
|
+
async def test_get_basic_info():
|
|
65
|
+
relay_switch_device = create_device_for_command_testing()
|
|
66
|
+
relay_switch_device._send_command = AsyncMock(return_value=b"\x01\x01")
|
|
67
|
+
info = await relay_switch_device.get_basic_info()
|
|
68
|
+
assert info["is_on"] is True
|
|
69
|
+
relay_switch_device._send_command = AsyncMock(return_value=b"\x01\x00")
|
|
70
|
+
info = await relay_switch_device.get_basic_info()
|
|
71
|
+
assert info["is_on"] is False
|
|
72
|
+
relay_switch_device._send_command = AsyncMock(return_value=b"\x00\x00")
|
|
73
|
+
info = await relay_switch_device.get_basic_info()
|
|
74
|
+
assert info is None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|