Compare commits
3 Commits
ce4ede51b1
...
475bdb9dd9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
475bdb9dd9 | ||
|
|
ba043554dc | ||
|
|
bd5c7ee339 |
@@ -4,5 +4,4 @@ logger = logging.getLogger('AppDaemon.Perimeter')
|
|||||||
logger.info('Imported statemachine')
|
logger.info('Imported statemachine')
|
||||||
|
|
||||||
|
|
||||||
class StateMachine:
|
class StateMachine: ...
|
||||||
...
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ from dataclasses import dataclass
|
|||||||
class Rule1:
|
class Rule1:
|
||||||
state: str
|
state: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Rule2:
|
class Rule2:
|
||||||
value: int
|
value: int
|
||||||
other: str = "default" # test changing this
|
other: str = 'default' # test changing this
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ from appdaemon.adapi import ADAPI
|
|||||||
|
|
||||||
|
|
||||||
class GrandParent(ADAPI):
|
class GrandParent(ADAPI):
|
||||||
def initialize(self):
|
def initialize(self) -> None:
|
||||||
self.log(f'{self.__class__.__name__} Initialized')
|
self.log(f'{self.__class__.__name__} Initialized')
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ from appdaemon.adapi import ADAPI
|
|||||||
|
|
||||||
|
|
||||||
class Parent(ADAPI):
|
class Parent(ADAPI):
|
||||||
def initialize(self):
|
def initialize(self) -> None:
|
||||||
self.log(f'{self.__class__.__name__} Initialized')
|
self.log(f'{self.__class__.__name__} Initialized')
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
from child import Child
|
from child import Child
|
||||||
|
|
||||||
|
|
||||||
class Sibling(Child):
|
class Sibling(Child):
|
||||||
def initialize(self):
|
def initialize(self) -> None:
|
||||||
self.log(f'{self.__class__.__name__} Initialized')
|
self.log(f'{self.__class__.__name__} Initialized')
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from typing import List
|
|
||||||
|
|
||||||
from .base import FoodItem
|
from .base import FoodItem
|
||||||
from .eggs import Eggs
|
from .eggs import Eggs
|
||||||
@@ -12,7 +11,7 @@ class GreenEggs(Eggs):
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Menu:
|
class Menu:
|
||||||
dishes: List[type[FoodItem]] = field(init=False)
|
dishes: list[type[FoodItem]] = field(init=False)
|
||||||
|
|
||||||
def __post_init__(self):
|
def __post_init__(self):
|
||||||
self.dishes = [GreenEggs, Ham]
|
self.dishes = [GreenEggs, Ham]
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ class Utensil(Enum):
|
|||||||
POT = auto()
|
POT = auto()
|
||||||
PAN = auto()
|
PAN = auto()
|
||||||
|
|
||||||
|
|
||||||
GLOBAL_VAR = Utensil.FORK
|
GLOBAL_VAR = Utensil.FORK
|
||||||
|
|||||||
0
conf/apps/food-repo/src/restaurant/__init__.py
Normal file
0
conf/apps/food-repo/src/restaurant/__init__.py
Normal file
@@ -5,7 +5,7 @@ from food.menu import Menu
|
|||||||
class Restaurant(ADAPI):
|
class Restaurant(ADAPI):
|
||||||
menu: Menu
|
menu: Menu
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self) -> None:
|
||||||
self.log(f'{self.__class__.__name__} initialized')
|
self.log(f'{self.__class__.__name__} initialized')
|
||||||
|
|
||||||
self.menu = Menu()
|
self.menu = Menu()
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
|
import logging
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
|
||||||
GLOBAL_VAR = "Hello, World!"
|
LOGGER = logging.getLogger('AppDaemon._globals')
|
||||||
|
|
||||||
|
|
||||||
def global_function():
|
GLOBAL_VAR = 'Hello, World!'
|
||||||
print('This is a global function.')
|
|
||||||
|
|
||||||
|
def global_function() -> None:
|
||||||
|
LOGGER.info('This is a global function.')
|
||||||
|
|
||||||
|
|
||||||
class GlobalClass:
|
class GlobalClass:
|
||||||
def __init__(self):
|
def __init__(self) -> None:
|
||||||
self.value = 'This is a global class instance.'
|
self.value = 'This is a global class instance.'
|
||||||
|
|
||||||
def display(self):
|
def display(self) -> None:
|
||||||
print(self.value)
|
LOGGER.info(self.value)
|
||||||
|
|
||||||
|
|
||||||
class ModeSelect(Enum):
|
class ModeSelect(Enum):
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ from typing import Any
|
|||||||
|
|
||||||
logger = logging.getLogger('AppDaemon.Perimeter')
|
logger = logging.getLogger('AppDaemon.Perimeter')
|
||||||
|
|
||||||
|
|
||||||
class HAL:
|
class HAL:
|
||||||
def __init__(self, *args: Any, **kwargs: Any):
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
logger.info('Logging from HAL')
|
logger.info('Logging from HAL')
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
CONSTANTS = {
|
CONSTANTS = {
|
||||||
'A': 1,
|
'A': 1,
|
||||||
'B': 2,
|
'B': 2,
|
||||||
'C': 3
|
'C': 3,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def utility_function():
|
def utility_function():
|
||||||
return 123, 456
|
return 123, 456
|
||||||
|
|||||||
@@ -12,17 +12,16 @@ simple_app:
|
|||||||
# dependencies:
|
# dependencies:
|
||||||
# - hello_world
|
# - hello_world
|
||||||
|
|
||||||
|
|
||||||
base_app:
|
base_app:
|
||||||
module: simple
|
module: simple
|
||||||
class: BaseApp
|
class: BaseApp
|
||||||
|
|
||||||
AppA:
|
# AppA:
|
||||||
module: app_a
|
# module: app_a
|
||||||
class: AppA
|
# class: AppA
|
||||||
dependencies:
|
# dependencies:
|
||||||
- AppB # This is only set to demonstrate forcing it to load after AppB
|
# - AppB # This is only set to demonstrate forcing it to load after AppB
|
||||||
|
|
||||||
AppB:
|
# AppB:
|
||||||
module: app_b
|
# module: app_b
|
||||||
class: AppB
|
# class: AppB
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ from appdaemon.adapi import ADAPI
|
|||||||
# fake/
|
# fake/
|
||||||
# SimpleApp
|
# SimpleApp
|
||||||
|
|
||||||
|
|
||||||
class HelloWorld(ADAPI):
|
class HelloWorld(ADAPI):
|
||||||
def initialize(self):
|
def initialize(self) -> None:
|
||||||
self.log(f'{self.__class__.__name__} Initialized')
|
self.log(f'{self.__class__.__name__} Initialized')
|
||||||
self.log('+' * 50)
|
self.log('+' * 50)
|
||||||
# fake
|
# 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:
|
def my_exciting_cb(self, *args: str, my_arg: int = 0, **kwargs: Any) -> Any:
|
||||||
namespace, domain, service = args
|
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
|
return 999 + my_arg
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class SimpleApp(Hass):
|
|||||||
match self.ping():
|
match self.ping():
|
||||||
case float() as ping:
|
case float() as ping:
|
||||||
ping = utils.format_timedelta(ping)
|
ping = utils.format_timedelta(ping)
|
||||||
self.log(f"{self.__class__.__name__} Initialized: {ping}")
|
self.log(f'{self.__class__.__name__} Initialized: {ping}')
|
||||||
case _:
|
case _:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -17,5 +17,5 @@ class BaseApp(ADBase):
|
|||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
self.adapi = self.get_ad_api()
|
self.adapi = self.get_ad_api()
|
||||||
self.log = self.adapi.log
|
self.log = self.adapi.log
|
||||||
self.hassapi = self.get_plugin_api("HASS")
|
self.hassapi = self.get_plugin_api('HASS')
|
||||||
assert isinstance(self.hassapi, Hass), "HASS API not available"
|
assert isinstance(self.hassapi, Hass), 'HASS API not available'
|
||||||
|
|||||||
25
ruff.toml
25
ruff.toml
@@ -1,14 +1,29 @@
|
|||||||
line-length = 88
|
line-length = 100
|
||||||
target-version = "py312"
|
target-version = "py312"
|
||||||
|
|
||||||
|
[format]
|
||||||
|
quote-style = "single"
|
||||||
|
indent-style = "space"
|
||||||
|
|
||||||
[lint]
|
[lint]
|
||||||
exclude = [
|
exclude = [
|
||||||
"conf/apps/simple_app/malformed.py"
|
"conf/apps/simple_app/malformed.py"
|
||||||
]
|
]
|
||||||
|
|
||||||
select = ["ALL"]
|
select = ["ALL"]
|
||||||
extend-ignore = ["ANN", "D", "E501", "COM812", "ERA001", "S101", "INP001"]
|
extend-ignore = [
|
||||||
|
"ANN",
|
||||||
|
"BLE001",
|
||||||
|
"COM812",
|
||||||
|
"D",
|
||||||
|
"E501",
|
||||||
|
"ERA001",
|
||||||
|
"INP001",
|
||||||
|
"S101",
|
||||||
|
]
|
||||||
|
|
||||||
[format]
|
|
||||||
quote-style = "single"
|
[lint.flake8-quotes]
|
||||||
indent-style = "space"
|
inline-quotes = "single"
|
||||||
|
docstring-quotes = "double"
|
||||||
|
multiline-quotes = "double"
|
||||||
|
|||||||
Reference in New Issue
Block a user