Skip to content

Commit

Permalink
fix: bump alexapy to 1.28.2 (#2434)
Browse files Browse the repository at this point in the history
* bump alexapy to 1.28.2

* style: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* style: auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* bump python to 3.11 in devcontainer

* bump python to 3.11 in devcontainer

* bump dockerfile to use python 3.11

* update devcontainer and poetry config

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
chrisvblemos and pre-commit-ci[bot] committed Aug 8, 2024
1 parent 8954511 commit 802c5c6
Show file tree
Hide file tree
Showing 8 changed files with 763 additions and 560 deletions.
11 changes: 8 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/python-3/.devcontainer/base.Dockerfile
# See here for image contents: https://github.com/devcontainers/images/tree/main/src/python

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
ARG VARIANT="3.11-bullseye"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

RUN pipx install poetry
WORKDIR /workspace
COPY pyproject.toml poetry.lock ./
RUN poetry update

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
"VARIANT": "3.11-bullseye",
// Options
"NODE_VERSION": "none"
}
Expand Down
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: 23.11.0
rev: 24.8.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.15.0
rev: v3.17.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 @@ -1136,9 +1136,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
)
if coordinator:
await coordinator.async_request_refresh()

Expand Down Expand Up @@ -1190,9 +1190,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 @@ -1250,24 +1250,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 @@ -1389,7 +1389,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
2 changes: 1 addition & 1 deletion custom_components/alexa_media/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/alandtse/alexa_media_player/issues",
"loggers": ["alexapy", "authcaptureproxy"],
"requirements": ["alexapy==1.27.10", "packaging>=20.3", "wrapt>=1.14.0"],
"requirements": ["alexapy==1.28.2", "packaging>=20.3", "wrapt>=1.14.0"],
"version": "4.12.6"
}
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
Loading

0 comments on commit 802c5c6

Please sign in to comment.