Skip to content

Commit

Permalink
V0.2.7 (#21)
Browse files Browse the repository at this point in the history
* Fix connection for HUB version 4.15.250

Fix for HUB version 4.15.250; aioharmony will not work with lower versions.

* Use XMPP instead of web sockets

Use XMPP instead of web sockets

* Workaround for xmpp issue in Home Assistant

* Removed wait, does not work

* Add identifier to logger entries in responsehandler

Added identifier for which HUB any log messages are produced from responsehandler, making it easier to determine the HUB it is for.

* Add slixmpp in setup.py required list

Added slixmpp in setup.py for required package.

* Update version as beta right now

* Added release notes

Added release notes

* Potential fix for Host unreachable issues

* Update __version__.py

* Update to wait times on reconnect

* Merge for web socket reconnect fix

Merge for potential web socket reconnect fix

* Flake8

* Beta version update

* Further websocket fixes

* Changed timeout

Changed timeout from 30 seconds to 5 seconds
Sleep for 1 second before trying reconnects.

* Fixed debug logging issue on reconnects

* Update to beta version 8 after merge

* Fixes after merge

* Enable cleanup after closing websocket

* Set version to 0.2.0

* Add instructions for enabling XMPP

* Fix for sending command over XMPP

Sending a command to a device over XMPP was not working anymore.
Fixed.

* Merge fix from 0.1.13

Fix for sockets not being closed on some OS's.

* Fix listen parameter

Fix using --listen parameter

* Add closing code to debug for web socket

* Update slixmpp to 1.5.2

* Addd handlers for starting, stopping, and in progress

Add handlers for starting, stopping, and in progress of activity switches

* Improvement to cancel tasks

* Protocol as choice

Protocol can now be provided for connecting to the HUB. If not provided default behavior occurs.

* Check XMPP is available

Will check if XMPP is available even when provided as protocol. If it is not then default back to WEBSOCKETS.

* logmodules and stop handler fix

Added option logmodules to aioharmony.
Fix upon disconnect timeout so stop handlers is still called.

* Add some timestamps and small fix

Add timestamps for printing activities and responses.
Fix for when not providing parameter logmodules.

* Fixes for XMPP reconnection

Some fixes to reset super XMPP class upon reconnect.

* Added 2 debug lines

* Fix connection refused

* 0.2.6

* Removed timeout for get_current_activity in refresh_info_from_hub as get_current_activity already takes care of this.
Cleaned up small piece of coding

* Unregister handler in send_to_hub upon timeout.

* Unregister handler in send_to_hub upon timeout.

* Update slixmpp and aiohttp

* Fix connection for HUB version 4.15.250

Fix for HUB version 4.15.250; aioharmony will not work with lower versions.

* Use XMPP instead of web sockets

Use XMPP instead of web sockets

* Workaround for xmpp issue in Home Assistant

* Removed wait, does not work

* Add identifier to logger entries in responsehandler

Added identifier for which HUB any log messages are produced from responsehandler, making it easier to determine the HUB it is for.

* Update version as beta right now

* Added release notes

Added release notes

* Potential fix for Host unreachable issues

* Update __version__.py

* Update to wait times on reconnect

* Merge for web socket reconnect fix

Merge for potential web socket reconnect fix

* Flake8

* Beta version update

* Further websocket fixes

* Changed timeout

Changed timeout from 30 seconds to 5 seconds
Sleep for 1 second before trying reconnects.

* Fixed debug logging issue on reconnects

* Update to beta version 8 after merge

* Fixes after merge

* Enable cleanup after closing websocket

* Set version to 0.2.0

* Add instructions for enabling XMPP

* Fix for sending command over XMPP

Sending a command to a device over XMPP was not working anymore.
Fixed.

* Merge fix from 0.1.13

Fix for sockets not being closed on some OS's.

* Fix listen parameter

Fix using --listen parameter

* Add closing code to debug for web socket

* Update slixmpp to 1.5.2

* Addd handlers for starting, stopping, and in progress

Add handlers for starting, stopping, and in progress of activity switches

* Improvement to cancel tasks

* Protocol as choice

Protocol can now be provided for connecting to the HUB. If not provided default behavior occurs.

* Check XMPP is available

Will check if XMPP is available even when provided as protocol. If it is not then default back to WEBSOCKETS.

* logmodules and stop handler fix

Added option logmodules to aioharmony.
Fix upon disconnect timeout so stop handlers is still called.

* Add some timestamps and small fix

Add timestamps for printing activities and responses.
Fix for when not providing parameter logmodules.

* Fixes for XMPP reconnection

Some fixes to reset super XMPP class upon reconnect.

* Added 2 debug lines

* Fix connection refused

* 0.2.6

* Removed timeout for get_current_activity in refresh_info_from_hub as get_current_activity already takes care of this.
Cleaned up small piece of coding

* Unregister handler in send_to_hub upon timeout.

* Unregister handler in send_to_hub upon timeout.

* Update slixmpp and aiohttp

* Fix readme

Co-authored-by: Erik Hendrix <[email protected]>
  • Loading branch information
ehendrix23 and Erik Hendrix authored Feb 5, 2021
1 parent 9b322a0 commit bc03061
Showing 7 changed files with 58 additions and 23 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -91,6 +91,7 @@ Usage
infinite, otherwise has to be a positive number.
(default: 0)
Release Notes
-------------

@@ -171,6 +172,10 @@ Release Notes
0.2.6
- Changed: If XMPP not enabled and no protocol provided then message will be DEBUG instead of Warning to enable XMPP.
- Fixed: If connect using XMPP fails with for example Connection Refused then it will be logged now and connection marked as failed for reconnection.
0.2.7
- Fixed: Registered handlers would not be unregistered after a timeout when sending commands to HUB.
- Updated slixmpp from >= 1.5.2 to >= 1.7.0
- Updated aiohttp from >= 3.4 to 3.7.3


TODO
2 changes: 1 addition & 1 deletion aioharmony/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.2.6'
__version__ = '0.2.7'
36 changes: 36 additions & 0 deletions aioharmony/handler.py
Original file line number Diff line number Diff line change
@@ -218,6 +218,42 @@ def dummy_callback(message):
once=False
)

