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
6 changed files with 36 additions and 55 deletions
|
@ -107,8 +107,8 @@ class AirConEntity(ClimateEntity):
|
||||||
|
|
||||||
def __init__(self, hass, said, name, backend_selector: BackendSelector, auth: Auth):
|
def __init__(self, hass, said, name, backend_selector: BackendSelector, auth: Auth):
|
||||||
"""Initialize the entity."""
|
"""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.entity_id = generate_entity_id(ENTITY_ID_FORMAT, said, hass=hass)
|
||||||
self._attr_name = name if name is not None else said
|
self._attr_name = name if name is not None else said
|
||||||
self._attr_unique_id = said
|
self._attr_unique_id = said
|
||||||
|
@ -117,6 +117,10 @@ class AirConEntity(ClimateEntity):
|
||||||
"""Connect aircon to the cloud."""
|
"""Connect aircon to the cloud."""
|
||||||
await self._aircon.connect()
|
await self._aircon.connect()
|
||||||
|
|
||||||
|
async def async_will_remove_from_hass(self) -> None:
|
||||||
|
"""Close Whrilpool Appliance sockets before removing."""
|
||||||
|
await self._aircon.disconnect()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return True if entity is available."""
|
"""Return True if entity is available."""
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"name": "Whirlpool Sixth Sense",
|
"name": "Whirlpool Sixth Sense",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/whirlpool",
|
"documentation": "https://www.home-assistant.io/integrations/whirlpool",
|
||||||
"requirements": ["whirlpool-sixth-sense==0.17.1"],
|
"requirements": ["whirlpool-sixth-sense==0.18.0"],
|
||||||
"codeowners": ["@abmantis"],
|
"codeowners": ["@abmantis"],
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"loggers": ["whirlpool"]
|
"loggers": ["whirlpool"]
|
||||||
|
|
|
@ -2570,7 +2570,7 @@ waterfurnace==1.1.0
|
||||||
webexteamssdk==1.1.1
|
webexteamssdk==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.whirlpool
|
# homeassistant.components.whirlpool
|
||||||
whirlpool-sixth-sense==0.17.1
|
whirlpool-sixth-sense==0.18.0
|
||||||
|
|
||||||
# homeassistant.components.whois
|
# homeassistant.components.whois
|
||||||
whois==0.9.16
|
whois==0.9.16
|
||||||
|
|
|
@ -1795,7 +1795,7 @@ wallbox==0.4.12
|
||||||
watchdog==2.2.0
|
watchdog==2.2.0
|
||||||
|
|
||||||
# homeassistant.components.whirlpool
|
# homeassistant.components.whirlpool
|
||||||
whirlpool-sixth-sense==0.17.1
|
whirlpool-sixth-sense==0.18.0
|
||||||
|
|
||||||
# homeassistant.components.whois
|
# homeassistant.components.whois
|
||||||
whois==0.9.16
|
whois==0.9.16
|
||||||
|
|
|
@ -56,6 +56,7 @@ def get_aircon_mock(said):
|
||||||
"""Get a mock of an air conditioner."""
|
"""Get a mock of an air conditioner."""
|
||||||
mock_aircon = mock.Mock(said=said)
|
mock_aircon = mock.Mock(said=said)
|
||||||
mock_aircon.connect = AsyncMock()
|
mock_aircon.connect = AsyncMock()
|
||||||
|
mock_aircon.disconnect = AsyncMock()
|
||||||
mock_aircon.get_online.return_value = True
|
mock_aircon.get_online.return_value = True
|
||||||
mock_aircon.get_power_on.return_value = True
|
mock_aircon.get_power_on.return_value = True
|
||||||
mock_aircon.get_mode.return_value = whirlpool.aircon.Mode.Cool
|
mock_aircon.get_mode.return_value = whirlpool.aircon.Mode.Cool
|
||||||
|
|
|
@ -51,15 +51,13 @@ from . import init_integration
|
||||||
async def update_ac_state(
|
async def update_ac_state(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
entity_id: str,
|
entity_id: str,
|
||||||
mock_aircon_api_instances: MagicMock,
|
mock_aircon_api_instance: MagicMock,
|
||||||
mock_instance_idx: int,
|
|
||||||
):
|
):
|
||||||
"""Simulate an update trigger from the API."""
|
"""Simulate an update trigger from the API."""
|
||||||
update_ha_state_cb = mock_aircon_api_instances.call_args_list[
|
for call in mock_aircon_api_instance.register_attr_callback.call_args_list:
|
||||||
mock_instance_idx
|
update_ha_state_cb = call[0][0]
|
||||||
].args[3]
|
update_ha_state_cb()
|
||||||
update_ha_state_cb()
|
await hass.async_block_till_done()
|
||||||
await hass.async_block_till_done()
|
|
||||||
return hass.states.get(entity_id)
|
return hass.states.get(entity_id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,7 +70,11 @@ async def test_no_appliances(
|
||||||
assert len(hass.states.async_all()) == 0
|
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."""
|
"""Test static climate attributes."""
|
||||||
await init_integration(hass)
|
await init_integration(hass)
|
||||||
|
|
||||||
|
@ -137,81 +139,56 @@ async def test_dynamic_attributes(
|
||||||
):
|
):
|
||||||
entity_id = clim_test_instance.entity_id
|
entity_id = clim_test_instance.entity_id
|
||||||
mock_instance = clim_test_instance.mock_instance
|
mock_instance = clim_test_instance.mock_instance
|
||||||
mock_instance_idx = clim_test_instance.mock_instance_idx
|
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == HVACMode.COOL
|
assert state.state == HVACMode.COOL
|
||||||
|
|
||||||
mock_instance.get_power_on.return_value = False
|
mock_instance.get_power_on.return_value = False
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.state == HVACMode.OFF
|
assert state.state == HVACMode.OFF
|
||||||
|
|
||||||
mock_instance.get_online.return_value = False
|
mock_instance.get_online.return_value = False
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.state == STATE_UNAVAILABLE
|
assert state.state == STATE_UNAVAILABLE
|
||||||
|
|
||||||
mock_instance.get_power_on.return_value = True
|
mock_instance.get_power_on.return_value = True
|
||||||
mock_instance.get_online.return_value = True
|
mock_instance.get_online.return_value = True
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.state == HVACMode.COOL
|
assert state.state == HVACMode.COOL
|
||||||
|
|
||||||
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Heat
|
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Heat
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.state == HVACMode.HEAT
|
assert state.state == HVACMode.HEAT
|
||||||
|
|
||||||
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Fan
|
mock_instance.get_mode.return_value = whirlpool.aircon.Mode.Fan
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.state == HVACMode.FAN_ONLY
|
assert state.state == HVACMode.FAN_ONLY
|
||||||
|
|
||||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Auto
|
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Auto
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.attributes[ATTR_FAN_MODE] == HVACMode.AUTO
|
assert state.attributes[ATTR_FAN_MODE] == HVACMode.AUTO
|
||||||
|
|
||||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Low
|
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Low
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.attributes[ATTR_FAN_MODE] == FAN_LOW
|
assert state.attributes[ATTR_FAN_MODE] == FAN_LOW
|
||||||
|
|
||||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Medium
|
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Medium
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.attributes[ATTR_FAN_MODE] == FAN_MEDIUM
|
assert state.attributes[ATTR_FAN_MODE] == FAN_MEDIUM
|
||||||
|
|
||||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.High
|
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.High
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.attributes[ATTR_FAN_MODE] == FAN_HIGH
|
assert state.attributes[ATTR_FAN_MODE] == FAN_HIGH
|
||||||
|
|
||||||
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Off
|
mock_instance.get_fanspeed.return_value = whirlpool.aircon.FanSpeed.Off
|
||||||
state = await update_ac_state(
|
state = await update_ac_state(hass, entity_id, mock_instance)
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
assert state.attributes[ATTR_FAN_MODE] == FAN_OFF
|
assert state.attributes[ATTR_FAN_MODE] == FAN_OFF
|
||||||
|
|
||||||
mock_instance.get_current_temp.return_value = 15
|
mock_instance.get_current_temp.return_value = 15
|
||||||
mock_instance.get_temp.return_value = 20
|
mock_instance.get_temp.return_value = 20
|
||||||
mock_instance.get_current_humidity.return_value = 80
|
mock_instance.get_current_humidity.return_value = 80
|
||||||
mock_instance.get_h_louver_swing.return_value = True
|
mock_instance.get_h_louver_swing.return_value = True
|
||||||
attributes = (
|
attributes = (await update_ac_state(hass, entity_id, mock_instance)).attributes
|
||||||
await update_ac_state(
|
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
).attributes
|
|
||||||
assert attributes[ATTR_CURRENT_TEMPERATURE] == 15
|
assert attributes[ATTR_CURRENT_TEMPERATURE] == 15
|
||||||
assert attributes[ATTR_TEMPERATURE] == 20
|
assert attributes[ATTR_TEMPERATURE] == 20
|
||||||
assert attributes[ATTR_CURRENT_HUMIDITY] == 80
|
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_temp.return_value = 21
|
||||||
mock_instance.get_current_humidity.return_value = 70
|
mock_instance.get_current_humidity.return_value = 70
|
||||||
mock_instance.get_h_louver_swing.return_value = False
|
mock_instance.get_h_louver_swing.return_value = False
|
||||||
attributes = (
|
attributes = (await update_ac_state(hass, entity_id, mock_instance)).attributes
|
||||||
await update_ac_state(
|
|
||||||
hass, entity_id, mock_aircon_api_instances, mock_instance_idx
|
|
||||||
)
|
|
||||||
).attributes
|
|
||||||
assert attributes[ATTR_CURRENT_TEMPERATURE] == 16
|
assert attributes[ATTR_CURRENT_TEMPERATURE] == 16
|
||||||
assert attributes[ATTR_TEMPERATURE] == 21
|
assert attributes[ATTR_TEMPERATURE] == 21
|
||||||
assert attributes[ATTR_CURRENT_HUMIDITY] == 70
|
assert attributes[ATTR_CURRENT_HUMIDITY] == 70
|
||||||
|
@ -233,7 +206,10 @@ async def test_dynamic_attributes(
|
||||||
|
|
||||||
|
|
||||||
async def test_service_calls(
|
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."""
|
"""Test controlling the entity through service calls."""
|
||||||
await init_integration(hass)
|
await init_integration(hass)
|
||||||
|
|
Loading…
Add table
Reference in a new issue