Remove service helper (3) (#16879)
* Update duckdns * Update google_assistant * Update group * Update homematic * Update image_processing * Update input_boolean * Update input_number * Update input_select * Update input_text
This commit is contained in:
1 parent
672fc61bb2
commit
e2a56721d3
22 files changed
+217
-231
No files matched your search
@@ -0,0 +1,23 @@
|
||||
"""Collection of helper methods.
|
||||
|
||||
All containing methods are legacy helpers that should not be used by new
|
||||
components. Instead call the service directly.
|
||||
"""
|
||||
from homeassistant.components.image_processing import DOMAIN, SERVICE_SCAN
|
||||
from homeassistant.const import ATTR_ENTITY_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.loader import bind_hass
|
||||
|
||||
|
||||
@bind_hass
|
||||
def scan(hass, entity_id=None):
|
||||
"""Force process of all cameras or given entity."""
|
||||
hass.add_job(async_scan, hass, entity_id)
|
||||
|
||||
|
||||
@callback
|
||||
@bind_hass
|
||||
def async_scan(hass, entity_id=None):
|
||||
"""Force process of all cameras or given entity."""
|
||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else None
|
||||
hass.async_add_job(hass.services.async_call(DOMAIN, SERVICE_SCAN, data))
|
||||
@@ -10,6 +10,7 @@ import homeassistant.components.image_processing as ip
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, get_test_instance_port, assert_setup_component)
|
||||
from tests.components.image_processing import common
|
||||
|
||||
|
||||
class TestSetupImageProcessing:
|
||||
@@ -85,7 +86,7 @@ class TestImageProcessing:
|
||||
"""Grab an image from camera entity."""
|
||||
self.hass.start()
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.test')
|
||||
common.scan(self.hass, entity_id='image_processing.test')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test')
|
||||
@@ -100,7 +101,7 @@ class TestImageProcessing:
|
||||
"""Try to get image without exists camera."""
|
||||
self.hass.states.remove('camera.demo_camera')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.test')
|
||||
common.scan(self.hass, entity_id='image_processing.test')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test')
|
||||
@@ -152,7 +153,7 @@ class TestImageProcessingAlpr:
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.demo_alpr')
|
||||
@@ -171,8 +172,8 @@ class TestImageProcessingAlpr:
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.demo_alpr')
|
||||
@@ -195,7 +196,7 @@ class TestImageProcessingAlpr:
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_alpr')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.demo_alpr')
|
||||
@@ -254,7 +255,7 @@ class TestImageProcessingFace:
|
||||
"""Set up and scan a picture and test faces from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_face')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_face')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.demo_face')
|
||||
@@ -279,7 +280,7 @@ class TestImageProcessingFace:
|
||||
"""Set up and scan a picture and test faces from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.demo_face')
|
||||
common.scan(self.hass, entity_id='image_processing.demo_face')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.demo_face')
|
||||
|
||||
@@ -9,6 +9,7 @@ import homeassistant.components.microsoft_face as mf
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, load_fixture, mock_coro)
|
||||
from tests.components.image_processing import common
|
||||
|
||||
|
||||
class TestMicrosoftFaceDetectSetup:
|
||||
@@ -146,7 +147,7 @@ class TestMicrosoftFaceDetect:
|
||||
params={'returnFaceAttributes': "age,gender"}
|
||||
)
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test_local')
|
||||
|
||||
@@ -9,6 +9,7 @@ import homeassistant.components.microsoft_face as mf
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, load_fixture, mock_coro)
|
||||
from tests.components.image_processing import common
|
||||
|
||||
|
||||
class TestMicrosoftFaceIdentifySetup:
|
||||
@@ -150,7 +151,7 @@ class TestMicrosoftFaceIdentify:
|
||||
text=load_fixture('microsoft_face_identify.json')
|
||||
)
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test_local')
|
||||
|
||||
@@ -10,6 +10,7 @@ from homeassistant.components.image_processing.openalpr_cloud import (
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, load_fixture, mock_coro)
|
||||
from tests.components.image_processing import common
|
||||
|
||||
|
||||
class TestOpenAlprCloudSetup:
|
||||
@@ -160,7 +161,7 @@ class TestOpenAlprCloud:
|
||||
with patch('homeassistant.components.camera.async_get_image',
|
||||
return_value=mock_coro(
|
||||
camera.Image('image/jpeg', b'image'))):
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test_local')
|
||||
@@ -188,7 +189,7 @@ class TestOpenAlprCloud:
|
||||
with patch('homeassistant.components.camera.async_get_image',
|
||||
return_value=mock_coro(
|
||||
camera.Image('image/jpeg', b'image'))):
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
@@ -204,7 +205,7 @@ class TestOpenAlprCloud:
|
||||
with patch('homeassistant.components.camera.async_get_image',
|
||||
return_value=mock_coro(
|
||||
camera.Image('image/jpeg', b'image'))):
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
assert len(aioclient_mock.mock_calls) == 1
|
||||
|
||||
@@ -9,6 +9,7 @@ import homeassistant.components.image_processing as ip
|
||||
|
||||
from tests.common import (
|
||||
get_test_home_assistant, assert_setup_component, load_fixture)
|
||||
from tests.components.image_processing import common
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
@@ -146,7 +147,7 @@ class TestOpenAlprLocal:
|
||||
"""Set up and scan a picture and test plates from event."""
|
||||
aioclient_mock.get(self.url, content=b'image')
|
||||
|
||||
ip.scan(self.hass, entity_id='image_processing.test_local')
|
||||
common.scan(self.hass, entity_id='image_processing.test_local')
|
||||
self.hass.block_till_done()
|
||||
|
||||
state = self.hass.states.get('image_processing.test_local')
|
||||
|
||||
Reference in new issue
Block a user