Merge pull request #30154 from home-assistant/rc

0.103.4
This commit is contained in:
Paulus Schoutsen 2019-12-22 23:41:22 +01:00 committed by GitHub
commit 48d35a4550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 69 deletions

View File

@ -160,7 +160,11 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
def _update_entry(self, entry, host, port, api_key=None): def _update_entry(self, entry, host, port, api_key=None):
"""Update existing entry.""" """Update existing entry."""
if entry.data[CONF_HOST] == host: if (
entry.data[CONF_HOST] == host
and entry.data[CONF_PORT] == port
and (api_key is None or entry.data[CONF_API_KEY] == api_key)
):
return self.async_abort(reason="already_configured") return self.async_abort(reason="already_configured")
entry.data[CONF_HOST] = host entry.data[CONF_HOST] = host
@ -187,6 +191,8 @@ class DeconzFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
for entry in self.hass.config_entries.async_entries(DOMAIN): for entry in self.hass.config_entries.async_entries(DOMAIN):
if uuid == entry.data.get(CONF_UUID): if uuid == entry.data.get(CONF_UUID):
if entry.source == "hassio":
return self.async_abort(reason="already_configured")
return self._update_entry( return self._update_entry(
entry, discovery_info[CONF_HOST], entry.data.get(CONF_PORT) entry, discovery_info[CONF_HOST], entry.data.get(CONF_PORT)
) )

View File

@ -59,7 +59,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
entity_handler.add_entity(new_sensor) entity_handler.add_entity(new_sensor)
entities.append(new_sensor) entities.append(new_sensor)
if sensor.battery: if sensor.battery is not None:
new_battery = DeconzBattery(sensor, gateway) new_battery = DeconzBattery(sensor, gateway)
if new_battery.unique_id not in batteries: if new_battery.unique_id not in batteries:
batteries.add(new_battery.unique_id) batteries.add(new_battery.unique_id)
@ -225,6 +225,9 @@ class DeconzBatteryHandler:
@callback @callback
def create_tracker(self, sensor): def create_tracker(self, sensor):
"""Create new tracker for battery state.""" """Create new tracker for battery state."""
for tracker in self._trackers:
if sensor == tracker.sensor:
return
self._trackers.add(DeconzSensorStateTracker(sensor, self.gateway)) self._trackers.add(DeconzSensorStateTracker(sensor, self.gateway))
@callback @callback

View File

@ -15,11 +15,11 @@ from homeassistant.components.image_processing import (
CONF_SOURCE, CONF_SOURCE,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
ImageProcessingEntity, ImageProcessingEntity,
draw_box,
) )
from homeassistant.core import split_entity_id from homeassistant.core import split_entity_id
from homeassistant.helpers import template from homeassistant.helpers import template
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.util.pil import draw_box
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -1,10 +1,8 @@
{ {
"domain": "doods", "domain": "doods",
"name": "DOODS - Distributed Outside Object Detection Service", "name": "DOODS - Distributed Outside Object Detection Service",
"documentation": "https://www.home-assistant.io/integrations/doods", "documentation": "https://www.home-assistant.io/integrations/doods",
"requirements": [ "requirements": ["pydoods==1.0.2", "pillow==6.2.1"],
"pydoods==1.0.2" "dependencies": [],
], "codeowners": []
"dependencies": [],
"codeowners": []
} }

View File

@ -303,6 +303,7 @@ class HomeKit:
def setup(self): def setup(self):
"""Set up bridge and accessory driver.""" """Set up bridge and accessory driver."""
# pylint: disable=import-outside-toplevel
from .accessories import HomeBridge, HomeDriver from .accessories import HomeBridge, HomeDriver
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop) self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self.stop)

View File

@ -2,9 +2,7 @@
import asyncio import asyncio
from datetime import timedelta from datetime import timedelta
import logging import logging
from typing import Tuple
from PIL import ImageDraw
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME, CONF_ENTITY_ID, CONF_NAME from homeassistant.const import ATTR_ENTITY_ID, ATTR_NAME, CONF_ENTITY_ID, CONF_NAME
@ -65,46 +63,6 @@ PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend(
PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE.extend(PLATFORM_SCHEMA.schema) PLATFORM_SCHEMA_BASE = cv.PLATFORM_SCHEMA_BASE.extend(PLATFORM_SCHEMA.schema)
def draw_box(
draw: ImageDraw,
box: Tuple[float, float, float, float],
img_width: int,
img_height: int,
text: str = "",
color: Tuple[int, int, int] = (255, 255, 0),
) -> None:
"""
Draw a bounding box on and image.
The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)
where the coordinates are floats in the range [0.0, 1.0] and
relative to the width and height of the image.
For example, if an image is 100 x 200 pixels (height x width) and the bounding
box is `(0.1, 0.2, 0.5, 0.9)`, the upper-left and bottom-right coordinates of
the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates).
"""
line_width = 3
font_height = 8
y_min, x_min, y_max, x_max = box
(left, right, top, bottom) = (
x_min * img_width,
x_max * img_width,
y_min * img_height,
y_max * img_height,
)
draw.line(
[(left, top), (left, bottom), (right, bottom), (right, top), (left, top)],
width=line_width,
fill=color,
)
if text:
draw.text(
(left + line_width, abs(top - line_width - font_height)), text, fill=color
)
async def async_setup(hass, config): async def async_setup(hass, config):
"""Set up the image processing.""" """Set up the image processing."""
component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL) component = EntityComponent(_LOGGER, DOMAIN, hass, SCAN_INTERVAL)

