fixed get_component() missing 1 required positional argument: 'comp_or_platform'
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
[Shinobi](https://shinobi.video/) is an open source cctv solution.
|
[Shinobi](https://shinobi.video/) is an open source cctv solution.
|
||||||
|
|
||||||
To enable this component, first copy `custom_components/` inside your Home Assistant config directory and add the Shinobi component and platform, for example in `configuration.yaml`. See https://github.com/moeiscool/Shinobi/wiki/API-Access on how to get your `api_key` and `group_key`. The `ssl` param is optional and defaults to `false`. The white- and blacklist is also optional and defaults to all active monitors being considered. Only one filtering method can be applied at the same time. For now, the name assigned in Shinobi is used to filter cams.
|
To enable this component, first copy `custom_components/` inside your Home Assistant config directory and add the Shinobi component and platform, for example in `configuration.yaml`. See https://shinobi.video/docs/api on how to get your `api_key` and `group_key`. The `ssl` param is optional and defaults to `false`. The white- and blacklist is also optional and defaults to all active monitors being considered. Only one filtering method can be applied at the same time. For now, the name assigned in Shinobi is used to filter cams.
|
||||||
|
|
||||||
```
|
```
|
||||||
…
|
…
|
||||||
|
|||||||
@@ -13,16 +13,19 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
DEPENDENCIES = ['shinobi']
|
DEPENDENCIES = ['shinobi']
|
||||||
DOMAIN = 'shinobi'
|
DOMAIN = 'shinobi'
|
||||||
|
|
||||||
shinobi = loader.get_component('shinobi')
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
vol.Optional(CONF_WHITELIST, default=[]): cv.ensure_list,
|
vol.Optional(CONF_WHITELIST, default=[]): cv.ensure_list,
|
||||||
vol.Optional(CONF_BLACKLIST, default=[]): cv.ensure_list
|
vol.Optional(CONF_BLACKLIST, default=[]): cv.ensure_list
|
||||||
})
|
})
|
||||||
|
|
||||||
|
shinobi = None
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
|
global shinobi
|
||||||
|
shinobi = hass.components.shinobi
|
||||||
|
|
||||||
all_monitors = shinobi.get_all_started_monitors()
|
all_monitors = shinobi.get_all_started_monitors()
|
||||||
|
|
||||||
if not all_monitors:
|
if not all_monitors:
|
||||||
@@ -54,7 +57,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
CONF_MJPEG_URL: shinobi.monitor_stream_url(monitor['mid']),
|
CONF_MJPEG_URL: shinobi.monitor_stream_url(monitor['mid']),
|
||||||
CONF_STILL_IMAGE_URL: shinobi.monitor_still_url(monitor['mid'])
|
CONF_STILL_IMAGE_URL: shinobi.monitor_still_url(monitor['mid'])
|
||||||
}
|
}
|
||||||
cameras.append(ShinobiCamera(hass, device_info, monitor))
|
cameras.append(ShinobiCamera(hass, shinobi, device_info, monitor))
|
||||||
|
|
||||||
if not cameras:
|
if not cameras:
|
||||||
_LOGGER.warning('No active cameras found')
|
_LOGGER.warning('No active cameras found')
|
||||||
@@ -66,9 +69,10 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
|||||||
class ShinobiCamera(MjpegCamera):
|
class ShinobiCamera(MjpegCamera):
|
||||||
"""Representation of a Shinobi Monitor Stream."""
|
"""Representation of a Shinobi Monitor Stream."""
|
||||||
|
|
||||||
def __init__(self, hass, device_info, monitor):
|
def __init__(self, hass, shinobi, device_info, monitor):
|
||||||
"""Initialize as a subclass of MjpegCamera."""
|
"""Initialize as a subclass of MjpegCamera."""
|
||||||
super().__init__(hass, device_info)
|
super().__init__(hass, device_info)
|
||||||
|
self.shinobi = shinobi
|
||||||
self._monitor_id = monitor['mid']
|
self._monitor_id = monitor['mid']
|
||||||
self._is_recording = None
|
self._is_recording = None
|
||||||
|
|
||||||
@@ -81,13 +85,13 @@ class ShinobiCamera(MjpegCamera):
|
|||||||
"""Update our recording state from the Shinobi API."""
|
"""Update our recording state from the Shinobi API."""
|
||||||
_LOGGER.debug('Updating camera state for monitor {}'.format(self._monitor_id))
|
_LOGGER.debug('Updating camera state for monitor {}'.format(self._monitor_id))
|
||||||
|
|
||||||
status_response = shinobi.get_monitor_state(self._monitor_id)
|
status_response = self.shinobi.get_monitor_state(self._monitor_id)
|
||||||
|
|
||||||
if not status_response:
|
if not status_response:
|
||||||
_LOGGER.warning('Could not get status for monitor {}'.format(self._monitor_id))
|
_LOGGER.warning('Could not get status for monitor {}'.format(self._monitor_id))
|
||||||
return
|
return
|
||||||
_LOGGER.debug('Monitor {} is in status {}'.format(self._monitor_id, status_response['mode']))
|
_LOGGER.debug('Monitor {} is in status {}'.format(self._monitor_id, status_response['mode']))
|
||||||
self._is_recording = status_response.get('status') == shinobi.SHINOBI_CAM_STATE['RECORDING']
|
self._is_recording = status_response.get('status') == self.shinobi.SHINOBI_CAM_STATE['RECORDING']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_recording(self):
|
def is_recording(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user