* Add available property to kodi, with some code cleanup
* Update homeassistant/components/kodi/media_player.py
Co-authored-by: Shay Levy <levyshay1@gmail.com>
Co-authored-by: Shay Levy <levyshay1@gmail.com>
The webhook url should be calculated at startup, not stored in the state
as otherwise a change in network requires re-configuring the integration
from scratch.
This is particularly important as external network configuration might
change when moving HA between networks, and it's not obvious it needs
to be re-added just for this.
Fixes
```
2022-04-29 12:49:10 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry Alexander (192.168.209.83) for isy994
Traceback (most recent call last):
File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 474, in async_unload
result = await component.async_unload_entry(hass, self)
File "/Users/bdraco/home-assistant/homeassistant/components/isy994/__init__.py", line 294, in async_unload_entry
await hass.async_add_executor_job(_stop_auto_update)
File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/Users/bdraco/home-assistant/homeassistant/components/isy994/__init__.py", line 292, in _stop_auto_update
isy.websocket.stop()
File "/Users/bdraco/home-assistant/venv/lib/python3.9/site-packages/pyisy/events/websocket.py", line 110, in stop
self.websocket_task.cancel()
File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 753, in call_soon
self._check_thread()
File "/opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/asyncio/base_events.py", line 790, in _check_thread
raise RuntimeError(
RuntimeError: Non-thread-safe operation invoked on an event loop other than the current one
```