Home Assistant release with the issue:
0.85.0dev0
Last working Home Assistant release (if known):
0..84.3
Operating environment (Hass.io/Docker/Windows/etc.):
venv
Component/platform:
remote.harmony
https://www.home-assistant.io/components/remote.harmony/
Description of problem:
After attempting to start an activity or turning off the remote, the remote fails to update even though the action was performed successfully.
On Services tab remote.turn_on
{
"entity_id": "remote.harmony_hub_bedroom",
"activity": "Bedroom SHIELD TV"
}
Or on the front end if the remote is on
turn it off by toggling it.
Problem-relevant configuration.yaml
entries and (fill out even if it seems unimportant):
remote:
- platform: harmony
name: Harmony Hub Bedroom
host: 192.168.1.21
Traceback (if applicable):
2018-12-19 09:06:33 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub_bedroom fails
Traceback (most recent call last):
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/pi/home-assistant/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 184, in _send_request
return await self._wait_response(msgid)
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 319, in recv
raise ConnectionClosed(self.close_code, self.close_reason)
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006, no reason.
2018-12-19 09:06:38 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub_bedroom fails
Traceback (most recent call last):
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/pi/home-assistant/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 158, in _send_request
await self._perform_connect()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 113, in _perform_connect
if not self._websocket.closed:
AttributeError: 'WebSocketClientProtocol' object has no attribute 'closed'
2018-12-19 09:06:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub_bedroom fails
Traceback (most recent call last):
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/pi/home-assistant/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 158, in _send_request
await self._perform_connect()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 113, in _perform_connect
if not self._websocket.closed:
AttributeError: 'WebSocketClientProtocol' object has no attribute 'closed'
The bottom error continues to repeat itself until HA is restarted, then the correct state is shown until the next action is performed.
Additional information:
CC: @ehendrix23
@dshokouhi
Can you run the following and provide result, wanna check what version of websockets you have installed.
pip show websockets
Thx.
sure thing @ehendrix23 here you go, let me know if you need anything else
(home-assistant) pi@raspberrypi:~/home-assistant $ pip show websockets
Name: websockets
Version: 3.4
Summary: An implementation of the WebSocket Protocol (RFC 6455)
Home-page: https://github.com/aaugustin/websockets
Author: Aymeric Augustin
Author-email: [email protected]
License: BSD
Location: /home/pi/home-assistant/lib/python3.6/site-packages
Requires:
Required-by: pyharmony, discord.py
OK. :-)
Can you run the following command to update websockets to 6.0:
pip install websockets==6.0 --upgrade
That should fix this. Will try to figure out how to make websockets 6.0 minimum requirement.
yup give me a few min :)
@ehendrix23 ok a few things lol:
2018-12-19 10:11:31 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:11:35 WARNING (MainThread) [homeassistant.helpers.entity] Update of remote.harmony_hub_bedroom is taking over 10 seconds
2018-12-19 10:11:37 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:11:43 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:11:49 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:11:55 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:01 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:07 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:13 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:19 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:25 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-19 10:12:25 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub_bedroom fails
Traceback (most recent call last):
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 528, in transfer_data
msg = yield from self.read_message()
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 580, in read_message
frame = yield from self.read_data_frame(max_size=self.max_size)
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 645, in read_data_frame
frame = yield from self.read_frame(max_size)
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 710, in read_frame
extensions=self.extensions,
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/framing.py", line 100, in read
data = yield from reader(2)
File "/usr/local/lib/python3.6/asyncio/streams.py", line 666, in readexactly
raise IncompleteReadError(incomplete, n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/pi/home-assistant/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/pi/home-assistant/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 184, in _send_request
return await self._wait_response(msgid)
File "/home/pi/home-assistant/lib/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 350, in recv
yield from self.ensure_open()
File "/home/pi/home-assistant/lib/python3.6/site-packages/websockets/protocol.py", line 501, in ensure_open
self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
Also just to comment. This only happens with remote.turn_on
and remote.turn_off
. If I use the harmony remote itself to turn on/off an activity it updates just fine. I can also use remote.send_command
to control devices independently.
So only with remote.turn_on and remote.turn_off? Not with remove.send_command?
That is really helpful to troubleshoot then! Thx!
Yup that is correct only those 2 service calls it seems and np happy to help! If you need anything else feel free to tag me, I am also on discord same user name :)
Just doing a quick check and I tried those ones out at my home and they worked. :-)
Can you enable debugging in HASS for components homeassistant.components.remote.harmony and pyharmony.client?
For example (you might already have logger there):
logger:
default: warning
logs:
homeassistant.components.remote.harmony: debug
pyharmony.client: debug
And then retry.
@ehendrix23 here you go: https://hastebin.com/wojimuziya.bash
This log includes both remote.turn_on
and remote.turn_off
https://hastebin.com/havanodome.bash
I'm not 100% sure, but I think the issue here is that it is still waiting for responses on the start activity when at the same time having send a request for update. And what end up might be having 2 different ones reading (or something like that). Got it somewhat in my mind on what is going on, just the explaining is the issue.
I was already going to look into how we handle responses etc. to be able to re-enable callback so that HASS does not have to poll every 5 seconds. Going to be a bit before I have something on that but I think it might help with this issue as well.
I think right now in your case there are 2 tasks (or more) running to read from that socket ending up causing this issue.
My idea is to have only 1 running all the time to read anything coming in. When something is then executed and needs a response it will then "register" with the "reader" identifying the message ID or so it is waiting for. When the "reader" then receives something it will match it with the message ID and provide the response to the correct one.
But, it will take me a bit of time to develop and then do some initial testing. Not to mention to think a bit more on exactly how I would do this.
Encountered the same issue on 0.84.5 and created issue #19486 which has been linked and closed.
Logs before upgrading Python websocket module:
2018-12-20 10:21:01 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:05 WARNING (MainThread) [homeassistant.helpers.entity] Update of remote.harmony_hub is taking over 10 seconds
2018-12-20 10:21:07 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:13 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:19 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:25 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:31 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:37 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:43 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:49 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:21:55 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:22:01 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:22:07 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 10:22:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub fails
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 184, in _send_request
return await self._wait_response(msgid)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 298, in recv
raise ConnectionClosed(self.close_code, self.close_reason)
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006, no reason.
2018-12-20 10:22:11 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/service.py", line 277, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote/harmony.py", line 240, in async_turn_on
await self._client.start_activity(activity_id)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 289, in start_activity
response = await self._wait_response(msgid)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 298, in recv
raise ConnectionClosed(self.close_code, self.close_reason)
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006, no reason.
Websocket Module Version:
$ pip show websockets
Name: websockets
Version: 3.2
Summary: An implementation of the WebSocket Protocol (RFC 6455)
Home-page: https://github.com/aaugustin/websockets
Author: Aymeric Augustin
Author-email: [email protected]
License: BSD
Location: /home/homeassistant/homeassistant/lib/python3.6/site-packages
Requires:
Required-by: pylgtv, pyharmony, homematicip
Websocket Module Upgrade:
$ pip install websockets==6.0 --upgrade
Collecting websockets==6.0
Downloading https://files.pythonhosted.org/packages/5c/fe/99aeaf97985585baefca8d56125ec828ef5549276324ec319b63a4da686d/websockets-6.0-cp36-cp36m-manylinux1_x86_64.whl (88kB)
100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 92kB 1.7MB/s
Installing collected packages: websockets
Found existing installation: websockets 3.2
Uninstalling websockets-3.2:
Successfully uninstalled websockets-3.2
Successfully installed websockets-6.0
Log after Websocket Module Upgrade:
2018-12-20 13:04:53 WARNING (MainThread) [homeassistant.helpers.entity] Update of remote.harmony_hub is taking over 10 seconds
2018-12-20 13:04:55 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:01 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:07 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:13 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:19 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:25 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:31 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:37 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:43 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:49 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:05:55 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:06:01 WARNING (MainThread) [homeassistant.components.remote] Updating harmony remote took longer than the scheduled update interval 0:00:05
2018-12-20 13:06:04 ERROR (MainThread) [homeassistant.helpers.entity] Update for remote.harmony_hub fails
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 528, in transfer_data
msg = yield from self.read_message()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 580, in read_message
frame = yield from self.read_data_frame(max_size=self.max_size)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 645, in read_data_frame
frame = yield from self.read_frame(max_size)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 710, in read_frame
extensions=self.extensions,
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/framing.py", line 100, in read
data = yield from reader(2)
File "/usr/lib64/python3.6/asyncio/streams.py", line 672, in readexactly
raise IncompleteReadError(incomplete, n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/entity.py", line 347, in async_device_update
await self.async_update()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote/harmony.py", line 205, in async_update
activity_id = await self._client.get_current_activity()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 234, in get_current_activity
'vnd.logitech.harmony/vnd.logitech.harmony.engine'
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 184, in _send_request
return await self._wait_response(msgid)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 350, in recv
yield from self.ensure_open()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 501, in ensure_open
self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
2018-12-20 13:06:04 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 528, in transfer_data
msg = yield from self.read_message()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 580, in read_message
frame = yield from self.read_data_frame(max_size=self.max_size)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 645, in read_data_frame
frame = yield from self.read_frame(max_size)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 710, in read_frame
extensions=self.extensions,
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/framing.py", line 100, in read
data = yield from reader(2)
File "/usr/lib64/python3.6/asyncio/streams.py", line 672, in readexactly
raise IncompleteReadError(incomplete, n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 2 expected bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/helpers/service.py", line 277, in _handle_service_platform_call
await getattr(entity, func)(**data)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/homeassistant/components/remote/harmony.py", line 240, in async_turn_on
await self._client.start_activity(activity_id)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 289, in start_activity
response = await self._wait_response(msgid)
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/pyharmony/client.py", line 190, in _wait_response
response_json = await self._websocket.recv()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 350, in recv
yield from self.ensure_open()
File "/home/homeassistant/homeassistant/lib64/python3.6/site-packages/websockets/protocol.py", line 501, in ensure_open
self.close_code, self.close_reason) from self.transfer_data_exc
websockets.exceptions.ConnectionClosed: WebSocket connection is closed: code = 1006 (connection closed abnormally [internal]), no reason
Good news is after upgrading the Websockets Module it continues to work despite the expection occurring. But it appears to only happen while the Harmony Hub is "switching" activities. After which the state is updated correctly.
Thanks, that just seems to confirm further to me on what might be going on and then what I'm working on now should fix this. :-)
@dshokouhi, @ronytomen
I've got a full updated version ready using a new module I developed. This one will be able to better handle everything. If you would be willing to test it out and let me know of any issues. Working good here but then again I do not have every scenario here. :-)
This should resolve the issue you have reported as well.
It has the following improvements:
How to update:
Now restart HASS. The new aiomodule will be downloaded automatically.
If you have issues, reverting back is as easy as replacing harmony.py in your custom folder back with the copy made earlier (harmony.py.bak) and restarting HASS.
Appreciate it!
@ehendrix23 so far so good on my end. I tested turning on an activity from HA, turning it off from the front end. Starting an activity on the remote. I was also able to send device commands successful. I did not encounter any issues in my setup :) Good job!!!!
Much more stable!
I do like the changes to the Harmony Hub configuration file and the additional logging informing you of the activity progress!
Thank you, I've been using too without problems.
EDIT: There's an error when using devices, I posted the issue on your aioharmony fork.
Yep, noticed that as well and already fixed on my end. Thank you!!
There is also an issue with reconnect. Had to restart my router and it only tried to reconnect once and when it failed on that gave up. Fixed as well.
Working on splitting off the hubconnector from actual protocol being used. Hence not able to do an update right now until I have that working.
I also have further updates for HASS harmony component. Testing service for changing channels, added firmware as an attribute.
Note, I just made config updates on my HUBs (added device, removed device, ...) and happy to report that it resulted in automatic update of my configuration. :-)
Question, what does the remote.harmony_sync
service do?
I have an issue where my input_select
state is incorrect on restarting HA. Can I use the mentioned service to cause a forced activity update?
Sync initiates a synchronization for the HUB, and based on that thus will also retrieve the configuration (including current activity) once SYNC is complete.
You should not need to do this however. When the platform is initialized it will get the current activity from the HUB.
I have the following within my automation to set my input_select on startup:
- alias: 'Setup after startup'
hide_entity: true
initial_state: on
trigger:
- platform: homeassistant
event: start
action:
# Turn off the automation to enable an activity based on the input_select.
# Need to do this 1st time as the state can go from PowerOff to an activity.
- service: automation.turn_off
entity_id: automation.Harmony_Activity_Selected
# Set the input select box to current activity for the family room.
- service: input_select.select_option
entity_id: input_select.family_room_tv
data_template:
option: "{{ state_attr('remote.family_room','current_activity') }}"
# Set the input select box to current activity for the master bedroom.
- service: input_select.select_option
entity_id: input_select.master_bedroom_tv
data_template:
option: "{{ state_attr('remote.master_bedroom','current_activity') }}"
- delay: 00:00:01 # Wait 1 second before turning on the automation again.
# Now turn the automation on again, from now on we should act on it.
- service: automation.turn_on
entity_id: automation.Harmony_Activity_Selected
And here is what I have then for both when an activity is selected from within HASS:
- alias: "Harmony_Activity_Selected"
hide_entity: true
trigger:
- platform: state
entity_id: input_select.family_room_tv
- platform: state
entity_id: input_select.master_bedroom_tv
condition:
- condition: template
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
- condition: template
value_template: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
{{ trigger.to_state.state != state_attr("remote." + room,'current_activity') }}
action:
service_template: >
{% if is_state(trigger.entity_id, "PowerOff") %}
script.remote_harmony_poweroff
{% else %}
script.remote_harmony_start_activity
{% endif %}
data_template:
room: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
{{ room }}
activity: " {{ trigger.to_state.state }} "
And here when an activity is selected from somewhere else (i.e. remote):
- alias: "Harmony_Update_Activity_Selected"
hide_entity: true
initial_state: on
trigger:
- platform: state
entity_id: remote.family_room
- platform: state
entity_id: remote.master_bedroom
action:
service: input_select.select_option
data_template:
entity_id: >
{% set entity = trigger.entity_id.split(".")[1] %}
{% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %}
input_select.{{ room }}_tv
option: "{{ state_attr(trigger.entity_id,'current_activity') }}"
With this I have it that input_select is showing the current activity on startup, that changing from input_select the activity is executed (but not if the change is due to it being changed from somewhere else), and that input_select is set to correct activity.
Sync initiates a synchronization for the HUB, and based on that thus will also retrieve the configuration (including current activity) once SYNC is complete.
You should not need to do this however. When the platform is initialized it will get the current activity from the HUB.
I have the following within my automation to set my input_select on startup:
- alias: 'Setup after startup' hide_entity: true initial_state: on trigger: - platform: homeassistant event: start action: # Turn off the automation to enable an activity based on the input_select. # Need to do this 1st time as the state can go from PowerOff to an activity. - service: automation.turn_off entity_id: automation.Harmony_Activity_Selected # Set the input select box to current activity for the family room. - service: input_select.select_option entity_id: input_select.family_room_tv data_template: option: "{{ state_attr('remote.family_room','current_activity') }}" # Set the input select box to current activity for the master bedroom. - service: input_select.select_option entity_id: input_select.master_bedroom_tv data_template: option: "{{ state_attr('remote.master_bedroom','current_activity') }}" - delay: 00:00:01 # Wait 1 second before turning on the automation again. # Now turn the automation on again, from now on we should act on it. - service: automation.turn_on entity_id: automation.Harmony_Activity_Selected
And here is what I have then for both when an activity is selected from within HASS:
- alias: "Harmony_Activity_Selected" hide_entity: true trigger: - platform: state entity_id: input_select.family_room_tv - platform: state entity_id: input_select.master_bedroom_tv condition: - condition: template value_template: "{{ trigger.from_state.state != trigger.to_state.state }}" - condition: template value_template: > {% set entity = trigger.entity_id.split(".")[1] %} {% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %} {{ trigger.to_state.state != state_attr("remote." + room,'current_activity') }} action: service_template: > {% if is_state(trigger.entity_id, "PowerOff") %} script.remote_harmony_poweroff {% else %} script.remote_harmony_start_activity {% endif %} data_template: room: > {% set entity = trigger.entity_id.split(".")[1] %} {% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %} {{ room }} activity: " {{ trigger.to_state.state }} "
And here when an activity is selected from somewhere else (i.e. remote):
- alias: "Harmony_Update_Activity_Selected" hide_entity: true initial_state: on trigger: - platform: state entity_id: remote.family_room - platform: state entity_id: remote.master_bedroom action: service: input_select.select_option data_template: entity_id: > {% set entity = trigger.entity_id.split(".")[1] %} {% set room = entity.split("_")[0] + "_" + entity.split("_")[1] %} input_select.{{ room }}_tv option: "{{ state_attr(trigger.entity_id,'current_activity') }}"
With this I have it that input_select is showing the current activity on startup, that changing from input_select the activity is executed (but not if the change is due to it being changed from somewhere else), and that input_select is set to correct activity.
Is there anywere one could have a look @ the setup you use? as a Homeassistant config or so. When i saw how you do the Input select update i got interested to see more on how i can maby improve on my setup.
@askusbloodfist,
No, I do not have it published. I only started using HASS a few months ago and since instead of putting in a lot of time for configuring my own, I'm ending up a lot more time doing development for it. :-)
However, if you tag me (ehendrix) in Home Assistant community forum with questions on the above I'll sure try to answer them :-)
I noticed the above issue last night, it have been working fine until yesterday.
I have upgraded my both Harmony to Developer firmware 4.15.210 and is running Hassio 0.84.6 (don't want to upgrade to 0.85.1 since there seems to be issues with Homekit).
I restarted both Harmony and Hassio and now it's working again.
If I'm to follow @ehendrix23 suggestion for upgrade of harmony.py, I don't have any "harmony.py" anywhere in my config share today, so is this a new solution to handle Harmony from Hassio? I mean, it's working now without the "harmony.py".
Also, will this upgrade (if I'm using it) revert to the original local API (XMPP) insteaad of web sockets?
Thanks!
@nolenjohan ,
The version in 0.84.6 works with web sockets as it was a patch to allow Harmony to keep on working with the new firmware (which dropped XMPP).
What was suggested was temporary for some to get a updated version in their HASS while it was still further tested and then would be going for approvals.
Version 0.85 includes a new harmony platform based on a new library providing a number of further improvements as well. It is still based on web sockets as Logitech has not made a GA release available with XMPP support back in. Once they do I will then update the library to use XMPP instead as that is what's Logitech's initial direction provided for this.
For now, if it works for you I would not do anything until you can update your HASS.
Most helpful comment
Thanks, that just seems to confirm further to me on what might be going on and then what I'm working on now should fix this. :-)