Skip to content

Commit

Permalink
style: auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 29, 2024
1 parent d42a507 commit 477caeb
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ repos:
- hooks:
- id: black
repo: https://github.com/psf/black
rev: 24.4.2
rev: 23.11.0
- repo: https://github.com/pre-commit/mirrors-prettier
hooks:
- id: prettier
exclude: ^custom_components/alexa_media/translations|CHANGELOG.md
rev: v4.0.0-alpha.8
- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py39-plus]
Expand Down
46 changes: 24 additions & 22 deletions custom_components/alexa_media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,9 +1125,9 @@ async def http2_handler(message_obj):
)
):
_LOGGER.debug("Discovered new media_player %s", hide_serial(serial))
(
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["new_devices"]
) = True
(hass.data[DATA_ALEXAMEDIA]["accounts"][email]["new_devices"]) = (
True
)
coordinator = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get(
"coordinator"
)
Expand Down Expand Up @@ -1182,9 +1182,9 @@ async def http2_close_handler():
hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"http2_lastattempt"
] = time.time()
http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"http2"
] = await http2_connect()
http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2"] = (
await http2_connect()
)
errors = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2error"] = (
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2error"] + 1
)
Expand Down Expand Up @@ -1243,24 +1243,24 @@ async def http2_error_handler(message):
else config.get(CONF_SCAN_INTERVAL)
)
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["login_obj"] = login_obj
http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"http2"
] = await http2_connect()
http2_enabled = hass.data[DATA_ALEXAMEDIA]["accounts"][email]["http2"] = (
await http2_connect()
)
coordinator = hass.data[DATA_ALEXAMEDIA]["accounts"][email].get("coordinator")
if coordinator is None:
_LOGGER.debug("%s: Creating coordinator", hide_email(email))
hass.data[DATA_ALEXAMEDIA]["accounts"][email][
"coordinator"
] = coordinator = DataUpdateCoordinator(
hass,
_LOGGER,
# Name of the data. For logging purposes.
name="alexa_media",
update_method=async_update_data,
# Polling interval. Will only be polled if there are subscribers.
update_interval=timedelta(
seconds=scan_interval * 10 if http2_enabled else scan_interval
),
hass.data[DATA_ALEXAMEDIA]["accounts"][email]["coordinator"] = coordinator = (
DataUpdateCoordinator(
hass,
_LOGGER,
# Name of the data. For logging purposes.
name="alexa_media",
update_method=async_update_data,
# Polling interval. Will only be polled if there are subscribers.
update_interval=timedelta(
seconds=scan_interval * 10 if http2_enabled else scan_interval
),
)
)
else:
_LOGGER.debug("%s: Reusing coordinator", hide_email(email))
Expand Down Expand Up @@ -1382,7 +1382,9 @@ async def test_login_status(hass, config_entry, login) -> bool:
account = config_entry.data
_LOGGER.debug("Logging in: %s %s", obfuscate(account), in_progess_instances(hass))
_LOGGER.debug("Login stats: %s", login.stats)
message: str = f"Reauthenticate {login.email} on the [Integrations](/config/integrations) page. "
message: str = (
f"Reauthenticate {login.email} on the [Integrations](/config/integrations) page. "
)
if login.stats.get("login_timestamp") != datetime(1, 1, 1):
elaspsed_time: str = str(datetime.now() - login.stats.get("login_timestamp"))
api_calls: int = login.stats.get("api_calls")
Expand Down
18 changes: 9 additions & 9 deletions custom_components/alexa_media/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ def __init__(self, coordinator, entity_id, name, media_player_device_id):
self._attr_name = name + " Temperature"
self._attr_device_class = SensorDeviceClass.TEMPERATURE
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_native_value: Optional[
datetime.datetime
] = parse_temperature_from_coordinator(coordinator, entity_id)
self._attr_native_value: Optional[datetime.datetime] = (
parse_temperature_from_coordinator(coordinator, entity_id)
)
self._attr_native_unit_of_measurement: Optional[str] = UnitOfTemperature.CELSIUS
# This includes "_temperature" because the Alexa entityId is for a physical device
# A single physical device could have multiple HA entities
Expand Down Expand Up @@ -306,12 +306,12 @@ def __init__(
self._attr_name = name + " " + self._sensor_name
self._attr_device_class = self._sensor_name
self._attr_state_class = SensorStateClass.MEASUREMENT
self._attr_native_value: Optional[
datetime.datetime
] = parse_air_quality_from_coordinator(coordinator, entity_id, instance)
self._attr_native_unit_of_measurement: Optional[
str
] = ALEXA_UNIT_CONVERSION.get(unit)
self._attr_native_value: Optional[datetime.datetime] = (
parse_air_quality_from_coordinator(coordinator, entity_id, instance)
)
self._attr_native_unit_of_measurement: Optional[str] = (
ALEXA_UNIT_CONVERSION.get(unit)
)
self._attr_unique_id = entity_id + " " + self._sensor_name
self._attr_icon = ALEXA_ICON_CONVERSION.get(sensor_name, ALEXA_ICON_DEFAULT)
self._attr_device_info = (
Expand Down

0 comments on commit 477caeb

Please sign in to comment.