roberodin / ha-samsungtv-custom

📺 HomeAssistant - SamsungTV Custom Component
Apache License 2.0
122 stars 177 forks source link

TV not recognised when on a different VLAN #30

Open phoniclynx opened 4 years ago

phoniclynx commented 4 years ago

I've just decided to separate my network into different VLANs to separate out my IoT devices onto a different VLAN. If I put the TV onto the normal network (192.168.0.0/16) the scripts work beautifully fine, which is the same network as HA. However, if I put it on the IoT VLAN (172.16.0.1/24) I get errors in the logs and no TV device.

TV: UA65RU8000WXXY

My config is:

media_player:
  - platform: samsungtv_custom
    name: TV - Bedroom
    host: 172.16.0.2
    port: 8002
    mac: "uh-oh-no-can-do"
    protocol: ctl_qled

Below are the errors in the logs:

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 408, in _async_add_entity
    await entity.async_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 286, in async_update_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 796, in state_attributes
    for attr in ATTR_TO_PROPERTY
  File "/usr/src/homeassistant/homeassistant/components/media_player/__init__.py", line 797, in <dictcomp>
    if getattr(self, attr) is not None
  File "/config/custom_components/samsungtv_custom/media_player.py", line 510, in is_volume_muted
    self._muted = self._upnp.get_mute()
  File "/config/custom_components/samsungtv_custom/samsungctl_qled/upnp.py", line 50, in get_mute
    if (int(mute) == 0):
UnboundLocalError: local variable 'mute' referenced before assignment

If I change the config to "WS" I get the errors:

Update for media_player.tv_bedroom fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/samsungtv_custom/media_player.py", line 731, in update
    self.send_key("KEY", 1)
  File "/config/custom_components/samsungtv_custom/media_player.py", line 743, in send_key
    self._remote.send_key(key)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 134, in send_key
    self._ws_send(payload)
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 87, in _ws_send
    self.open()
  File "/config/custom_components/samsungtv_custom/samsungtvws/remote.py", line 113, in open
    raise Exception(response)
Exception: {'event': 'ms.channel.timeOut'}

both work-ish.. but I find the qled one to work better with my TV.

terminet85 commented 4 years ago

What version do you have of websocket-client?

phoniclynx commented 4 years ago

@terminet85 how do I know what version I am running? It's the latest docker of HA 100.6

johntdyer commented 4 years ago

Pretty sure I am facing the same issue here... works when its on the same vlan... I've tried all three protocols and they have the same results..

HeedfulCrayon commented 3 years ago

Same issue here. Ping works just fine. I can also access the rest api response from my HA instance, but for some reason websockets don't seem to work for me either.