Fix typo and update style to match the other platforms (#7621)

This commit is contained in:
Fabian Affolter 2017-05-16 21:57:00 +02:00 committed by GitHub
parent 71ed17b836
commit 1fafa34eb1

View file

@ -9,22 +9,15 @@ import logging
from homeassistant.core import split_entity_id from homeassistant.core import split_entity_id
from homeassistant.components.image_processing import ( from homeassistant.components.image_processing import (
ImageProcessingEntity, ImageProcessingEntity, PLATFORM_SCHEMA)
PLATFORM_SCHEMA,
)
from homeassistant.components.opencv import ( from homeassistant.components.opencv import (
ATTR_MATCHES, ATTR_MATCHES, CLASSIFIER_GROUP_CONFIG, CONF_CLASSIFIER, CONF_ENTITY_ID,
CLASSIFIER_GROUP_CONFIG, CONF_NAME, process_image)
CONF_CLASSIFIER,
CONF_ENTITY_ID,
CONF_NAME,
process_image,
)
DEPENDENCIES = ['opencv']
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
DEPENDENCIES = ['opencv']
DEFAULT_TIMEOUT = 10 DEFAULT_TIMEOUT = 10
SCAN_INTERVAL = timedelta(seconds=2) SCAN_INTERVAL = timedelta(seconds=2)
@ -33,18 +26,13 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(CLASSIFIER_GROUP_CONFIG)
def _create_processor_from_config(hass, camera_entity, config): def _create_processor_from_config(hass, camera_entity, config):
"""Create an OpenCV processor from configurtaion.""" """Create an OpenCV processor from configuration."""
classifier_config = config[CONF_CLASSIFIER] classifier_config = config[CONF_CLASSIFIER]
name = '{} {}'.format( name = '{} {}'.format(
config[CONF_NAME], config[CONF_NAME], split_entity_id(camera_entity)[1].replace('_', ' '))
split_entity_id(camera_entity)[1].replace('_', ' '))
processor = OpenCVImageProcessor( processor = OpenCVImageProcessor(
hass, hass, camera_entity, name, classifier_config)
camera_entity,
name,
classifier_config,
)
return processor return processor
@ -57,10 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
devices = [] devices = []
for camera_entity in discovery_info[CONF_ENTITY_ID]: for camera_entity in discovery_info[CONF_ENTITY_ID]:
devices.append( devices.append(
_create_processor_from_config( _create_processor_from_config(hass, camera_entity, discovery_info))
hass,
camera_entity,
discovery_info))
add_devices(devices) add_devices(devices)
@ -115,6 +100,5 @@ class OpenCVImageProcessor(ImageProcessingEntity):
def process_image(self, image): def process_image(self, image):
"""Process the image.""" """Process the image."""
self._last_image = image self._last_image = image
self._matches = process_image(image, self._matches = process_image(
self._classifier_configs, image, self._classifier_configs, False)
False)