added food.meal
This commit is contained in:
19
conf/apps/food-repo/src/food/meal.py
Normal file
19
conf/apps/food-repo/src/food/meal.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from dataclasses import dataclass, field
|
||||
from typing import List
|
||||
|
||||
from appdaemon.adapi import ADAPI
|
||||
|
||||
from .eggs import Eggs
|
||||
from .ham import Ham
|
||||
|
||||
|
||||
class GreenEggs(Eggs):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Meal:
|
||||
dishes: List[ADAPI] = field(init=False)
|
||||
|
||||
def __post_init__(self):
|
||||
self.dishes = [GreenEggs, Ham]
|
||||
@@ -1,7 +1,10 @@
|
||||
from appdaemon.adapi import ADAPI
|
||||
|
||||
from food import Eggs
|
||||
from food.meal import Meal
|
||||
|
||||
|
||||
class Restaurant(ADAPI):
|
||||
def initialize(self):
|
||||
self.log(f'{self.__class__.__name__} initialized with {Eggs}')
|
||||
meal = Meal()
|
||||
eggs: Eggs = meal.dishes[0]
|
||||
self.log(f'{self.__class__.__name__} initialized with {eggs}')
|
||||
|
||||
Reference in New Issue
Block a user