home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.48k stars 30.7k forks source link

Panasonic Viera: state always reported as on after restart of Home Assistant #34894

Closed rschaeuble closed 4 years ago

rschaeuble commented 4 years ago

The problem

After restarting Home Assistant, the state of my Panasonic Viera (model TX-55EXW604S) is always reported as ON.

This is occuring since upgrading to 0.109. In 0.107 (I skipped 0.108), the state was correct after restart.

Environment

Problem-relevant configuration.yaml

No entires in configuration.yaml. This is the relevant part from core.config_entries:

{
                "connection_class": "local_poll",
                "data": {
                    "host": "xxx.xxx.xxx.xxx",
                    "name": "wohnzimmer_fernsehgeraet",
                    "port": 55000,
                    "turn_on_action": null
                },
                "domain": "panasonic_viera",
                "entry_id": "XXXXXXXXX",
                "options": {},
                "source": "user",
                "system_options": {
                    "disable_new_entities": false
                },
                "title": "wohnzimmer_fernsehgeraet",
                "unique_id": "xxx.xxx.xxx.xxx",
                "version": 1
 }

Traceback/Error logs

There are no log entires.

Additional information

I have an (unverified) theory what's going on.

Version 0.107: https://github.com/home-assistant/core/blob/d520a02b8c41b073476a615a582990a1b8e4ceff/homeassistant/components/panasonic_viera/media_player.py#L125-L132 The update method catches exceptions, setting the state to OFF when it can't fetch volume etc. from the TV.

Version 0.109: https://github.com/home-assistant/core/blob/405062d2df06c8e3861fd0010104d628306235df/homeassistant/components/panasonic_viera/media_player.py#L244-L250 The _update method (which seems to to be the replacement for the old update method) does not catch exceptions. As a result, the state stays set to ON (which is the assumed initial state).

lolouk44 commented 4 years ago

sorry just seen this. Was too eager to test :) this line too? remote_device = PanasonicVieraRemoteEntity(remote, name)

joogps commented 4 years ago

You don't need to rename PanasonicVieraRemoteEntity, just replace RemoteEntity with RemoteDevice where it appears (it appears twice)

Do the same in media_player.py

lolouk44 commented 4 years ago

Some progress :) TV first showed as on after restarting HA while TV was on Volume reacted pretty much straight away. App name shows netflix for some reason even though I had no app running Then still says on on even though I switch the TV off with the remote I eventually (about 30 sec later) turned the tv on with the remote. The TV state went to off Then remains off regardless, with this in the logs:

