Source code for juham_automation.japp
from masterpiece import Application
from juham_core import Juham
from juham_systemstatus import SystemStatus
from .ts.forecast_ts import ForecastTs
from .ts.power_ts import PowerTs
from .ts.powerplan_ts import PowerPlanTs
from .ts.powermeter_ts import PowerMeterTs
from .ts.log_ts import LogTs
from .ts.energycostcalculator_ts import EnergyCostCalculatorTs
from .ts.electricityprice_ts import ElectricityPriceTs
from .automation.spothintafi import SpotHintaFi
from .automation.energycostcalculator import EnergyCostCalculator
[docs]
class JApp(Application):
"""Juham home automation application base class. Registers new plugin
group 'juham' on which general purpose Juham plugins can be written on.
"""
def __init__(self, name: str) -> None:
"""Creates home automation application with the given name.
If --enable_plugins is False create hard coded configuration
by calling instantiate_classes() method.
Args:
name (str): name for the application
"""
super().__init__(name, Juham(name))
[docs]
def instantiate_classes(self) -> None:
"""Instantiate automation classes .
Returns:
None
"""
self.add(ForecastTs())
self.add(PowerTs())
self.add(PowerPlanTs())
self.add(PowerMeterTs())
self.add(LogTs())
self.add(SpotHintaFi())
self.add(EnergyCostCalculator())
self.add(EnergyCostCalculatorTs())
self.add(ElectricityPriceTs())
# install plugins
self.add(self.instantiate_plugin_by_name("SystemStatus"))
self.add(self.instantiate_plugin_by_name("VisualCrossing"))
self.add(self.instantiate_plugin_by_name("OpenWeatherMap"))
[docs]
@classmethod
def register(cls) -> None:
"""Register plugin group `juham`."""
Application.register_plugin_group("juham")