View File

@ -2,11 +2,7 @@
"domain": "image_processing", "domain": "image_processing",
"name": "Image processing", "name": "Image processing",
"documentation": "https://www.home-assistant.io/integrations/image_processing", "documentation": "https://www.home-assistant.io/integrations/image_processing",
"requirements": [ "requirements": [],
"pillow==6.2.1" "dependencies": ["camera"],
],
"dependencies": [
"camera"
],
"codeowners": [] "codeowners": []
} }

View File

@ -2,7 +2,7 @@
"domain": "seven_segments", "domain": "seven_segments",
"name": "Seven segments", "name": "Seven segments",
"documentation": "https://www.home-assistant.io/integrations/seven_segments", "documentation": "https://www.home-assistant.io/integrations/seven_segments",
"requirements": [], "requirements": ["pillow==6.2.1"],
"dependencies": [], "dependencies": [],
"codeowners": [] "codeowners": []
} }

View File

@ -15,11 +15,11 @@ from homeassistant.components.image_processing import (
CONF_SOURCE, CONF_SOURCE,
PLATFORM_SCHEMA, PLATFORM_SCHEMA,
ImageProcessingEntity, ImageProcessingEntity,
draw_box,
) )
from homeassistant.core import split_entity_id from homeassistant.core import split_entity_id
from homeassistant.helpers import template from homeassistant.helpers import template
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.util.pil import draw_box
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)

View File

@ -2,7 +2,12 @@
"domain": "tensorflow", "domain": "tensorflow",
"name": "Tensorflow", "name": "Tensorflow",
"documentation": "https://www.home-assistant.io/integrations/tensorflow", "documentation": "https://www.home-assistant.io/integrations/tensorflow",
"requirements": ["tensorflow==1.13.2", "numpy==1.17.4", "protobuf==3.6.1"], "requirements": [
"tensorflow==1.13.2",
"numpy==1.17.4",
"protobuf==3.6.1",
"pillow==6.2.1"
],
"dependencies": [], "dependencies": [],
"codeowners": [] "codeowners": []
} }

View File

@ -1,7 +1,7 @@
"""Constants used by Home Assistant components.""" """Constants used by Home Assistant components."""
MAJOR_VERSION = 0 MAJOR_VERSION = 0
MINOR_VERSION = 103 MINOR_VERSION = 103
PATCH_VERSION = "3" PATCH_VERSION = "4"
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION) __short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION) __version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
REQUIRED_PYTHON_VER = (3, 6, 1) REQUIRED_PYTHON_VER = (3, 6, 1)

47
homeassistant/util/pil.py Normal file
View File

@ -0,0 +1,47 @@
"""PIL utilities.
Can only be used by integrations that have pillow in their requirements.
"""
from typing import Tuple
from PIL import ImageDraw
def draw_box(
draw: ImageDraw,
box: Tuple[float, float, float, float],
img_width: int,
img_height: int,
text: str = "",
color: Tuple[int, int, int] = (255, 255, 0),
) -> None:
"""
Draw a bounding box on and image.
The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)
where the coordinates are floats in the range [0.0, 1.0] and
relative to the width and height of the image.
For example, if an image is 100 x 200 pixels (height x width) and the bounding
box is `(0.1, 0.2, 0.5, 0.9)`, the upper-left and bottom-right coordinates of
the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates).
"""
line_width = 3
font_height = 8
y_min, x_min, y_max, x_max = box
(left, right, top, bottom) = (
x_min * img_width,
x_max * img_width,
y_min * img_height,
y_max * img_height,
)
draw.line(
[(left, top), (left, bottom), (right, bottom), (right, top), (left, top)],
width=line_width,
fill=color,
)
if text:
draw.text(
(left + line_width, abs(top - line_width - font_height)), text, fill=color
)

View File

@ -980,9 +980,11 @@ piglow==1.2.4
# homeassistant.components.pilight # homeassistant.components.pilight
pilight==0.1.1 pilight==0.1.1
# homeassistant.components.image_processing # homeassistant.components.doods
# homeassistant.components.proxy # homeassistant.components.proxy
# homeassistant.components.qrcode # homeassistant.components.qrcode
# homeassistant.components.seven_segments
# homeassistant.components.tensorflow
pillow==6.2.1 pillow==6.2.1
# homeassistant.components.dominos # homeassistant.components.dominos

View File

@ -320,11 +320,6 @@ pexpect==4.6.0
# homeassistant.components.pilight # homeassistant.components.pilight
pilight==0.1.1 pilight==0.1.1
# homeassistant.components.image_processing
# homeassistant.components.proxy
# homeassistant.components.qrcode
pillow==6.2.1
# homeassistant.components.plex # homeassistant.components.plex
plexapi==3.3.0 plexapi==3.3.0