Configurator support for entity_picture (#4028)
This commit is contained in:
parent
e2d23d902a
commit
89e8fb4066
6 changed files with 22 additions and 8 deletions
|
@ -8,7 +8,8 @@ the user has submitted configuration information.
|
|||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.const import EVENT_TIME_CHANGED, ATTR_FRIENDLY_NAME
|
||||
from homeassistant.const import EVENT_TIME_CHANGED, ATTR_FRIENDLY_NAME, \
|
||||
ATTR_ENTITY_PICTURE
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
|
||||
_INSTANCES = {}
|
||||
|
@ -36,7 +37,8 @@ STATE_CONFIGURED = 'configured'
|
|||
# pylint: disable=too-many-arguments
|
||||
def request_config(
|
||||
hass, name, callback, description=None, description_image=None,
|
||||
submit_caption=None, fields=None, link_name=None, link_url=None):
|
||||
submit_caption=None, fields=None, link_name=None, link_url=None,
|
||||
entity_picture=None):
|
||||
"""Create a new request for configuration.
|
||||
|
||||
Will return an ID to be used for sequent calls.
|
||||
|
@ -46,7 +48,7 @@ def request_config(
|
|||
request_id = instance.request_config(
|
||||
name, callback,
|
||||
description, description_image, submit_caption,
|
||||
fields, link_name, link_url)
|
||||
fields, link_name, link_url, entity_picture)
|
||||
|
||||
_REQUESTS[request_id] = instance
|
||||
|
||||
|
@ -104,7 +106,7 @@ class Configurator(object):
|
|||
def request_config(
|
||||
self, name, callback,
|
||||
description, description_image, submit_caption,
|
||||
fields, link_name, link_url):
|
||||
fields, link_name, link_url, entity_picture):
|
||||
"""Setup a request for configuration."""
|
||||
entity_id = generate_entity_id(ENTITY_ID_FORMAT, name, hass=self.hass)
|
||||
|
||||
|
@ -119,6 +121,7 @@ class Configurator(object):
|
|||
ATTR_CONFIGURE_ID: request_id,
|
||||
ATTR_FIELDS: fields,
|
||||
ATTR_FRIENDLY_NAME: name,
|
||||
ATTR_ENTITY_PICTURE: entity_picture,
|
||||
}
|
||||
|
||||
data.update({
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
@ -190,6 +190,7 @@ def request_configuration(host, hass, add_devices, filename,
|
|||
hass, "Philips Hue", hue_configuration_callback,
|
||||
description=("Press the button on the bridge to register Philips Hue "
|
||||
"with Home Assistant."),
|
||||
entity_picture="/static/images/logo_philips_hue.png",
|
||||
description_image="/static/images/config_philips_hue.jpg",
|
||||
submit_caption="I have pressed the button"
|
||||
)
|
||||
|
|
|
@ -183,7 +183,7 @@ def request_configuration(host, hass, add_devices_callback):
|
|||
_CONFIGURING[host] = configurator.request_config(
|
||||
hass, 'Plex Media Server', plex_configuration_callback,
|
||||
description=('Enter the X-Plex-Token'),
|
||||
description_image='/static/images/config_plex_mediaserver.png',
|
||||
entity_picture='/static/images/logo_plex_mediaserver.png',
|
||||
submit_caption='Confirm',
|
||||
fields=[{'id': 'token', 'name': 'X-Plex-Token', 'type': ''}]
|
||||
)
|
||||
|
|
|
@ -46,10 +46,20 @@ class TestConfigurator(unittest.TestCase):
|
|||
configurator.ATTR_DESCRIPTION_IMAGE: "config image url",
|
||||
configurator.ATTR_SUBMIT_CAPTION: "config submit caption",
|
||||
configurator.ATTR_FIELDS: [],
|
||||
configurator.ATTR_LINK_NAME: "link name",
|
||||
configurator.ATTR_LINK_URL: "link url",
|
||||
configurator.ATTR_ENTITY_PICTURE: "config entity picture",
|
||||
configurator.ATTR_CONFIGURE_ID: configurator.request_config(
|
||||
self.hass, "Test Request", lambda _: None,
|
||||
"config description", "config image url",
|
||||
"config submit caption"
|
||||
self.hass,
|
||||
name="Test Request",
|
||||
callback=lambda _: None,
|
||||
description="config description",
|
||||
description_image="config image url",
|
||||
submit_caption="config submit caption",
|
||||
fields=None,
|
||||
link_name="link name",
|
||||
link_url="link url",
|
||||
entity_picture="config entity picture",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue