Skip to content

Commit

Permalink
Merge pull request #1537 from Odianosen25/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Odianosen25 authored Jun 29, 2022
2 parents 5e7f435 + d695207 commit 34e5822
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
20 changes: 7 additions & 13 deletions appdaemon/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ def register_service(
name = kwargs.get("__name")
# first we confirm if the namespace exists
if name and namespace not in self.AD.state.state:
raise NamespaceException("Namespace %s, doesn't exist", namespace)
raise NamespaceException(f"Namespace {namespace}, doesn't exist")

elif not callable(callback):
raise ValueError("The given callback %s is not a callable function", callback)
raise ValueError(f"The given callback {callback} is not a callable function")

if namespace not in self.services:
self.services[namespace] = {}
Expand Down Expand Up @@ -87,12 +87,12 @@ def deregister_service(self, namespace: str, domain: str, service: str, **kwargs
raise ValueError("App must be given to deregister service call")

if name not in self.app_registered_services:
raise ValueError("The given App %s has no services registered", name)
raise ValueError(f"The given App {name} has no services registered")

app_service = f"{namespace}:{domain}:{service}"

if app_service not in self.app_registered_services[name]:
raise ValueError("The given App %s doesn't have the given service registered it", name)
raise ValueError(f"The given App {name} doesn't have the given service registered it")

# if it gets here, then time to deregister
with self.services_lock:
Expand Down Expand Up @@ -161,19 +161,13 @@ async def call_service(self, namespace: str, domain: str, service: str, data: di
name = data.pop("__name", None)

if namespace not in self.services:
raise NamespaceException("Unknown namespace (%s) in call_service from %s", namespace, name)
raise NamespaceException(f"Unknown namespace {namespace} in call_service from {name}")

if domain not in self.services[namespace]:
raise DomainException("Unknown domain (%s/%s) in call_service from %s", namespace, domain, name)
raise DomainException(f"Unknown domain ({namespace}/{domain}) in call_service from {name}")

if service not in self.services[namespace][domain]:
raise ServiceException(
"Unknown service (%s/%s/%s) in call_service from %s",
namespace,
domain,
service,
name,
)
raise ServiceException(f"Unknown service ({namespace}/{domain}/{service}) in call_service from {name}")

# If we have namespace in data it's an override for the domain of the eventual service call, as distinct
# from the namespace the call itself is executed from. e.g. set_state() is in the AppDaemon namespace but
Expand Down
1 change: 1 addition & 0 deletions docs/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Change Log
- Fixed issue when an entity is deleted from HA, and it remains in AD
- Fixed issue with setup file saying support "python3 3.0"
- Fixed issue with the inability to know which app's callback failed `constrain_state` check
- Fixed issue with AD giving messed up error messages
- Documentation fixes - contributed by `Rootie <https://github.com/Rootie>`__
- Documentation fixes - contributed by `Jakob Ruhe <https://github.com/jakeru>`__
- Documentation fixes - contributed by `illuzn <https://github.com/illuzn>`__
Expand Down

0 comments on commit 34e5822

Please sign in to comment.