Closed zibous closed 4 years ago
Hey there @bendavid, mind taking a look at this issue as its been labeled with a integration (webostv
) you are listed as a codeowner for? Thanks!
@zibous can you check what version of websockets is installed in this environment?
The /srv/homeassistant/lib/python3.7/site-packages/websockets/version.py shows me: version = '6.0'
Is there another way to check the running version ?
Ok, this version is pretty out of date. Upgrading websockets to the latest version should fix it. (This probably means the minimum version number needs to be added to the websocket dependency in aiopylgtv to avoid this from occurring in some setups.)
Thanks. But is this usually not managed through the Homeassistant installation? I have the version over
pip3 install --pre --upgrade homeassistant
installed and thought that I would upgrade everything.
Yes, I think the dependencies in aiopylgtv need to be updated in order to make this work automatically the way you expect. (I think what's happening is that since websockets was already installed in this environment, and nothing explicitly requested a newer version, it was not upgraded automatically.)
OK. Thank you. Is there a way to update the websockets to the latest version (without side effects) or do I have to wait until this is solved via the dependencies in aiopylgtv.
I also have a problem with the integration at 0.104.0b3.
Error during setup of component webostv
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 170, in _async_setup_component hass, processed_config File "/usr/src/homeassistant/homeassistant/components/webostv/__init__.py", line 91, in async_setup tasks = [async_setup_tv(hass, config, conf) for conf in config[DOMAIN]] KeyError: 'webostv'
Edit: this is a different problem and it's because webostv
now has its own platform.
So do not set it up under media_player:
but webostv:
Temporär update websockets and websocket-client for 0.104.0b4:
$ sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip install --upgrade websocket-client
$ pip install --upgrade websockets
$ pip3 freeze | grep web
## Result
websocket-client==0.57.0
websockets==8.1
Now webostv is working w/o errors
Problem to pair
What solution is there for this? I can no longer connect the LG TV to the current version.
Nmap scan report for 10.1.1.92
Host is up (0.0012s latency).
Not shown: 994 closed ports
PORT STATE SERVICE
1131/tcp open caspssl
1433/tcp open ms-sql-s
1900/tcp open upnp
3000/tcp open ppp
3001/tcp open nessus
9998/tcp open distinct32
1. Stop Homeassistant
2. Delete webostv.conf
3. Turn on LG TV
4. Enable Pairing on LG TV
5. Start Homeassistant
6. Start Pairing Request
7. Accept connection on LG TV
8. new webostv.conf created
webostv.conf
9. Homeassistant Pairing Dialog never close
--> Error log
Jan 13 08:49:31 zeusus hass[29115]: 2020-01-13 08:49:31 ERROR (MainThread) [homeassistant.components.webostv] Unable to connect to host 10.1.1.92
If you restart home assistant after the failed pairing attempt, does it then successfully connect?
@bendavid
Negativ, do not connect.
Protokolldetails ( WARNING )
Mon Jan 13 2020 10:42:11 GMT+0100 (Mitteleuropäische Normalzeit)
Platform androidtv not ready yet. Retrying in 30 seconds.
Can you try pairing and connecting standalone? (ie using the "Basic example" from https://github.com/bendavid/aiopylgtv)
I don't think this is possible because I only have Python 3.7.5 installed. Requirements: Python> = 3.8
It does also work in python 3.7 (but ideally you would try it in the same python environment as home assistant is using in any case)
Result:
Traceback (most recent call last):
File "test.py", line 12, in <module>
asyncio.get_event_loop().run_until_complete(runloop(client))
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "test.py", line 5, in runloop
await client.connect()
File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 118, in connect
return await self.connect_result
File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 199, in connect_handler
self.subscribe_inputs(self.set_inputs_state),
File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 651, in subscribe_inputs
return await self.subscribe(inputs, EP_GET_INPUTS)
File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 490, in subscribe
return await self.request(uri, payload=payload, cmd_type='subscribe', uid=uid)
File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 478, in request
raise PyLGTVCmdException(f"Invalid request response {response}")
aiopylgtv.webos_client.PyLGTVCmdException: Invalid request response
Response:
{
"type": "response",
"id": 7,
"payload": {
"devices": [
{
"id": "SCART_1",
"label": "AV-1",
"port": 1,
"appId": "com.webos.app.externalinput.scart",
"icon": "http://10.1.1.92:3000/resources/625dfb7d9b95f5e0845937da645ec742f1d2388f/scart.png",
"modified": False,
"autoav": False,
"currentTVStatus": "",
"subList": [],
"subCount": 0,
"connected": False,
"favorite": False
},
{
"id": "AV_1",
"label": "AV-2",
"port": 1,
"appId": "com.webos.app.externalinput.av2",
"icon": "http://10.1.1.92:3000/resources/09d1fd9f5429e1e08c831ae6aaa5d7ef9e3c1822/av.png",
"modified": False,
"subList": [],
"subCount": 0,
"connected": False,
"favorite": False
},
{
"id": "COMP_1",
"label": "Komponente",
"port": 1,
"appId": "com.webos.app.externalinput.component",
"icon": "http://10.1.1.92:3000/resources/a3cb1035230cde11c41cef0091a298b5c541b093/component.png",
"modified": False,
"subList": [],
"subCount": 0,
"connected": False,
"favorite": False
},
{
"id": "HDMI_1",
"label": "Anderes Gerät",
"port": 1,
"appId": "com.webos.app.hdmi1",
"icon": "http://10.1.1.92:3000/resources/0482be2c0d70c6ac9ccde8c394aafcb42a24e2d7/streamingbox.png",
"modified": False,
"subList": [],
"subCount": 0,
"connected": True,
"favorite": True
},
{
"id": "HDMI_2",
"label": "HDMI-2",
"port": 2,
"appId": "com.webos.app.hdmi2",
"icon": "http://10.1.1.92:3000/resources/ce24a63433f7202b8f6785aa0eebd3005a18eca7/HDMI_2.png",
"modified": False,
"subList": [
{
"id": "SIMPLINK",
"uniqueId": 4,
"cecpDevType": 4,
"cecpDevId": 8,
"cecpNewType": 6,
"version": 12,
"osdName": "BD HTS"
}
],
"oneDepth": True,
"subCount": 1,
"connected": False,
"favorite": True
},
{
"id": "HDMI_3",
"label": "HDMI-3",
"port": 3,
"appId": "com.webos.app.hdmi3",
"icon": "http://10.1.1.92:3000/resources/500126c2e959f46c5647287f5acd5a4e8c447fdc/HDMI_3.png",
"modified": False,
"subList": [
{
"id": "SIMPLINK",
"uniqueId": 8,
"cecpDevType": 4,
"cecpDevId": 15,
"cecpNewType": 9,
"version": 0,
"osdName": "Amazon FireTV"
}
],
"oneDepth": True,
"subCount": 1,
"connected": True,
"favorite": True
},
{
"id": "HDMI_4",
"label": "Set-Top-Box",
"port": 4,
"appId": "com.webos.app.hdmi4",
"icon": "http://10.1.1.92:3000/resources/29b40774bc050f06a4335d5832ff019cfa93c37d/settopbox.png",
"modified": False,
"subList": [],
"subCount": 0,
"connected": False,
"favorite": True
}
],
"returnValue": True
}
}
Ok, this TV model behaves slightly differently from the ones I've tested with. I'll make the error handling a bit more flexible to accommodate this.
@bendavid o.k Thanks.
LG 55UC970V-ZA
Software 05.05.90
webOS TV Version 1.4.0-2357(afro-ashley)
how do i with the new integration record three different lg tv in my home assistant? each registration of the next device deletes the previous one, being the webostv.conf file unique? in fact, unlike the previous system in which you could indicate a webostv.conf file for each TV, this in 0.104 seems not to be possible? Are there possible solutions?
It should work with a single webostv.conf file (it can store registration information for multiple devices, keyed by host/ip address.) Does it not work?
@bendavid
How can i update to update aiopylgtv to 0.2.6 or do I have to wait until a new version of the home assistant is released.
Pre upgrade do not install the new version.
pip3 install --pre --upgrade homeassistant
You can manually upgrade aiopylgtv with pip
pip3 install --upgrade aiopylgtv
It doesn't work: the previous recording is canceled for every TV I add. If I manually edit the webostv.conf file, entering the registration information of the other televisions, an error message indicating the webostv integration appears. Other solutions?
@bendavid
Perfect, all is working w/o errors with Home Assistant 0.104.0. Thanks 👍
How can i switch TV on ?
Both settings "service: persistent_notification.create || service: wake_on_lan.send_magic_packet" do not work and the TV is not switched on.
webostv:
name: Wohnzimmer LG TV
host: 10.1.1.92
standby_connection: true
# turn_on_action:
# service: persistent_notification.create
# data:
# message: "Turn on action"
turn_on_action:
service: wake_on_lan.send_magic_packet
data:
mac: "CC:2D:8C:B2:BA:A2"
customize:
sources:
- livetv
- youtube
- netflix
Is there a solution or alternative?
Error Log service: wake_on_lan.send_magic_packet
Jan 16 15:12:08 zeusus hass[26414]: 2020-01-16 15:12:08 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.139620184376976] Not connected, can't execute command.
Jan 16 15:12:08 zeusus hass[26414]: Traceback (most recent call last):
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
Jan 16 15:12:08 zeusus hass[26414]: connection.context(msg),
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1226, in async_call
Jan 16 15:12:08 zeusus hass[26414]: await asyncio.shield(self._execute_service(handler, service_call))
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1251, in _execute_service
Jan 16 15:12:08 zeusus hass[26414]: await handler.func(service_call)
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 201, in handle_service
Jan 16 15:12:08 zeusus hass[26414]: self._platforms.values(), func, call, service_name, required_features
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 335, in entity_service_call
Jan 16 15:12:08 zeusus hass[26414]: future.result() # pop exception if have
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 357, in _handle_service_platform_call
Jan 16 15:12:08 zeusus hass[26414]: await getattr(entity, func)(**data)
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/media_player.py", line 304, in async_turn_on
Jan 16 15:12:08 zeusus hass[26414]: await self._client.get_current_app()
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 554, in get_current_app
Jan 16 15:12:08 zeusus hass[26414]: res = await self.request(EP_GET_CURRENT_APP_INFO)
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 454, in request
Jan 16 15:12:08 zeusus hass[26414]: await self.command(cmd_type, uri, payload, uid)
Jan 16 15:12:08 zeusus hass[26414]: File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 442, in command
Jan 16 15:12:08 zeusus hass[26414]: raise PyLGTVCmdException("Not connected, can't execute command.")
Jan 16 15:12:08 zeusus hass[26414]: aiopylgtv.webos_client.PyLGTVCmdException: Not connected, can't execute command.
Turn OFF TV is working.
Attempts to send a message (notification) to the TV are unfortunately not possible.
Looks like you might not have standby+ or equivalent setting enabled on your tv. Either enable this setting on the tv, or set standby_connection to false in your home assistant config.
(The handling of this situation in home assistant/aiopylgtv is not optimal however, so this is something which I will also improve.)
It should work with a single webostv.conf file (it can store registration information for multiple devices, keyed by host/ip address.) Does it not work?
@bendavid I just opened this issue addressing the inability to add more than one TV at a time #30868
@bendavid
Thanks for your information.
I'm unlucky because the version webOS TV version 1.4.0-2357 (afro-ashley) has no option for "Standby Mode" or "WakeOnLan". So I don't think it can be switched on, because if the TV is off, it cannot be reached via the network. He also does not respond to a WOL broadcast.
LG 55UC970V-ZA
Software 05.05.90
webOS TV Version 1.4.0-2357(afro-ashley)
Alternatively I tried to switch on the FireTV Stick, which also activates the TV. Works, but switching back to TV LiveMode does not work.
lgwohnzimmer_on:
alias: "LG TV Wohnzimmer einschalten"
sequence:
- service: media_player.turn_on
entity_id:
- media_player.lg_fire_tv
- delay: '00:00:10'
- service: media_player.select_source
data:
entity_id: media_player.wohnzimmer_lg_tv
source: LiveTV
I'm still looking for a solution. A turn_on_action via a connected device would be great:
webostv:
name: Wohnzimmer LG TV
host: 10.1.1.92
standby_connection: false
turn_on_action:
service: media_player.turn_on
entity_id:
- media_player.lg_fire_tv
customize:
turn_on_source:
- livetv
sources:
- livetv
- youtube
- netflix
There's no reason why switching sources in a sequence shouldn't work like this. The "delay" may not a reliable way of doing this, especially if your TV does not support standby mode, so you could explicitly wait for the TV to change state.
lgwohnzimmer_on:
alias: "LG TV Wohnzimmer einschalten"
sequence:
- service: media_player.turn_on
entity_id:
- media_player.lg_fire_tv
- wait_template: "{{ not(is_state('media_player.wohnzimmer_lg_tv', 'off')) }}"
timeout: '00:00:30'
continue_on_timeout: 'false'
- service: media_player.select_source
data:
entity_id: media_player.wohnzimmer_lg_tv
source: LiveTV
@bendavid Thanks
Good idea 👍 , but unfortunately it doesn't work. The LG Tv is switched on and after about 10s the HMDI port is activated with the Amazon FireTV and Amazone Prime is displayed. Then there is no changeover, since the media_player.wohnzimmer_lg_tv state is already set to "on".
If I increase the TimeOut to 5 min, it will work, but that's too long. Try to find a better event to control this ..
In this case you could have the wait template look at the current course rather than the state (or wait for it to switch to the relevant hdmi port and then switch back to the desired source)
@bendavid
If I take out the "Timeout", then the script works.
lgwohnzimmer_on:
alias: "LG TV Wohnzimmer einschalten"
sequence:
- service: media_player.turn_on
entity_id:
- media_player.lg_fire_tv
- wait_template: "{{ (is_state('media_player.wohnzimmer_lg_tv', 'on')) }}"
- service: media_player.select_source
data:
entity_id: media_player.wohnzimmer_lg_tv
source: LiveTV
It looks like the event "state: 'media_player.wohnzimmer_lg_tv" takes a very long time. Can I set the shorter one?
Probably not. The TV may simply take a long time to fully boot from a cold off state (this is the reason why lg introduced standby+ I guess)
@bendavid
AttributeError: 'NoneType' object has no attribute 'get'
notify:
- platform: webostv
host: !secret webostv_host
name: lgtv_wohnzimmer
Error on startup
Jan 18 19:29:34 zeusus hass[22010]: 2020-01-18 19:29:34 ERROR (MainThread) [homeassistant.components.notify] Error setting up platform webostv
Jan 18 19:29:34 zeusus hass[22010]: Traceback (most recent call last):
Jan 18 19:29:34 zeusus hass[22010]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/notify/__init__.py", line 73, in async_setup_platform
Jan 18 19:29:34 zeusus hass[22010]: hass, p_config, discovery_info
Jan 18 19:29:34 zeusus hass[22010]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/notify.py", line 19, in async_get_service
Jan 18 19:29:34 zeusus hass[22010]: host = discovery_info.get(CONF_HOST)
Jan 18 19:29:34 zeusus hass[22010]: AttributeError: 'NoneType' object has no attribute 'get'
notify.wohnzimmer_lg_tv is working, w/o Errors.
Has anything changed in the configuration or am I doing something wrong?
You should not configure the webostv platform under notify. (The configuration under webostv takes care of both media_player and notify automatically)
@bendavid Yes it is working w/o
notify:
- platform: webostv
....
Thanks 👍
Just leaving this here, media_player.turn_off turns the TV on when it's off.
Home Assistant release with the issue:
Jan 12 10:02:26 zeusus hass[23725]: 2020-01-12 10:02:26 ERROR (MainThread) [homeassistant.setup] Error during setup of component webostv Jan 12 10:02:26 zeusus hass[23725]: Traceback (most recent call last): Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/setup.py", line 170, in _async_setup_component Jan 12 10:02:26 zeusus hass[23725]: hass, processed_config Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/__init__.py", line 93, in async_setup Jan 12 10:02:26 zeusus hass[23725]: await asyncio.gather(*tasks) Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/__init__.py", line 109, in async_setup_tv Jan 12 10:02:26 zeusus hass[23725]: await async_setup_tv_finalize(hass, config, conf, client) Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/__init__.py", line 141, in async_setup_tv_finalize Jan 12 10:02:26 zeusus hass[23725]: await async_connect(client) Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/webostv/__init__.py", line 118, in async_connect Jan 12 10:02:26 zeusus hass[23725]: await client.connect() Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 118, in connect Jan 12 10:02:26 zeusus hass[23725]: return await self.connect_result Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 148, in connect_handler Jan 12 10:02:26 zeusus hass[23725]: close_timeout=self.timeout_connect), Jan 12 10:02:26 zeusus hass[23725]: File "/srv/homeassistant/lib/python3.7/site-packages/websockets/client.py", line 385, in __init__ Jan 12 10:02:26 zeusus hass[23725]: factory, host, port, **kwds) Jan 12 10:02:26 zeusus hass[23725]: TypeError: create_connection() got an unexpected keyword argument 'ping_interval'
I'm having exactly same error. Home Assistant 0.104.3:
arch | x86_64 |
---|---|
dev | false |
docker | true |
hassio | true |
os_name | Linux |
python_version | 3.7.6 |
timezone | Europe/Kiev |
version | 0.104.3 |
virtualenv | false |
TV is having LG WebOS 2.0. I'm using Hass.io under Ubuntu 16.04.6 LTS on Intel NUC Core i3, 16Gb RAM, 256Gb SSD.
You somehow have an older version of websockets, despite that the dependencies explicitly specify the minimum version now. What procedure did you use to update from 0.103?
You somehow have an older version of websockets, despite that the dependencies explicitly specify the minimum version now. What procedure did you use to update from 0.103?
Using UI under /hassio/dashboard. Should I manually update websocets? (And how)
My next steps:
After that pairing request was successful, but just after host restart I have this error again:
Mon Jan 27 2020 15:41:16 GMT+0200 (Eastern European Standard Time)
create_connection() got an unexpected keyword argument 'ping_interval'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 134, in handle_call_service
connection.context(msg),
File "/usr/src/homeassistant/homeassistant/core.py", line 1226, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1251, in _execute_service
await handler.func(service_call)
File "/usr/src/homeassistant/homeassistant/components/configurator/__init__.py", line 235, in async_handle_service_call
await self.hass.async_add_job(callback, call.data.get(ATTR_FIELDS, {}))
File "/usr/src/homeassistant/homeassistant/components/webostv/__init__.py", line 159, in lgtv_configuration_callback
await client.connect()
File "/usr/local/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 126, in connect
return await self.connect_result
File "/usr/local/lib/python3.7/site-packages/aiopylgtv/webos_client.py", line 156, in connect_handler
close_timeout=self.timeout_connect),
File "/usr/local/lib/python3.7/site-packages/websockets/client.py", line 385, in __init__
factory, host, port, **kwds)
TypeError: create_connection() got an unexpected keyword argument 'ping_interval'
Home Assistant release with the issue: 0.104.0b4
Last working Home Assistant release (if known): 0.103.6
Operating environment (Hass.io/Docker/Windows/etc.):
Description of problem: Error during setup of component webostv create_connection() got an unexpected keyword argument 'ping_interval'
Problem-relevant
configuration.yaml
entries and (fill out even if it seems unimportant):Additional information:
ERROR Log
Is there a possible solution to fix this error?