Bump aiolookin to 1.0.0 (#83198)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
88c8eef4eb
commit
ec24b93c17
8 changed files with 69 additions and 31 deletions
|
@ -101,16 +101,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
push_coordinator = LookinPushCoordinator(entry.title)
|
||||
|
||||
meteo_coordinator: LookinDataUpdateCoordinator = LookinDataUpdateCoordinator(
|
||||
hass,
|
||||
push_coordinator,
|
||||
name=entry.title,
|
||||
update_method=lookin_protocol.get_meteo_sensor,
|
||||
update_interval=timedelta(
|
||||
minutes=5
|
||||
), # Updates are pushed (fallback is polling)
|
||||
)
|
||||
await meteo_coordinator.async_config_entry_first_refresh()
|
||||
if lookin_device.model >= 2:
|
||||
meteo_coordinator: LookinDataUpdateCoordinator = LookinDataUpdateCoordinator(
|
||||
hass,
|
||||
push_coordinator,
|
||||
name=entry.title,
|
||||
update_method=lookin_protocol.get_meteo_sensor,
|
||||
update_interval=timedelta(
|
||||
minutes=5
|
||||
), # Updates are pushed (fallback is polling)
|
||||
)
|
||||
await meteo_coordinator.async_config_entry_first_refresh()
|
||||
|
||||
device_coordinators: dict[str, LookinDataUpdateCoordinator] = {}
|
||||
for remote in devices:
|
||||
|
@ -148,17 +149,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
lookin_udp_subs = await manager.async_get_subscriptions()
|
||||
|
||||
entry.async_on_unload(
|
||||
lookin_udp_subs.subscribe_event(
|
||||
lookin_device.id, UDPCommandType.meteo, None, _async_meteo_push_update
|
||||
if lookin_device.model >= 2:
|
||||
entry.async_on_unload(
|
||||
lookin_udp_subs.subscribe_event(
|
||||
lookin_device.id, UDPCommandType.meteo, None, _async_meteo_push_update
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
hass.data[DOMAIN][entry.entry_id] = LookinData(
|
||||
host=host,
|
||||
lookin_udp_subs=lookin_udp_subs,
|
||||
lookin_device=lookin_device,
|
||||
meteo_coordinator=meteo_coordinator,
|
||||
meteo_coordinator=meteo_coordinator if lookin_device.model >= 2 else None,
|
||||
devices=devices,
|
||||
lookin_protocol=lookin_protocol,
|
||||
device_coordinators=device_coordinators,
|
||||
|
|
|
@ -146,13 +146,18 @@ class ConditionerEntity(LookinCoordinatorEntity, ClimateEntity):
|
|||
# or cool otherwise we set auto since we don't have a way to make
|
||||
# an educated guess.
|
||||
#
|
||||
meteo_data: MeteoSensor = self._meteo_coordinator.data
|
||||
if not (current_temp := meteo_data.temperature):
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.AUTO)
|
||||
elif current_temp >= self._climate.temp_celsius:
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.COOL)
|
||||
|
||||
if self._meteo_coordinator:
|
||||
meteo_data: MeteoSensor = self._meteo_coordinator.data
|
||||
if not (current_temp := meteo_data.temperature):
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.AUTO)
|
||||
elif current_temp >= self._climate.temp_celsius:
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.COOL)
|
||||
else:
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.HEAT)
|
||||
else:
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.HEAT)
|
||||
self._climate.hvac_mode = lookin_index.index(HVACMode.AUTO)
|
||||
|
||||
await self._async_update_conditioner()
|
||||
|
||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||
|
@ -172,14 +177,20 @@ class ConditionerEntity(LookinCoordinatorEntity, ClimateEntity):
|
|||
async def _async_update_conditioner(self) -> None:
|
||||
"""Update the conditioner state from the climate data."""
|
||||
self.coordinator.async_set_updated_data(self._climate)
|
||||
await self._lookin_protocol.update_conditioner(climate=self._climate)
|
||||
await self._lookin_protocol.update_conditioner(
|
||||
uuid=self._attr_unique_id, status=self._climate.to_status
|
||||
)
|
||||
|
||||
def _async_update_from_data(self) -> None:
|
||||
"""Update attrs from data."""
|
||||
meteo_data: MeteoSensor = self._meteo_coordinator.data
|
||||
if self._meteo_coordinator:
|
||||
temperature = self._meteo_coordinator.data.temperature
|
||||
humidity = int(self._meteo_coordinator.data.humidity)
|
||||
else:
|
||||
temperature = humidity = None
|
||||
|
||||
self._attr_current_temperature = meteo_data.temperature
|
||||
self._attr_current_humidity = int(meteo_data.humidity)
|
||||
self._attr_current_temperature = temperature
|
||||
self._attr_current_humidity = humidity
|
||||
self._attr_target_temperature = self._climate.temp_celsius
|
||||
self._attr_fan_mode = LOOKIN_FAN_MODE_IDX_TO_HASS[self._climate.fan_mode]
|
||||
self._attr_swing_mode = LOOKIN_SWING_MODE_IDX_TO_HASS[self._climate.swing_mode]
|
||||
|
|
|
@ -61,6 +61,7 @@ class LookinDeviceCoordinatorEntity(
|
|||
|
||||
def __init__(self, lookin_data: LookinData) -> None:
|
||||
"""Init the lookin device entity."""
|
||||
assert lookin_data.meteo_coordinator is not None
|
||||
super().__init__(lookin_data.meteo_coordinator)
|
||||
self._set_lookin_device_attrs(lookin_data)
|
||||
self._attr_device_info = _lookin_device_to_device_info(
|
||||
|
@ -109,10 +110,10 @@ class LookinCoordinatorEntity(
|
|||
self._attr_unique_id = uuid
|
||||
self._attr_name = device.name
|
||||
|
||||
async def _async_send_command(self, command: str) -> None:
|
||||
async def _async_send_command(self, command: str, signal: str = "FF") -> None:
|
||||
"""Send command from saved IR device."""
|
||||
await self._lookin_protocol.send_command(
|
||||
uuid=self._uuid, command=command, signal="FF"
|
||||
uuid=self._uuid, command=command, signal=signal
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "LOOKin",
|
||||
"documentation": "https://www.home-assistant.io/integrations/lookin/",
|
||||
"codeowners": ["@ANMalko", "@bdraco"],
|
||||
"requirements": ["aiolookin==0.1.1"],
|
||||
"requirements": ["aiolookin==1.0.0"],
|
||||
"zeroconf": ["_lookin._tcp.local."],
|
||||
"config_flow": true,
|
||||
"iot_class": "local_push",
|
||||
|
|
|
@ -36,6 +36,7 @@ _FUNCTION_NAME_TO_FEATURE = {
|
|||
"volup": MediaPlayerEntityFeature.VOLUME_STEP,
|
||||
"chup": MediaPlayerEntityFeature.NEXT_TRACK,
|
||||
"chdown": MediaPlayerEntityFeature.PREVIOUS_TRACK,
|
||||
"mode": MediaPlayerEntityFeature.SELECT_SOURCE,
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,6 +87,29 @@ class LookinMedia(LookinPowerPushRemoteEntity, MediaPlayerEntity):
|
|||
for function_name, feature in _FUNCTION_NAME_TO_FEATURE.items():
|
||||
if function_name in self._function_names:
|
||||
self._attr_supported_features |= feature
|
||||
self._source_list: dict[str, str] | None = None
|
||||
|
||||
@property
|
||||
def source_list(self) -> list[str]:
|
||||
"""List of available input sources."""
|
||||
return list(self._source_list.keys()) if self._source_list else []
|
||||
|
||||
async def async_select_source(self, source: str) -> None:
|
||||
"""Choose an available playlist and play it."""
|
||||
if not self._source_list:
|
||||
return
|
||||
await self._async_send_command(command="mode", signal=self._source_list[source])
|
||||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Get list of available input sources."""
|
||||
if self._source_list is None and "mode" in self._function_names:
|
||||
if sources := await self._lookin_protocol.get_media_sources(
|
||||
uuid=self._uuid
|
||||
):
|
||||
self._source_list = {
|
||||
f"INPUT_{index}": f"{index:02x}" for index in range(len(sources))
|
||||
}
|
||||
await super().async_added_to_hass()
|
||||
|
||||
async def async_volume_up(self) -> None:
|
||||
"""Turn volume up for media player."""
|
||||
|
|
|
@ -16,7 +16,7 @@ class LookinData:
|
|||
host: str
|
||||
lookin_udp_subs: LookinUDPSubscriptions
|
||||
lookin_device: Device
|
||||
meteo_coordinator: LookinDataUpdateCoordinator
|
||||
meteo_coordinator: LookinDataUpdateCoordinator | None
|
||||
devices: list[dict[str, Any]]
|
||||
lookin_protocol: LookInHttpProtocol
|
||||
device_coordinators: dict[str, LookinDataUpdateCoordinator]
|
||||
|
|
|
@ -205,7 +205,7 @@ aiolifx_themes==0.2.0
|
|||
aiolivisi==0.0.14
|
||||
|
||||
# homeassistant.components.lookin
|
||||
aiolookin==0.1.1
|
||||
aiolookin==1.0.0
|
||||
|
||||
# homeassistant.components.lyric
|
||||
aiolyric==1.0.9
|
||||
|
|
|
@ -183,7 +183,7 @@ aiolifx_themes==0.2.0
|
|||
aiolivisi==0.0.14
|
||||
|
||||
# homeassistant.components.lookin
|
||||
aiolookin==0.1.1
|
||||
aiolookin==1.0.0
|
||||
|
||||
# homeassistant.components.lyric
|
||||
aiolyric==1.0.9
|
||||
|
|
Loading…
Add table
Reference in a new issue