diff --git a/conf/apps/globals.py b/conf/apps/globals.py index d0eb442..5db81e9 100644 --- a/conf/apps/globals.py +++ b/conf/apps/globals.py @@ -1,18 +1,22 @@ +import logging from enum import Enum -GLOBAL_VAR = "Hello, World!" +LOGGER = logging.getLogger('AppDaemon._globals') -def global_function(): - print('This is a global function.') +GLOBAL_VAR = 'Hello, World!' + + +def global_function() -> None: + LOGGER.info('This is a global function.') class GlobalClass: - def __init__(self): + def __init__(self) -> None: self.value = 'This is a global class instance.' - def display(self): - print(self.value) + def display(self) -> None: + LOGGER.info(self.value) class ModeSelect(Enum): diff --git a/conf/apps/simple_app/apps.yaml b/conf/apps/simple_app/apps.yaml index e940ecc..84f7db6 100644 --- a/conf/apps/simple_app/apps.yaml +++ b/conf/apps/simple_app/apps.yaml @@ -12,17 +12,16 @@ simple_app: # dependencies: # - hello_world - base_app: module: simple class: BaseApp -AppA: - module: app_a - class: AppA - dependencies: - - AppB # This is only set to demonstrate forcing it to load after AppB +# AppA: +# module: app_a +# class: AppA +# dependencies: +# - AppB # This is only set to demonstrate forcing it to load after AppB -AppB: - module: app_b - class: AppB \ No newline at end of file +# AppB: +# module: app_b +# class: AppB diff --git a/conf/apps/simple_app/hello.py b/conf/apps/simple_app/hello.py index e07badf..a7f8c9a 100644 --- a/conf/apps/simple_app/hello.py +++ b/conf/apps/simple_app/hello.py @@ -10,14 +10,15 @@ from appdaemon.adapi import ADAPI # fake/ # SimpleApp + class HelloWorld(ADAPI): - def initialize(self): + def initialize(self) -> None: self.log(f'{self.__class__.__name__} Initialized') self.log('+' * 50) # fake - self.register_service("my_domain/my_exciting_service", self.my_exciting_cb) + self.register_service('my_domain/my_exciting_service', self.my_exciting_cb) def my_exciting_cb(self, *args: str, my_arg: int = 0, **kwargs: Any) -> Any: namespace, domain, service = args - self.log(f"Service {domain}/{service} in the {namespace} namepsace called with {kwargs}") + self.log(f'Service {domain}/{service} in the {namespace} namepsace called with {kwargs}') return 999 + my_arg diff --git a/conf/apps/simple_app/simple.py b/conf/apps/simple_app/simple.py index c13cc8e..c550a4b 100644 --- a/conf/apps/simple_app/simple.py +++ b/conf/apps/simple_app/simple.py @@ -8,7 +8,7 @@ class SimpleApp(Hass): match self.ping(): case float() as ping: ping = utils.format_timedelta(ping) - self.log(f"{self.__class__.__name__} Initialized: {ping}") + self.log(f'{self.__class__.__name__} Initialized: {ping}') case _: pass @@ -17,5 +17,5 @@ class BaseApp(ADBase): def initialize(self) -> None: self.adapi = self.get_ad_api() self.log = self.adapi.log - self.hassapi = self.get_plugin_api("HASS") - assert isinstance(self.hassapi, Hass), "HASS API not available" + self.hassapi = self.get_plugin_api('HASS') + assert isinstance(self.hassapi, Hass), 'HASS API not available'