mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Upgrade numpy to 1.14.0 (#11542)
This commit is contained in:
parent
13effee679
commit
8b267e3faf
@ -11,21 +11,19 @@ import math
|
|||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
from homeassistant.components.binary_sensor import (
|
||||||
|
DEVICE_CLASSES_SCHEMA, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
|
||||||
|
BinarySensorDevice)
|
||||||
|
from homeassistant.const import (
|
||||||
|
ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME, CONF_DEVICE_CLASS, CONF_ENTITY_ID,
|
||||||
|
CONF_FRIENDLY_NAME, STATE_UNKNOWN)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
|
||||||
BinarySensorDevice, ENTITY_ID_FORMAT, PLATFORM_SCHEMA,
|
|
||||||
DEVICE_CLASSES_SCHEMA)
|
|
||||||
from homeassistant.const import (
|
|
||||||
ATTR_ENTITY_ID, ATTR_FRIENDLY_NAME,
|
|
||||||
CONF_DEVICE_CLASS, CONF_ENTITY_ID, CONF_FRIENDLY_NAME,
|
|
||||||
STATE_UNKNOWN)
|
|
||||||
from homeassistant.helpers.entity import generate_entity_id
|
from homeassistant.helpers.entity import generate_entity_id
|
||||||
from homeassistant.helpers.event import async_track_state_change
|
from homeassistant.helpers.event import async_track_state_change
|
||||||
from homeassistant.util import utcnow
|
from homeassistant.util import utcnow
|
||||||
|
|
||||||
REQUIREMENTS = ['numpy==1.13.3']
|
REQUIREMENTS = ['numpy==1.14.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -36,21 +34,21 @@ ATTR_INVERT = 'invert'
|
|||||||
ATTR_SAMPLE_DURATION = 'sample_duration'
|
ATTR_SAMPLE_DURATION = 'sample_duration'
|
||||||
ATTR_SAMPLE_COUNT = 'sample_count'
|
ATTR_SAMPLE_COUNT = 'sample_count'
|
||||||
|
|
||||||
CONF_SENSORS = 'sensors'
|
|
||||||
CONF_ATTRIBUTE = 'attribute'
|
CONF_ATTRIBUTE = 'attribute'
|
||||||
|
CONF_INVERT = 'invert'
|
||||||
CONF_MAX_SAMPLES = 'max_samples'
|
CONF_MAX_SAMPLES = 'max_samples'
|
||||||
CONF_MIN_GRADIENT = 'min_gradient'
|
CONF_MIN_GRADIENT = 'min_gradient'
|
||||||
CONF_INVERT = 'invert'
|
|
||||||
CONF_SAMPLE_DURATION = 'sample_duration'
|
CONF_SAMPLE_DURATION = 'sample_duration'
|
||||||
|
CONF_SENSORS = 'sensors'
|
||||||
|
|
||||||
SENSOR_SCHEMA = vol.Schema({
|
SENSOR_SCHEMA = vol.Schema({
|
||||||
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||||
vol.Optional(CONF_ATTRIBUTE): cv.string,
|
vol.Optional(CONF_ATTRIBUTE): cv.string,
|
||||||
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
vol.Optional(CONF_DEVICE_CLASS): DEVICE_CLASSES_SCHEMA,
|
||||||
vol.Optional(CONF_FRIENDLY_NAME): cv.string,
|
vol.Optional(CONF_FRIENDLY_NAME): cv.string,
|
||||||
|
vol.Optional(CONF_INVERT, default=False): cv.boolean,
|
||||||
vol.Optional(CONF_MAX_SAMPLES, default=2): cv.positive_int,
|
vol.Optional(CONF_MAX_SAMPLES, default=2): cv.positive_int,
|
||||||
vol.Optional(CONF_MIN_GRADIENT, default=0.0): vol.Coerce(float),
|
vol.Optional(CONF_MIN_GRADIENT, default=0.0): vol.Coerce(float),
|
||||||
vol.Optional(CONF_INVERT, default=False): cv.boolean,
|
|
||||||
vol.Optional(CONF_SAMPLE_DURATION, default=0): cv.positive_int,
|
vol.Optional(CONF_SAMPLE_DURATION, default=0): cv.positive_int,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -129,11 +127,11 @@ class SensorTrend(BinarySensorDevice):
|
|||||||
return {
|
return {
|
||||||
ATTR_ENTITY_ID: self._entity_id,
|
ATTR_ENTITY_ID: self._entity_id,
|
||||||
ATTR_FRIENDLY_NAME: self._name,
|
ATTR_FRIENDLY_NAME: self._name,
|
||||||
ATTR_INVERT: self._invert,
|
|
||||||
ATTR_GRADIENT: self._gradient,
|
ATTR_GRADIENT: self._gradient,
|
||||||
|
ATTR_INVERT: self._invert,
|
||||||
ATTR_MIN_GRADIENT: self._min_gradient,
|
ATTR_MIN_GRADIENT: self._min_gradient,
|
||||||
ATTR_SAMPLE_DURATION: self._sample_duration,
|
|
||||||
ATTR_SAMPLE_COUNT: len(self.samples),
|
ATTR_SAMPLE_COUNT: len(self.samples),
|
||||||
|
ATTR_SAMPLE_DURATION: self._sample_duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -8,16 +8,15 @@ from datetime import timedelta
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.core import split_entity_id
|
|
||||||
from homeassistant.components.image_processing import (
|
from homeassistant.components.image_processing import (
|
||||||
CONF_SOURCE, CONF_ENTITY_ID, CONF_NAME, PLATFORM_SCHEMA,
|
CONF_ENTITY_ID, CONF_NAME, CONF_SOURCE, PLATFORM_SCHEMA,
|
||||||
ImageProcessingEntity)
|
ImageProcessingEntity)
|
||||||
|
from homeassistant.core import split_entity_id
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
|
|
||||||
REQUIREMENTS = ['numpy==1.13.3']
|
REQUIREMENTS = ['numpy==1.14.0']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -73,7 +72,7 @@ def _create_processor_from_config(hass, camera_entity, config):
|
|||||||
|
|
||||||
def _get_default_classifier(dest_path):
|
def _get_default_classifier(dest_path):
|
||||||
"""Download the default OpenCV classifier."""
|
"""Download the default OpenCV classifier."""
|
||||||
_LOGGER.info('Downloading default classifier')
|
_LOGGER.info("Downloading default classifier")
|
||||||
req = requests.get(CASCADE_URL, stream=True)
|
req = requests.get(CASCADE_URL, stream=True)
|
||||||
with open(dest_path, 'wb') as fil:
|
with open(dest_path, 'wb') as fil:
|
||||||
for chunk in req.iter_content(chunk_size=1024):
|
for chunk in req.iter_content(chunk_size=1024):
|
||||||
@ -84,14 +83,13 @@ def _get_default_classifier(dest_path):
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the OpenCV image processing platform."""
|
"""Set up the OpenCV image processing platform."""
|
||||||
try:
|
try:
|
||||||
# Verify opencv python package is preinstalled
|
# Verify that the OpenCV python package is pre-installed
|
||||||
# pylint: disable=unused-import,unused-variable
|
# pylint: disable=unused-import,unused-variable
|
||||||
import cv2 # noqa
|
import cv2 # noqa
|
||||||
except ImportError:
|
except ImportError:
|
||||||
_LOGGER.error("No opencv library found! " +
|
_LOGGER.error(
|
||||||
"Install or compile for your system " +
|
"No OpenCV library found! Install or compile for your system "
|
||||||
"following instructions here: " +
|
"following instructions here: http://opencv.org/releases.html")
|
||||||
"http://opencv.org/releases.html")
|
|
||||||
return
|
return
|
||||||
|
|
||||||
entities = []
|
entities = []
|
||||||
@ -105,8 +103,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
for camera in config[CONF_SOURCE]:
|
for camera in config[CONF_SOURCE]:
|
||||||
entities.append(OpenCVImageProcessor(
|
entities.append(OpenCVImageProcessor(
|
||||||
hass, camera[CONF_ENTITY_ID], camera.get(CONF_NAME),
|
hass, camera[CONF_ENTITY_ID], camera.get(CONF_NAME),
|
||||||
config[CONF_CLASSIFIER]
|
config[CONF_CLASSIFIER]))
|
||||||
))
|
|
||||||
|
|
||||||
add_devices(entities)
|
add_devices(entities)
|
||||||
|
|
||||||
@ -121,8 +118,7 @@ class OpenCVImageProcessor(ImageProcessingEntity):
|
|||||||
if name:
|
if name:
|
||||||
self._name = name
|
self._name = name
|
||||||
else:
|
else:
|
||||||
self._name = "OpenCV {0}".format(
|
self._name = "OpenCV {0}".format(split_entity_id(camera_entity)[1])
|
||||||
split_entity_id(camera_entity)[1])
|
|
||||||
self._classifiers = classifiers
|
self._classifiers = classifiers
|
||||||
self._matches = {}
|
self._matches = {}
|
||||||
self._total_matches = 0
|
self._total_matches = 0
|
||||||
@ -157,8 +153,8 @@ class OpenCVImageProcessor(ImageProcessingEntity):
|
|||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
cv_image = cv2.imdecode(numpy.asarray(bytearray(image)),
|
cv_image = cv2.imdecode(
|
||||||
cv2.IMREAD_UNCHANGED)
|
numpy.asarray(bytearray(image)), cv2.IMREAD_UNCHANGED)
|
||||||
|
|
||||||
for name, classifier in self._classifiers.items():
|
for name, classifier in self._classifiers.items():
|
||||||
scale = DEFAULT_SCALE
|
scale = DEFAULT_SCALE
|
||||||
|
@ -508,7 +508,7 @@ nuheat==0.3.0
|
|||||||
|
|
||||||
# homeassistant.components.binary_sensor.trend
|
# homeassistant.components.binary_sensor.trend
|
||||||
# homeassistant.components.image_processing.opencv
|
# homeassistant.components.image_processing.opencv
|
||||||
numpy==1.13.3
|
numpy==1.14.0
|
||||||
|
|
||||||
# homeassistant.components.google
|
# homeassistant.components.google
|
||||||
oauth2client==4.0.0
|
oauth2client==4.0.0
|
||||||
|
@ -94,7 +94,7 @@ mficlient==0.3.0
|
|||||||
|
|
||||||
# homeassistant.components.binary_sensor.trend
|
# homeassistant.components.binary_sensor.trend
|
||||||
# homeassistant.components.image_processing.opencv
|
# homeassistant.components.image_processing.opencv
|
||||||
numpy==1.13.3
|
numpy==1.14.0
|
||||||
|
|
||||||
# homeassistant.components.mqtt
|
# homeassistant.components.mqtt
|
||||||
# homeassistant.components.shiftr
|
# homeassistant.components.shiftr
|
||||||
|
Loading…
x
Reference in New Issue
Block a user