### Install jeedomdaemon via pip Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Install the library manually using pip. ```bash pip3 install jeedomdaemon ``` -------------------------------- ### Install jeedomdaemon via requirements.txt Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Specify the library and version in your requirements.txt file. ```txt jeedomdaemon~=1.2.0 ``` -------------------------------- ### Install jeedomdaemon via Jeedom packages.json Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Add the library to your Jeedom core packages.json for installation. ```json { "pre-install": {}, "apt": {}, "pip3": { "jeedomdaemon": {} }, "npm": {}, "yarn": {}, "plugin": {}, "post-install": {} } ``` -------------------------------- ### Daemon with Callbacks Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Implement on_start, on_message, and on_stop callbacks for custom daemon behavior during its lifecycle. Ensure to call the superclass constructor. ```python from jeedomdaemon import BaseDaemon class MyDaemon(BaseDaemon): def __init__(self) -> None: # Standard initialisation super().__init__(on_start_cb=self.on_start, on_message_cb=self.on_message, on_stop_cb=self.on_stop) # Add here any initialisation your daemon would need async def on_start(self): """ This method will be called when your daemon starts. This is the place where you should create your tasks, login to remote system, etc """ # if you don't have specific action to do on start, do not create this method pass async def on_message(self, message: list): """ This function will be called once a message is received from Jeedom; check on api key is done already, just care about your logic You must implement the different actions that your daemon can handle. """ pass async def on_stop(self): """ This callback will be called when the daemon needs to stop` You need to close your remote connexions and cancel background tasks if any here. """ # if you don't have specific action to do on stop, do not create this method pass MyDaemon().run() ``` -------------------------------- ### Basic Daemon Skeleton Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Create a minimal daemon by inheriting from BaseDaemon and running it. This provides basic communication capabilities. ```python from jeedomdaemon import BaseDaemon class MyDaemon(BaseDaemon): pass MyDaemon().run() ``` -------------------------------- ### Custom Daemon Configuration Source: https://github.com/mips2648/jeedom-daemon-py/blob/main/README.md Define a custom configuration class by inheriting from BaseConfig to add specific arguments like user and password. Provide this custom config class during BaseDaemon initialization. ```python from jeedomdaemon import BaseDaemon from jeedomdaemon import BaseConfig class DemoConfig(BaseConfig): """This is where you declare your custom argument/configuration Remember that all usual arguments are managed by the BaseConfig class already so you only have to take care of yours; e.g. user & password in this case """ def __init__(self): super().__init__() self.add_argument("--user", type=str, default='Harrison') self.add_argument("--password", type=str) class MyDaemon(BaseDaemon): def __init__(self) -> None: # provide your custom config class during init super().__init__(config=DemoConfig(), on_start_cb=...) # ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.