mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Bump whirlpool-sixth-sense to 0.18.0 (#84945)
* bump whirlpool_sixth_sense to 18.0 add callback method initiated in 18.0 * add disconnect to mock
This commit is contained in:
parent
f56f391f81
commit
b65d4a9efd
@ -107,8 +107,8 @@ class AirConEntity(ClimateEntity):
|
||||
|
||||
def __init__(self, hass, said, name, backend_selector: BackendSelector, auth: Auth):
|
||||
"""Initialize the entity."""
|
||||
self._aircon = Aircon(backend_selector, auth, said, self.async_write_ha_state)
|
||||
|
||||
self._aircon = Aircon(backend_selector, auth, said)
|
||||
self._aircon.register_attr_callback(self.async_write_ha_state)
|
||||
self.entity_id = generate_entity_id(ENTITY_ID_FORMAT, said, hass=hass)
|
||||
self._attr_name = name if name is not None else said
|
||||
self._attr_unique_id = said
|
||||
@ -117,6 +117,10 @@ class AirConEntity(ClimateEntity):
|
||||
"""Connect aircon to the cloud."""
|
||||
await self._aircon.connect()
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Close Whrilpool Appliance sockets before removing."""
|
||||
await self._aircon.disconnect()
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
"""Return True if entity is available."""
|
||||
|
@ -3,7 +3,7 @@
|
||||
"name": "Whirlpool Sixth Sense",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/whirlpool",
|
||||
"requirements": ["whirlpool-sixth-sense==0.17.1"],
|
||||
"requirements": ["whirlpool-sixth-sense==0.18.0"],
|
||||
"codeowners": ["@abmantis"],
|
||||
"iot_class": "cloud_push",
|
||||
"loggers": ["whirlpool"]
|
||||
|
@ -2570,7 +2570,7 @@ waterfurnace==1.1.0
|
||||
webexteamssdk==1.1.1
|
||||
|
||||
# homeassistant.components.whirlpool
|
||||
whirlpool-sixth-sense==0.17.1
|
||||
whirlpool-sixth-sense==0.18.0
|
||||
|
||||
# homeassistant.components.whois
|
||||
whois==0.9.16
|
||||
|
@ -1795,7 +1795,7 @@ wallbox==0.4.12
|
||||
watchdog==2.2.0
|
||||
|
||||
# homeassistant.components.whirlpool
|
||||
whirlpool-sixth-sense==0.17.1
|
||||
whirlpool-sixth-sense==0.18.0
|
||||
|
||||
# homeassistant.components.whois
|
||||
whois==0.9.16
|
||||
|
@ -56,6 +56,7 @@ def get_aircon_mock(said):
|
||||
"""Get a mock of an air conditioner."""
|
||||
mock_aircon = mock.Mock(said=said)
|
||||
mock_aircon.connect = AsyncMock()
|
||||
mock_aircon.disconnect = AsyncMock()
|
||||
mock_aircon.get_online.return_value = True
|
||||
mock_aircon.get_power_on.return_value = True
|
||||
mock_aircon.get_mode.return_value = whirlpool.aircon.Mode.Cool
|
||||
|
@ -51,15 +51,13 @@ from . import init_integration
|
||||
async def update_ac_state(
|
||||
hass: HomeAssistant,
|
||||
entity_id: str,
|
||||
mock_aircon_api_instances: MagicMock,
|
||||
mock_instance_idx: int,
|
||||
mock_aircon_api_instance: MagicMock,
|
||||
):
|
||||
"""Simulate an update trigger from the API."""
|
||||
update_ha_state_cb = mock_aircon_api_instances.call_args_list[
|
||||
mock_instance_idx
|
||||
].args[3]
|
||||
update_ha_state_cb()
|
||||
await hass.async_block_till_done()
|
||||
for call in mock_aircon_api_instance.register_attr_callback.call_args_list:
|
||||
update_ha_state_cb = call[0][0]
|
||||
update_ha_state_cb()
|
||||
await hass.async_block_till_done()
|
||||
return hass.states.get(entity_id)
|
||||
|
||||
|
||||
@ -72,7 +70,11 @@ async def test_no_appliances(
|
||||
assert len(hass.states.async_all()) == 0
|
||||
|
||||
|
||||
async def test_static_attributes(hass: HomeAssistant, mock_aircon1_api: MagicMock):
|
||||
async def test_static_attributes(
|
||||
hass: HomeAssistant,
|
||||
mock_aircon1_api: MagicMock,
|
||||
mock_aircon_api_instances: MagicMock,
|
||||
):
|
||||
"""Test static climate attributes."""
|
||||
await init_integration(hass)
|
||||
|
||||
@ -137,81 +139,56 @@ async def test_dynamic_attributes(
|
||||
):
|
||||
entity_id = clim_test_instance.entity_id
|
||||
mock_instance = clim_test_instance.mock_instance
|
||||
mock_instance_idx = clim_test_instance.mock_instance_idx
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == HVACMode.COOL
|
||||
|
||||
mock_instance.get_power_on.return_value = False
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.state == HVACMode.OFF
|
||||
|
||||
mock_instance.get_online.return_value = False
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
mock_instance.get_power_on.return_value = True
|
||||
mock_instance.get_online.return_value = True
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.state == HVACMode.COOL
|
||||
|
||||
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Heat
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.state == HVACMode.HEAT
|
||||
|
||||
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Fan
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.state == HVACMode.FAN_ONLY
|
||||
|
||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Auto
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.attributes[ATTR_FAN_MODE] == HVACMode.AUTO
|
||||
|
||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Low
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.attributes[ATTR_FAN_MODE] == FAN_LOW
|
||||
|
||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Medium
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.attributes[ATTR_FAN_MODE] == FAN_MEDIUM
|
||||
|
||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.High
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.attributes[ATTR_FAN_MODE] == FAN_HIGH
|
||||
|
||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Off
|
||||
state = await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||
assert state.attributes[ATTR_FAN_MODE] == FAN_OFF
|
||||
|
||||
mock_instance.get_current_temp.return_value = 15
|
||||
mock_instance.get_temp.return_value = 20
|
||||
mock_instance.get_current_humidity.return_value = 80
|
||||
mock_instance.get_h_louver_swing.return_value = True
|
||||
attributes = (
|
||||
await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
).attributes
|
||||
attributes = (await update_ac_state(hass, entity_id, mock_instance)).attributes
|
||||
assert attributes[ATTR_CURRENT_TEMPERATURE] == 15
|
||||
assert attributes[ATTR_TEMPERATURE] == 20
|
||||
assert attributes[ATTR_CURRENT_HUMIDITY] == 80
|
||||
@ -221,11 +198,7 @@ async def test_dynamic_attributes(
|
||||
mock_instance.get_temp.return_value = 21
|
||||
mock_instance.get_current_humidity.return_value = 70
|
||||
mock_instance.get_h_louver_swing.return_value = False
|
||||
attributes = (
|
||||
await update_ac_state(
|
||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
||||
)
|
||||
).attributes
|
||||
attributes = (await update_ac_state(hass, entity_id, mock_instance)).attributes
|
||||
assert attributes[ATTR_CURRENT_TEMPERATURE] == 16
|
||||
assert attributes[ATTR_TEMPERATURE] == 21
|
||||
assert attributes[ATTR_CURRENT_HUMIDITY] == 70
|
||||
@ -233,7 +206,10 @@ async def test_dynamic_attributes(
|
||||
|
||||
|
||||
async def test_service_calls(
|
||||
hass: HomeAssistant, mock_aircon1_api: MagicMock, mock_aircon2_api: MagicMock
|
||||
hass: HomeAssistant,
|
||||
mock_aircon_api_instances: MagicMock,
|
||||
mock_aircon1_api: MagicMock,
|
||||
mock_aircon2_api: MagicMock,
|
||||
):
|
||||
"""Test controlling the entity through service calls."""
|
||||
await init_integration(hass)
|
||||
|
Loading…
x
Reference in New Issue
Block a user