Update for media_player.panasonic_viera_tv fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 962, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 949, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.27', 55000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 583, in async_aiohttp_request
    method, url, headers=headers, data=body
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.0.27:55000 ssl:None [Connect call failed ('192.168.0.27', 55000)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/media_player.py", line 114, in async_update
    await self._remote.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 203, in async_update
    await self._handle_errors(self._update, is_async=True)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 262, in _handle_errors
    await self._shutdown()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 296, in _shutdown
    await self._control.async_upnp_service_unsubscribe(event)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 648, in async_upnp_service_unsubscribe
    "UNSUBSCRIBE", f"http://{self._host}:{self._port}/{service}", headers
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 591, in async_aiohttp_request
    raise TimeoutError
TimeoutError
lolouk44 commented 4 years ago

by the way I have now 3 components? image

joogps commented 4 years ago

the remote entity is from a new feature I'm adding.

Ok, I will make one more commit that logs when the state variables change and what kind of data is received.

joogps commented 4 years ago

Also the log messages were just poor error handling. I'll fix that in the future

lolouk44 commented 4 years ago

cool. I'll also set my logs to debug for the component. Is that correct ?

logger:
  default: error
  logs:
    homeassistant.components.panasonic_viera: debug
joogps commented 4 years ago

Yes!

joogps commented 4 years ago

Also, it would be nice to call homeassistant.update_entity after each change to update states right away

lolouk44 commented 4 years ago

cool. So far, if the TV is on while I restart HA, it's updating the volume So is the mute state, without having to call homeassistant.update_entity app_name seems to remain at "netflix" regardless of the app running (tried with youtube) Calling homeassistant.update_entity doesn't seem to have any effect

joogps commented 4 years ago

Do you have any logs with Received data from service?

joogps commented 4 years ago

This "Netflix" situation is strange... I need to check the data sent by your TV to confirm where the problem is

lolouk44 commented 4 years ago

latest:

2020-05-04 13:07:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 723, in _handle_request
    await self.on_event(service, properties)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 273, in on_event
    _LOGGER.error("Received data from service %s: %d", service, properties)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1407, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1514, in _log
    self.handle(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1524, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1586, in callHandlers
    hdlr.handle(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 894, in handle
    self.emit(record)
  File "/usr/src/homeassistant/homeassistant/components/system_log/__init__.py", line 181, in emit
    record, stack, _figure_out_source(record, stack, self.hass)
  File "/usr/src/homeassistant/homeassistant/components/system_log/__init__.py", line 97, in __init__
    self.message = deque([record.getMessage()], maxlen=5)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: %d format: a number is required, not collections.OrderedDict
2020-05-04 13:07:26 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 723, in _handle_request
    await self.on_event(service, properties)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 273, in on_event
    _LOGGER.error("Received data from service %s: %d", service, properties)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1407, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1514, in _log
    self.handle(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1524, in handle
    self.callHandlers(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 1586, in callHandlers
    hdlr.handle(record)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 894, in handle
    self.emit(record)
  File "/usr/src/homeassistant/homeassistant/components/system_log/__init__.py", line 181, in emit
    record, stack, _figure_out_source(record, stack, self.hass)
  File "/usr/src/homeassistant/homeassistant/components/system_log/__init__.py", line 97, in __init__
    self.message = deque([record.getMessage()], maxlen=5)
  File "/usr/local/lib/python3.7/logging/__init__.py", line 369, in getMessage
    msg = msg % self.args
TypeError: %d format: a number is required, not list
joogps commented 4 years ago

Sorry, apparently Python didn't like the way I was logging. Fixed.

lolouk44 commented 4 years ago

it's funny now that twice I get an update in the logs after I click restart server.

2020-05-04 13:12:48 DEBUG (SyncWorker_8) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-04 13:12:48 DEBUG (SyncWorker_8) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-04 13:12:48 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-04 13:12:49 INFO (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Please override the on_event method to handle the received data.
2020-05-04 13:12:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 13:12:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-04 13:12:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: on
2020-05-04 13:12:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update app info: vc_app:1:product_id=0010000200000001:Netflix

Just did the update on init.py Then got this at restart:

2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service dmr/event_0
2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] OrderedDict([('@val', '0'), ('PresetNameList', OrderedDict([('@val', 'FactoryDefaults')])), ('Mute', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('Volume', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('X_AudioList', OrderedDict([('@val', '-1,')])), ('X_CurrentAudioID', OrderedDict([('@val', '0')])), ('X_DualMonoModeList', OrderedDict([('@val', '-1,')])), ('X_CurrentDualMonoModeID', OrderedDict([('@val', '0')])), ('X_SubtitleList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleID', OrderedDict([('@val', '0')])), ('X_SubtitleCharCodeList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleCharCodeID', OrderedDict([('@val', '0')]))])
2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: on
2020-05-04 13:13:52 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update app info: vc_app:1:product_id=0010000200000001:Netflix
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service dmr/event_0
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] OrderedDict([('@val', '0'), ('PresetNameList', OrderedDict([('@val', 'FactoryDefaults')])), ('Mute', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('Volume', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('X_AudioList', OrderedDict([('@val', '-1,')])), ('X_CurrentAudioID', OrderedDict([('@val', '0')])), ('X_DualMonoModeList', OrderedDict([('@val', '-1,')])), ('X_CurrentDualMonoModeID', OrderedDict([('@val', '0')])), ('X_SubtitleList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleID', OrderedDict([('@val', '0')])), ('X_SubtitleCharCodeList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleCharCodeID', OrderedDict([('@val', '0')]))])
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: on
2020-05-04 13:14:03 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update app info: vc_app:1:product_id=0010000200000001:Netflix
joogps commented 4 years ago

The "Netflix" issue is because of the data coming from your TV, apparently. And the screen state should update when you turn the TV off. If it doesn't, then the problem is with Panasonic's API.

lolouk44 commented 4 years ago

my boy is watching youtube now ;) gimme 10 min (we're about to have lunch after that so will quickly test state changes before)

joogps commented 4 years ago

oh, no problem!

lolouk44 commented 4 years ago

state is not changing to off after switching off by remote...

2020-05-04 13:20:23 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: off
2020-05-04 13:20:23 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 13:20:23 ERROR (MainThread) [homeassistant.components.panasonic_viera] OrderedDict([('X_ScreenState', 'off')])
2020-05-04 13:20:23 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: off
2020-05-04 13:20:32 DEBUG (MainThread) [homeassistant.components.panasonic_viera] Could not establish remote connection: 
2020-05-04 13:20:32 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Stopping server
2020-05-04 13:20:32 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.panasonic_viera_tv fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 962, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 949, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.27', 55000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 583, in async_aiohttp_request
    method, url, headers=headers, data=body
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.0.27:55000 ssl:None [Connect call failed ('192.168.0.27', 55000)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/media_player.py", line 114, in async_update
    await self._remote.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 202, in async_update
    await self._handle_errors(self._update, is_async=True)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 261, in _handle_errors
    await self._shutdown()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 302, in _shutdown
    await self._control.async_upnp_service_unsubscribe(event)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 648, in async_upnp_service_unsubscribe
    "UNSUBSCRIBE", f"http://{self._host}:{self._port}/{service}", headers
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 591, in async_aiohttp_request
    raise TimeoutError
TimeoutError
2020-05-04 13:20:42 DEBUG (MainThread) [homeassistant.components.panasonic_viera] Could not establish remote connection: 
2020-05-04 13:20:42 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Stopping server
2020-05-04 13:20:42 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.panasonic_viera_tv fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 962, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 949, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.27', 55000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 583, in async_aiohttp_request
    method, url, headers=headers, data=body
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.0.27:55000 ssl:None [Connect call failed ('192.168.0.27', 55000)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/media_player.py", line 114, in async_update
    await self._remote.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 202, in async_update
    await self._handle_errors(self._update, is_async=True)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 261, in _handle_errors
    await self._shutdown()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 302, in _shutdown
    await self._control.async_upnp_service_unsubscribe(event)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 648, in async_upnp_service_unsubscribe
    "UNSUBSCRIBE", f"http://{self._host}:{self._port}/{service}", headers
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 591, in async_aiohttp_request
    raise TimeoutError
TimeoutError
2020-05-04 13:20:43 DEBUG (MainThread) [homeassistant.components.panasonic_viera] Could not establish remote connection: 
2020-05-04 13:20:43 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Stopping server
2020-05-04 13:20:43 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.panasonic_viera_tv fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 936, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 962, in create_connection
    raise exceptions[0]
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 949, in create_connection
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 473, in sock_connect
    return await fut
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 503, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 111] Connect call failed ('192.168.0.27', 55000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 583, in async_aiohttp_request
    method, url, headers=headers, data=body
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/usr/local/lib/python3.7/site-packages/aiohttp/client.py", line 483, in _request
    timeout=real_timeout
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 523, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 859, in _create_connection
    req, traces, timeout)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 1004, in _create_direct_connection
    raise last_exc
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 986, in _create_direct_connection
    req=req, client_error=client_error)
  File "/usr/local/lib/python3.7/site-packages/aiohttp/connector.py", line 943, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 192.168.0.27:55000 ssl:None [Connect call failed ('192.168.0.27', 55000)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/media_player.py", line 114, in async_update
    await self._remote.async_update()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 202, in async_update
    await self._handle_errors(self._update, is_async=True)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 261, in _handle_errors
    await self._shutdown()
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/__init__.py", line 302, in _shutdown
    await self._control.async_upnp_service_unsubscribe(event)
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 648, in async_upnp_service_unsubscribe
    "UNSUBSCRIBE", f"http://{self._host}:{self._port}/{service}", headers
  File "/usr/src/homeassistant/homeassistant/components/panasonic_viera/panasonic_viera/__init__.py", line 591, in async_aiohttp_request
    raise TimeoutError
TimeoutError
joogps commented 4 years ago

Okay, I think I know what's happening. The _shutdown function has no error checking, and when a TimeoutError is raised, it prevents the TV state from being set to "Unavailable" after a connection error. In the first lines, we can see that the TV's state is set to off, but the integration fails after that

joogps commented 4 years ago

I'll try to optimize it for all TVs (each one behaves a bit differently from the others apparently)

lolouk44 commented 4 years ago

getting better. State now keeps changing as I turn on and off. even the app state has changed. Opening Firefox returns: app_name: Netflix, vc_app Opening BBC Iplayer returns: app_name: Netflix, vc_app Opening Youtube returns: app_name: Netflix Switching to HDMI input returns: app_name: Netflix

Turning the TV off via remote, state goes to unavailable. Turning it back on, state goes briefly to off then on (which I guess makes sense. When the TV is off, its NIC is off as I can't even ping it) So although I'll have to update all my automations from off to unavailable, I'm happy it's working now :)

btw remote also changes from on to unavailable. media_player.viera remains unavailable all the time, so that's probably one to remove for now?

lolouk44 commented 4 years ago

you may also want to change the log level for the data received from error to debug:

2020-05-04 14:34:49 DEBUG (SyncWorker_0) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-04 14:34:49 DEBUG (SyncWorker_0) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-04 14:34:49 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service dmr/event_0
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] OrderedDict([('@val', '0'), ('PresetNameList', OrderedDict([('@val', 'FactoryDefaults')])), ('Mute', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('Volume', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('X_AudioList', OrderedDict([('@val', '-1,')])), ('X_CurrentAudioID', OrderedDict([('@val', '0')])), ('X_DualMonoModeList', OrderedDict([('@val', '-1,')])), ('X_CurrentDualMonoModeID', OrderedDict([('@val', '0')])), ('X_SubtitleList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleID', OrderedDict([('@val', '0')])), ('X_SubtitleCharCodeList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleCharCodeID', OrderedDict([('@val', '0')]))])
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: on
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update app info: vc_app:1:product_id=0010000200000001:Netflix
2020-05-04 14:36:51 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Not notify
2020-05-04 14:36:52 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Not notify
joogps commented 4 years ago

getting better. State now keeps changing as I turn on and off. even the app state has changed. Opening Firefox returns: app_name: Netflix, vc_app Opening BBC Iplayer returns: app_name: Netflix, vc_app Opening Youtube returns: app_name: Netflix Switching to HDMI input returns: app_name: Netflix

Turning the TV off via remote, state goes to unavailable. Turning it back on, state goes briefly to off then on (which I guess makes sense. When the TV is off, its NIC is off as I can't even ping it) So although I'll have to update all my automations from off to unavailable, I'm happy it's working now :)

btw remote also changes from on to unavailable. media_player.viera remains unavailable all the time, so that's probably one to remove for now?

I guess the media_player.viera entity is just an old entity that wasn't removed completely 🤷‍♂️

joogps commented 4 years ago

you may also want to change the log level for the data received from error to debug:

2020-05-04 14:34:49 DEBUG (SyncWorker_0) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-04 14:34:49 DEBUG (SyncWorker_0) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-04 14:34:49 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service dmr/event_0
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] OrderedDict([('@val', '0'), ('PresetNameList', OrderedDict([('@val', 'FactoryDefaults')])), ('Mute', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('Volume', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('X_AudioList', OrderedDict([('@val', '-1,')])), ('X_CurrentAudioID', OrderedDict([('@val', '0')])), ('X_DualMonoModeList', OrderedDict([('@val', '-1,')])), ('X_CurrentDualMonoModeID', OrderedDict([('@val', '0')])), ('X_SubtitleList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleID', OrderedDict([('@val', '0')])), ('X_SubtitleCharCodeList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleCharCodeID', OrderedDict([('@val', '0')]))])
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Received the following data from service nrc/event_0
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update screen state: on
2020-05-04 14:34:49 ERROR (MainThread) [homeassistant.components.panasonic_viera] Update app info: vc_app:1:product_id=0010000200000001:Netflix
2020-05-04 14:36:51 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Not notify
2020-05-04 14:36:52 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Not notify

That was just to make sure it would appear 😂

joogps commented 4 years ago

Also, I didn't manage to get input data. Maybe it's impossible with my model, since not even the app let me do it.

legolas0802 commented 4 years ago

migliorare. Lo stato ora continua a cambiare mentre accendo e spengo. anche lo stato dell'app è cambiato. Apertura di ritorni di Firefox: nome_app: Netflix, vc_app Apertura di BBC Iplayer ritorni: nome_app: Netflix, vc_app Apertura di ritorni Youtube: nome_app: Netflix Passaggio a ritorni di ingresso HDMI: nome_app: Netflix

Spegnendo la TV tramite telecomando, lo stato diventa non disponibile. Riaccendendolo, lo stato si spegne brevemente, quindi si accende (il che immagino abbia senso. Quando la TV è spenta, la sua scheda di rete è disattivata in quanto non riesco nemmeno a eseguire il ping) Quindi anche se dovrò aggiornare tutte le mie automazioni da offa unavailable, sono felice che funzioni ora :)

btw remote cambia anche da on a non disponibile. media_player.viera non è sempre disponibile, quindi è probabilmente uno da rimuovere per ora?

for the unaviable problem go to the TV menu and activate the option switch on via app, under remote TV app settings

lolouk44 commented 4 years ago

for the unaviable problem go to the TV menu and activate the option switch on via app, under remote TV app settings

Thanks @legolas0802 for this. Never knew/noticed this :)

@joogps if you can add this to the doc next time you update the integration/doc. You may also want to add my TV to the list of supported models (TX58DX700) ;)

Last but not least, I don't suppose you're able to retrieve the TV's source?

joogps commented 4 years ago

@lolouk44 I couldn’t manage to get the source (subscribed to all of the available events and got nothing), but it’s possible to change the source with key presses and get the current app. So we could implement input selection where the source would only be set, and if an app was open, it would display the app name

legolas0802 commented 4 years ago

for the unaviable problem go to the TV menu and activate the option switch on via app, under remote TV app settings

Thanks @legolas0802 for this. Never knew/noticed this :)

@joogps if you can add this to the doc next time you update the integration/doc. You may also want to add my TV to the list of supported models (TX58DX700) ;)

Last but not least, I don't suppose you're able to retrieve the TV's source? You are welcome!!! the source no, but it would be a great success to be able to change it as happens from the smartphone app.

lolouk44 commented 4 years ago

the source no, but it would be a great success to be able to change it as happens from the smartphone app.

Yes that'd be great...

circa1665 commented 4 years ago

Last but not least, I don't suppose you're able to retrieve the TV's source?

Source selection (HDMI 1, 2, 3) would be amazing!!

joogps commented 4 years ago

That's definitely something to add... I just need to work on fixing those issues first

circa1665 commented 4 years ago

That's definitely something to add... I just need to work on fixing those issues first

Awesome!!

Re: reading the current input from the TV, not sure if this helps, if I go to [TV_IP]:55000/nrc/sdd_0.xml

I can see this XML file: sdd_0.xml.zip

There's this section:

    <action>
      <name>X_GetInputMode</name>
      <argumentList>
        <argument>
          <name>X_InputMode</name>
          <direction>out</direction>
          <relatedStateVariable>X_InputMode</relatedStateVariable>
        </argument>
      </argumentList>
    </action>

Would this have anything to do with reading the current input?

joogps commented 4 years ago
Screen Shot 2020-05-01 at 15 32 56

@rschaeuble guess that's something 🤷

@circa1665 that probably just returns 'rc-mode', as reported by the events. It's the only attribute I didn't figure out the meaning of 🤔

joogps commented 4 years ago

X_KeyboardType changes when a keyboard is opened (and that could be useful)

joogps commented 4 years ago

I made the pull request on the lib repository https://github.com/florianholzapfel/panasonic-viera/pull/36

joogps commented 4 years ago

@lolouk44 I made some extra changes on my fork, you can test them if you want to

joogps commented 4 years ago

It's the only attribute I didn't figure out the meaning of 🤔

It just clicked. “rc-mode” probably stands for “remote control mode”, since there’s also a “pad mode” available in the official app

lolouk44 commented 4 years ago

@lolouk44 I made some extra changes on my fork, you can test them if you want to

Sure. What changes did you do / what do you want me to test?

lolouk44 commented 4 years ago

At first glance it doesn't work as well. State was showing as unavailable after I set the integration up (with the TV in standby mode, not off) Turning the TV on eventually changed the status to on, but turning it off changed the status to unavailable I then turned the TV back on and the status remains unavailable

2020-05-05 08:15:04 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Sending to http://192.168.0.27:55000/dmr/control_0:
{'Host': '192.168.0.27:55000', 'Content-Length': 328, 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"'}
b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:GetVolume xmlns:m="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></m:GetVolume></s:Body></s:Envelope>'
2020-05-05 08:15:04 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentVolume>0</CurrentVolume>\n  </u:GetVolumeResponse>\n </s:Body>\n</s:Envelope>\n'
2020-05-05 08:15:04 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Sending to http://192.168.0.27:55000/dmr/control_0:
{'Host': '192.168.0.27:55000', 'Content-Length': 324, 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"urn:schemas-upnp-org:service:RenderingControl:1#GetMute"'}
b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:GetMute xmlns:m="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></m:GetMute></s:Body></s:Envelope>'
2020-05-05 08:15:04 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetMuteResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentMute>0</CurrentMute>\n  </u:GetMuteResponse>\n </s:Body>\n</s:Envelope>\n'
2020-05-05 08:15:14 DEBUG (SyncWorker_24) [homeassistant.components.panasonic_viera.panasonic_viera] Sending to http://192.168.0.27:55000/dmr/control_0:
{'Host': '192.168.0.27:55000', 'Content-Length': 328, 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"'}
b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:GetVolume xmlns:m="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></m:GetVolume></s:Body></s:Envelope>'
2020-05-05 08:15:14 DEBUG (SyncWorker_24) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentVolume>0</CurrentVolume>\n  </u:GetVolumeResponse>\n </s:Body>\n</s:Envelope>\n'
2020-05-05 08:15:14 DEBUG (SyncWorker_24) [homeassistant.components.panasonic_viera.panasonic_viera] Sending to http://192.168.0.27:55000/dmr/control_0:
{'Host': '192.168.0.27:55000', 'Content-Length': 324, 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"urn:schemas-upnp-org:service:RenderingControl:1#GetMute"'}
b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:GetMute xmlns:m="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></m:GetMute></s:Body></s:Envelope>'
2020-05-05 08:15:14 DEBUG (SyncWorker_24) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetMuteResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentMute>0</CurrentMute>\n  </u:GetMuteResponse>\n </s:Body>\n</s:Envelope>\n'
2020-05-05 08:15:36 DEBUG (SyncWorker_15) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetMuteResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentMute>0</CurrentMute>\n  </u:GetMuteResponse>\n </s:Body>\n</s:Envelope>\n'
2020-05-05 08:15:36 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Received valid request from service None. Handling properties:
2020-05-05 08:15:36 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] OrderedDict([('X_ScreenState', 'off')])
2020-05-05 08:15:36 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Received valid request from service nrc/event_0. Handling properties:
2020-05-05 08:15:36 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] OrderedDict([('X_ScreenState', 'off')])
2020-05-05 08:15:47 DEBUG (MainThread) [homeassistant.components.panasonic_viera] Could not establish remote connection: HTTP Error 400: Bad Request
2020-05-05 08:15:47 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Stopping server
2020-05-05 08:15:47 DEBUG (MainThread) [homeassistant.components.panasonic_viera] Couldn't unsubscribe from service %s
2020-05-05 08:15:58 DEBUG (SyncWorker_31) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:15:58 DEBUG (SyncWorker_31) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:15:58 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:16:09 DEBUG (SyncWorker_2) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:16:09 DEBUG (SyncWorker_2) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:16:09 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:16:09 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:16:20 DEBUG (SyncWorker_6) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:16:20 DEBUG (SyncWorker_6) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:16:20 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:16:20 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:16:30 DEBUG (SyncWorker_15) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:16:30 DEBUG (SyncWorker_15) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:16:30 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:16:30 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:16:41 DEBUG (SyncWorker_12) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:16:41 DEBUG (SyncWorker_12) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:16:41 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:16:41 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:16:52 DEBUG (SyncWorker_3) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:21:56 DEBUG (SyncWorker_11) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:21:56 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:21:56 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:22:06 DEBUG (SyncWorker_26) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:22:06 DEBUG (SyncWorker_26) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:22:06 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:22:06 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:22:17 DEBUG (SyncWorker_25) [homeassistant.components.panasonic_viera.panasonic_viera] Determining TV type

2020-05-05 08:22:17 DEBUG (SyncWorker_25) [homeassistant.components.panasonic_viera.panasonic_viera] Determined TV type is non-encrypted

2020-05-05 08:22:17 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Creating server at 192.168.0.23:55000
2020-05-05 08:22:17 ERROR (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Failed to create HTTP server at 192.168.0.23:55000: [Errno 98] error while attempting to bind on address ('192.168.0.23', 55000): address in use
2020-05-05 08:22:17 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Received valid request from service None. Handling properties:
2020-05-05 08:22:17 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] OrderedDict([('@val', '0'), ('PresetNameList', OrderedDict([('@val', 'FactoryDefaults')])), ('Mute', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('Volume', OrderedDict([('@val', '0'), ('@channel', 'Master')])), ('X_AudioList', OrderedDict([('@val', '-1,')])), ('X_CurrentAudioID', OrderedDict([('@val', '0')])), ('X_DualMonoModeList', OrderedDict([('@val', '-1,')])), ('X_CurrentDualMonoModeID', OrderedDict([('@val', '0')])), ('X_SubtitleList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleID', OrderedDict([('@val', '0')])), ('X_SubtitleCharCodeList', OrderedDict([('@val', '-1,')])), ('X_CurrentSubtitleCharCodeID', OrderedDict([('@val', '0')]))])
2020-05-05 08:22:17 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] Received valid request from service None. Handling properties:
2020-05-05 08:22:17 DEBUG (MainThread) [homeassistant.components.panasonic_viera.panasonic_viera] [OrderedDict([('X_InputMode', 'rc-mode')]), OrderedDict([('X_KeyboardType', 'default')]), OrderedDict([('X_ScreenState', 'on')]), OrderedDict([('X_AppInfo', 'vc_app:1:product_id=0010000200000001:Netflix')])]
2020-05-05 08:22:28 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Sending to http://192.168.0.27:55000/dmr/control_0:
{'Host': '192.168.0.27:55000', 'Content-Length': 328, 'Content-Type': 'text/xml; charset=utf-8', 'SOAPAction': '"urn:schemas-upnp-org:service:RenderingControl:1#GetVolume"'}
b'<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:GetVolume xmlns:m="urn:schemas-upnp-org:service:RenderingControl:1"><InstanceID>0</InstanceID><Channel>Master</Channel></m:GetVolume></s:Body></s:Envelope>'
2020-05-05 08:22:28 DEBUG (SyncWorker_1) [homeassistant.components.panasonic_viera.panasonic_viera] Response: b'<?xml version="1.0" encoding="utf-8"?>\n<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">\n <s:Body>\n  <u:GetVolumeResponse xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1">\n   <CurrentVolume>0</CurrentVolume>\n  </u:GetVolumeResponse>\n </s:Body>\n</s:Envelope>\n'
joogps commented 4 years ago
Screen Shot 2020-05-05 at 11 48 22

Turns out the TV has a server with all of the app icons!

MadsALarsen commented 4 years ago

any news on the power state issue (always on)???

joogps commented 4 years ago

It's fixed! I'm pushing the changes to this repository, if you want to, you can test it.

MadsALarsen commented 4 years ago

cool, but I don't know how to use the link, haven't tried it before???

joogps commented 4 years ago

You can just wait for the official release if you prefer 😁

MadsALarsen commented 4 years ago

i would love to get it fixed now ;-)

lolouk44 commented 4 years ago

It's fixed! I'm pushing the changes to this repository, if you want to, you can test it.

I'm not seeing any changes since 13h ago?

joogps commented 4 years ago

I'm doing some final edits, mainly to the tests. I closed the PR that added remote control support so I can prioritise this one

lolouk44 commented 4 years ago

for info I just tried the latest code and I can't set up the integration:

Error occurred loading configuration flow for integration panasonic_viera: cannot import name 'EncryptionRequired' from 'panasonic_viera' (/config/panasonic_viera/__init__.py)
Connection lost. Reconnecting…