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:
Robbie Trencheny
2016-09-25 09:41:11 -07:00
committed by Paulus Schoutsen
parent 986873834a
commit b3d67a7ed9
4 changed files with 10 additions and 7 deletions
+2 -2
View File
@@ -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,
+1 -1
View File
@@ -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."""
+4 -1
View File
@@ -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):