HANDLER_START_ACTIVITY_NOTIFY_STARTED = Handler(
handler_obj=dummy_callback,
handler_name='Activity_Starting',
resp_json={
'type': re.compile(r'^connect\.stateDigest\?notify$'),
'data': {
'activityStatus': 1,
},
},
once=False
)

HANDLER_STOP_ACTIVITY_NOTIFY_STARTED = Handler(
handler_obj=dummy_callback,
handler_name='Activity_Stopping',
resp_json={
'type': re.compile(r'^connect\.stateDigest\?notify$'),
'data': {
'activityStatus': 0,
},
},
once=False
)

HANDLER_START_ACTIVITY_NOTIFY_INPROGRESS = Handler(
handler_obj=dummy_callback,
handler_name='Activity_Starting_Inprogress',
resp_json={
'type': re.compile(r'^connect\.stateDigest\?notify$'),
'data': {
'activityStatus': 2,
},
},
once=False
)

HANDLER_START_ACTIVITY_FINISHED = Handler(
handler_obj=dummy_callback,
handler_name='Activity_Changed',
26 changes: 12 additions & 14 deletions aioharmony/harmonyclient.py
Original file line number Diff line number Diff line change
@@ -323,15 +323,8 @@ async def refresh_info_from_hub(self) -> None:
elif isinstance(result, Exception):
# Other exception, raise it.
raise result
try:
# Retrieve current activity, done only once config received.
with timeout(DEFAULT_TIMEOUT):
await self._get_current_activity()
except asyncio.TimeoutError:
_LOGGER.error("%s: Timeout trying to retrieve current "
"activity.",
self.name)
return

await self._get_current_activity()

# If we were provided a callback handler then call it now.
if self._callbacks.config_updated:
@@ -487,6 +480,7 @@ async def send_to_hub(self,
}

response = None
handler_uuid = None
if wait:
response = self._loop.create_future()
resp_handler = Handler(handler_obj=response,
@@ -495,9 +489,8 @@ async def send_to_hub(self,
expiration=timedelta(
seconds=DEFAULT_TIMEOUT)
)
self.register_handler(handler=resp_handler,
msgid=msgid)

handler_uuid = self.register_handler(handler=resp_handler,
msgid=msgid)
try:
with timeout(send_timeout):
send_response = await self._hub_connection.hub_send(
@@ -511,8 +504,12 @@ async def send_to_hub(self,
)
if send_response is None:
# There was an issue
if handler_uuid is not None:
self.unregister_handler(handler_uuid=handler_uuid)
return False
except asyncio.TimeoutError:
if handler_uuid is not None:
self.unregister_handler(handler_uuid=handler_uuid)
raise aioexc.TimeOut

if asyncio.isfuture(send_response):
@@ -525,6 +522,8 @@ async def send_to_hub(self,
with timeout(send_timeout):
await response
except asyncio.TimeoutError:
if handler_uuid is not None:
self.unregister_handler(handler_uuid=handler_uuid)
raise aioexc.TimeOut

return response.result()
@@ -534,7 +533,6 @@ async def _get_current_activity(self) -> bool:
_LOGGER.debug("%s: Retrieving current activity", self.name)

# Send the command to the HUB

try:
with timeout(DEFAULT_TIMEOUT/2):
response = await self.send_to_hub(command='get_current_activity', send_timeout=DEFAULT_TIMEOUT/4)
@@ -545,7 +543,7 @@ async def _get_current_activity(self) -> bool:
with timeout(DEFAULT_TIMEOUT/2):
response = await self.send_to_hub(command='get_current_activity', send_timeout=DEFAULT_TIMEOUT/4)
except (asyncio.TimeoutError, aioexc.TimeOut):
_LOGGER.error("%s: Timeout trying to retrieve current activity.",
_LOGGER.error("%s: Second Timeout trying to retrieve current activity.",
self.name)
response = None

5 changes: 1 addition & 4 deletions aioharmony/helpers.py
Original file line number Diff line number Diff line change
@@ -75,7 +75,6 @@ def call_raw_callback(callback: CallbackType,
:return: True if callback was done successfully, False if it wasn't
:rtype: bool
"""
called_callback = False
if asyncio.isfuture(callback):
# It is a future, set the result of the future to
# the message.
@@ -84,15 +83,13 @@ def call_raw_callback(callback: CallbackType,
"set",
callback_name,
callback_uuid)

else:
_LOGGER.debug("Future %s with UUID %s is set",
callback_name,
callback_uuid)
callback.set_result(result)
called_callback = True

return called_callback
return True

if isinstance(callback, asyncio.Event):
# It is an event, set the event.
3 changes: 1 addition & 2 deletions aioharmony/hubconnector_xmpp.py
Original file line number Diff line number Diff line change
@@ -238,6 +238,7 @@ def disconnect_result(_):
disconnected.set_result(True)

self._deregister_handlers()

self.add_event_handler('disconnected',
disconnect_result,
disposable=True,
@@ -406,8 +407,6 @@ def message_received(event):

self._listener_message_received = message_received

self._listener_message_received = message_received

# Register our callback.
self.register_handler(
Callback('Listener',
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
slixmpp>=1.5.2
slixmpp>=1.7.0
async_timeout>=3.0.1
aiohttp>=3.4
aiohttp>=3.7.3

0 comments on commit bc03061

Please sign in to comment.