1
0
mirror of https://github.com/home-assistant/core.git synced 2026-04-02 08:26:41 +01:00

Bump pylutron to 0.4.0 and maintain switch compatibility (#165592)

This commit is contained in:
cdheiser
2026-03-16 11:13:23 -07:00
committed by GitHub
parent 03edee1335
commit 501c8fecec
5 changed files with 32 additions and 8 deletions

View File

@@ -7,6 +7,6 @@
"integration_type": "hub",
"iot_class": "local_polling",
"loggers": ["pylutron"],
"requirements": ["pylutron==0.3.0"],
"requirements": ["pylutron==0.4.0"],
"single_config_entry": true
}

View File

@@ -87,11 +87,11 @@ class LutronLed(LutronKeypad, SwitchEntity):
def turn_on(self, **kwargs: Any) -> None:
"""Turn the LED on."""
self._lutron_device.state = True
self._lutron_device.state = Led.LED_ON
def turn_off(self, **kwargs: Any) -> None:
"""Turn the LED off."""
self._lutron_device.state = False
self._lutron_device.state = Led.LED_OFF
@property
def extra_state_attributes(self) -> Mapping[str, Any] | None:
@@ -108,4 +108,4 @@ class LutronLed(LutronKeypad, SwitchEntity):
def _update_attrs(self) -> None:
"""Update the state attributes."""
self._attr_is_on = self._lutron_device.last_state
self._attr_is_on = self._lutron_device.last_state != Led.LED_OFF

2
requirements_all.txt generated
View File

@@ -2254,7 +2254,7 @@ pylitterbot==2025.1.0
pylutron-caseta==0.27.0
# homeassistant.components.lutron
pylutron==0.3.0
pylutron==0.4.0
# homeassistant.components.mailgun
pymailgunner==1.4

View File

@@ -1928,7 +1928,7 @@ pylitterbot==2025.1.0
pylutron-caseta==0.27.0
# homeassistant.components.lutron
pylutron==0.3.0
pylutron==0.4.0
# homeassistant.components.mailgun
pymailgunner==1.4

View File

@@ -2,6 +2,7 @@
from unittest.mock import MagicMock, patch
from pylutron import Led
import pytest
from syrupy.assertion import SnapshotAssertion
@@ -10,6 +11,7 @@ from homeassistant.const import (
ATTR_ENTITY_ID,
SERVICE_TURN_OFF,
SERVICE_TURN_ON,
STATE_ON,
Platform,
)
from homeassistant.core import HomeAssistant
@@ -105,7 +107,7 @@ async def test_led_turn_on_off(
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
assert led.state == 1
assert led.state == Led.LED_ON
# Turn off
await hass.services.async_call(
@@ -114,4 +116,26 @@ async def test_led_turn_on_off(
{ATTR_ENTITY_ID: entity_id},
blocking=True,
)
assert led.state == 0
assert led.state == Led.LED_OFF
@pytest.mark.parametrize("led_state", [Led.LED_SLOW_FLASH, Led.LED_FAST_FLASH])
async def test_led_flash_states(
hass: HomeAssistant,
mock_lutron: MagicMock,
mock_config_entry: MockConfigEntry,
led_state: int,
) -> None:
"""Test LED in flash states."""
mock_config_entry.add_to_hass(hass)
led = mock_lutron.areas[0].keypads[0].leds[0]
led.last_state = led_state
await hass.config_entries.async_setup(mock_config_entry.entry_id)
await hass.async_block_till_done()
entity_id = "switch.test_keypad_test_button"
state = hass.states.get(entity_id)
assert state is not None
assert state.state == STATE_ON