mirror of
https://github.com/elisspace/core.git
synced 2026-10-03 07:49:57 +00:00
Change notify target property to be a dictionary (#3501)
* Change notify target property to be a dictionary * Make demo target properties unique and fix test to match behavior
This commit is contained in:
committed by
Paulus Schoutsen
parent
986873834a
commit
b3d67a7ed9
@@ -112,8 +112,8 @@ def setup(hass, config):
|
||||
|
||||
if hasattr(notify_service, 'targets'):
|
||||
platform_name = (p_config.get(CONF_NAME) or platform)
|
||||
for target in notify_service.targets:
|
||||
target_name = slugify("{}_{}".format(platform_name, target))
|
||||
for name, target in notify_service.targets.items():
|
||||
target_name = slugify("{}_{}".format(platform_name, name))
|
||||
targets[target_name] = target
|
||||
hass.services.register(DOMAIN, target_name,
|
||||
service_call_handler,
|
||||
|
||||
@@ -25,7 +25,7 @@ class DemoNotificationService(BaseNotificationService):
|
||||
@property
|
||||
def targets(self):
|
||||
"""Return a dictionary of registered targets."""
|
||||
return ["test target"]
|
||||
return {"test target name": "test target id"}
|
||||
|
||||
def send_message(self, message="", **kwargs):
|
||||
"""Send a message to a user."""
|
||||
|
||||
@@ -314,7 +314,10 @@ class HTML5NotificationService(BaseNotificationService):
|
||||
@property
|
||||
def targets(self):
|
||||
"""Return a dictionary of registered targets."""
|
||||
return self.registrations.keys()
|
||||
targets = {}
|
||||
for registration in self.registrations:
|
||||
targets[registration] = registration
|
||||
return targets
|
||||
|
||||
# pylint: disable=too-many-locals
|
||||
def send_message(self, message="", **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user