Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #194

Merged
merged 7 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## v1.0.13

- Fix reconnect process
- Fix threadsafe warning log messages
- Fix color more error log messages

## v1.0.13b2

- Remove typo of args in AWS client message handling

## v1.0.13b1

- Remove typo of args in AWS client message handling

## v1.0.13b0

- Add threadsafe handling for set status
- Add safe block for AWS client termination process
- Fix color mode warning on startup

## v1.0.12

- Fix light support modes warning
Expand Down Expand Up @@ -292,7 +312,7 @@ ERROR (MainThread) [custom_components.mydolphin_plus.managers.config_manager] In
## v0.0.8

- Add a list of relevant states that also determine if a robot is not actively cleaning
- Added MyDolpin Plus to the standard HACS repo
- Added MyDolphin Plus to the standard HACS repo

## v0.0.7

Expand Down
1 change: 1 addition & 0 deletions custom_components/mydolphin_plus/common/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,5 @@
API_RESPONSE_DATA_SECRET_ACCESS_KEY,
DYNAMIC_CONTENT_SERIAL_NUMBER,
CONF_USERNAME,
CONF_PASSWORD,
]
3 changes: 2 additions & 1 deletion custom_components/mydolphin_plus/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def __init__(
):
super().__init__(entity_description, coordinator)

self._attr_supported_color_modes = set(ColorMode.ONOFF)
self._attr_supported_color_modes = {ColorMode.ONOFF}
self._attr_color_mode = ColorMode.ONOFF

async def async_turn_on(self, **kwargs: Any) -> None:
await self.async_execute_device_action(ACTION_ENTITY_TURN_ON)
Expand Down
29 changes: 21 additions & 8 deletions custom_components/mydolphin_plus/managers/aws_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from homeassistant.const import CONF_MODE
from homeassistant.core import HomeAssistant
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.dispatcher import dispatcher_send

from ..common.clean_modes import CleanModes
from ..common.connection_callbacks import ConnectionCallbacks
Expand Down Expand Up @@ -148,14 +148,27 @@ def data(self) -> dict:
return self._data

async def terminate(self):
def _on_terminate_future_completed(future):
disconnect_future.result()
try:

self._awsiot_client = None
def _on_terminate_future_completed(future):
future.result()

self._awsiot_client = None

if self._awsiot_client is not None:
disconnect_future = self._awsiot_client.disconnect()
disconnect_future.add_done_callback(_on_terminate_future_completed)
if self._awsiot_client is not None:
disconnect_future = self._awsiot_client.disconnect()
disconnect_future.add_done_callback(_on_terminate_future_completed)

except Exception as ex:
exc_type, exc_obj, tb = sys.exc_info()
line_number = tb.tb_lineno

_LOGGER.warning(
"Failed to gracefully shutdown AWS IOT Client, setting it to None, "
f"Error: {ex}, Line: {line_number}"
)

self._awsiot_client = None

self._set_status(ConnectivityStatus.Disconnected)
_LOGGER.debug("AWS Client is disconnected")
Expand Down Expand Up @@ -642,4 +655,4 @@ def _async_dispatcher_send(self, signal: str, *args: Any) -> None:
self._local_async_dispatcher_send(signal, *args)

else:
async_dispatcher_send(self._hass, signal, *args)
dispatcher_send(self._hass, signal, *args)
4 changes: 1 addition & 3 deletions custom_components/mydolphin_plus/managers/flow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(

async def async_step(self, user_input: dict | None = None):
"""Manage the domain options."""
_LOGGER.info(f"Config flow started, Step: {self._flow_id}, Input: {user_input}")
_LOGGER.info(f"Config flow started, Step: {self._flow_id}")

form_errors = None

Expand All @@ -57,8 +57,6 @@ async def async_step(self, user_input: dict | None = None):
user_input = {key: self._entry.data[key] for key in self._entry.data}
user_input[CONF_TITLE] = self._entry.title

_LOGGER.info(user_input)

await PasswordManager.decrypt(
self._hass, user_input, self._entry.entry_id
)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/mydolphin_plus/managers/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.dispatcher import dispatcher_send

from ..common.connectivity_status import ConnectivityStatus
from ..common.consts import (
Expand Down Expand Up @@ -509,4 +509,4 @@ def _async_dispatcher_send(self, signal: str, *args: Any) -> None:
self._local_async_dispatcher_send(signal, *args)

else:
async_dispatcher_send(self._hass, signal, *args)
dispatcher_send(self._hass, signal, *args)
2 changes: 1 addition & 1 deletion custom_components/mydolphin_plus/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/sh00t2kill/dolphin-robot/issues",
"requirements": ["awsiotsdk"],
"version": "1.0.12"
"version": "1.0.13"
}
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pre-commit
homeassistant~=2024.2.0
aiohttp~=3.9.3
cryptography~=42.0.2
cryptography~=42.0.4
voluptuous~=0.13.1

python-slugify

awsiotsdk~=1.21.0
awscrt~=0.20.2

awsiot~=0.1.3
Loading