enhomie.homie package#

Subpackages#

Submodules#

enhomie.homie.common module#

class enhomie.homie.common.HomieStage(state: Literal['poweron', 'nopower'] | None = None, color: str | Color | None = None, level: int | None = None)[source]#

Bases: object

Contain information about the parameters for the scene.

state: Literal['poweron', 'nopower'] | None = None#
color: Color | None = None#
level: int | None = None#

enhomie.homie.config module#

class enhomie.homie.config.HomieConfig(sargs: dict[str, Any] | None = None, files: str | Path | list[str | Path] | list[str] | list[Path] | tuple[str | Path, ...] | set[str] | None = None, cargs: dict[str, Any] | None = None)[source]#

Bases: Config

Contain the configurations from the arguments and files.

Parameters:
  • sargs – Additional arguments on the command line.

  • files – Complete or relative path to config files.

  • cargs – Configuration arguments in dictionary form, which will override contents from the config files.

property params: HomieParams#

Return the Pydantic model containing the configuration.

Warning

This method completely overrides the parent but is based on that code, would be unfortunate if upstream changes meant this breaks or breaks something else.

Returns:

Pydantic model containing the configuration.

merge_params() None[source]#

Update the Pydantic model containing the configuration.

enhomie.homie.homie module#

class enhomie.homie.homie.Homie(config: HomieConfig)[source]#

Bases: object

Interact with supported devices to ensure desired state.

Parameters:

config – Primary class instance for configuration.

property config: HomieConfig#

Return the Config instance containing the configuration.

Returns:

Config instance containing the configuration.

property logger: HomieLogger#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property jinja2: HomieJinja2#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property childs: HomieChilds#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property persist: HomiePersist#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property params: HomieParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property console: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property debug: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property dryrun: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property forced: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property desired: HomieDesired#

Return the related actions matching the provided event.

Returns:

Related actions matching the provided event.

property aspired: HomieAspired#

Return the related desired state for the desired groups.

Returns:

Related desired state for the desired groups.

refresh(timeout: int | None = None) bool[source]#

Refresh the cached information for the remote upstream.

Parameters:

timeout – Timeout waiting for the server response.

Returns:

Boolean indicating the success of the refresh.

property dumped: dict[str, Any]#

Return the facts about the attributes from the instance.

Returns:

Facts about the attributes from the instance.

printer(source: HomiePrint, color: int = 6) None[source]#

Print the contents for the object within Homie instance.

Parameters:
  • source – Content which will be shown after header.

  • color – Override the color used for box character.

get_actions(target: HomieActionNode, *, state: HomieState | None = None, color: str | None = None, level: int | None = None, scene: HomieScene | None = None, force: bool = False, change: bool = True) HomieActionBase[source]#

Insert the new item containing information for operation.

Parameters:
  • target – Device or group settings will be updated.

  • state – Determine the state related to the target.

  • color – Determine the color related to the target.

  • level – Determine the level related to the target.

  • scene – Determine the scene related to the target.

  • force – Override the default for full idempotency.

  • change – Determine whether the change is executed.

set_actions(aitems: HomieActionBase, force: bool = False, change: bool = True) bool[source]#

Insert the new item containing information for operation.

Parameters:
  • aitems – Constructed action objects for operation.

  • force – Override the default for full idempotency.

  • change – Determine whether the change is executed.

Returns:

Boolean indicating whether or not was changed.

j2parse(value: Any, statics: dict[str, Any] | None = None, literal: bool = True) Any[source]#

Return the provided input using the Jinja2 environment.

Parameters:
  • value – Input that will be processed and returned.

  • statics – Additional values available for parsing.

  • literal – Determine if Python objects are evaled.

Returns:

Provided input using the Jinja2 environment.

enhomie.homie.models module#

class enhomie.homie.models.HomieModels[source]#

Bases: object

Return the class object that was imported within method.

classmethod homie() Type[HomieParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod printer() Type[HomiePrinterParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod service() Type[HomieServiceParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod builtins() Type[BltnModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod hubitat() Type[HubiModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod philips() Type[PhueModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod ubiquiti() Type[UbiqModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod child() Type[HomieChildParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod origin() Type[HomieOriginParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod device() Type[HomieDeviceParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod group() Type[HomieGroupParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod scene() Type[HomieSceneParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod desire() Type[HomieDesireParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod aspire() Type[HomieAspireParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod plugin() Type[HomiePluginParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod occur() Type[HomieOccurParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod where() Type[HomieWhereParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod stage() Type[HomieStage][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod queue() Type[HomieQueueItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod thread() Type[HomieThreadItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod action() Type[HomieActionItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod update() Type[HomieUpdateItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod stream() Type[HomieStreamItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod desired() Type[HomieDesiredItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod aspired() Type[HomieAspiredItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

enhomie.homie.service module#

class enhomie.homie.service.HomieService(homie: Homie)[source]#

Bases: object

Multi-threaded service for processing the desired state.

Parameters:

homie – Primary class instance for Homie Automate.

property homie: Homie#

Return the Homie instance to which the instance belongs.

Returns:

Homie instance to which the instance belongs.

property params: HomieServiceParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property actions: HomieActions | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property updates: HomieUpdates | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property streams: HomieStreams | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property restful: HomieRestful | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property running: list[str]#

Return the list of threads which are determined running.

Returns:

List of threads which are determined running.

property zombies: list[str]#

Return the list of threads which are determined zombies.

Returns:

List of threads which are determined zombies.

property congest: list[tuple[str, int]]#

Return the list of congested threads and members queues.

Returns:

List of congested threads and members queues.

property enqueue: list[tuple[str, int]]#

Return the list of congested threads and members queues.

Returns:

List of congested threads and members queues.

start() None[source]#

Start the various threads within the Homie class object.

operate() None[source]#

Perform the operation related to Homie service members.

operate_updates() None[source]#

Perform the operation related to Homie service members.

operate_streams() None[source]#

Perform the operation related to Homie service members.

operate_healths() None[source]#

Perform the operation related to Homie service members.

check_zombies() bool[source]#

Return the boolean indicating while threads are zombies.

Returns:

Boolean indicating while threads are zombies.

check_congest() bool[source]#

Return the boolean indicating when queues are congested.

Returns:

Boolean indicating when queues are congested.

soft(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.

stop(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.

Module contents#

class enhomie.homie.Homie(config: HomieConfig)[source]#

Bases: object

Interact with supported devices to ensure desired state.

Parameters:

config – Primary class instance for configuration.

property config: HomieConfig#

Return the Config instance containing the configuration.

Returns:

Config instance containing the configuration.

property logger: HomieLogger#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property jinja2: HomieJinja2#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property childs: HomieChilds#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property persist: HomiePersist#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property params: HomieParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property console: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property debug: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property dryrun: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property forced: bool#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property desired: HomieDesired#

Return the related actions matching the provided event.

Returns:

Related actions matching the provided event.

property aspired: HomieAspired#

Return the related desired state for the desired groups.

Returns:

Related desired state for the desired groups.

refresh(timeout: int | None = None) bool[source]#

Refresh the cached information for the remote upstream.

Parameters:

timeout – Timeout waiting for the server response.

Returns:

Boolean indicating the success of the refresh.

property dumped: dict[str, Any]#

Return the facts about the attributes from the instance.

Returns:

Facts about the attributes from the instance.

printer(source: HomiePrint, color: int = 6) None[source]#

Print the contents for the object within Homie instance.

Parameters:
  • source – Content which will be shown after header.

  • color – Override the color used for box character.

get_actions(target: HomieActionNode, *, state: HomieState | None = None, color: str | None = None, level: int | None = None, scene: HomieScene | None = None, force: bool = False, change: bool = True) HomieActionBase[source]#

Insert the new item containing information for operation.

Parameters:
  • target – Device or group settings will be updated.

  • state – Determine the state related to the target.

  • color – Determine the color related to the target.

  • level – Determine the level related to the target.

  • scene – Determine the scene related to the target.

  • force – Override the default for full idempotency.

  • change – Determine whether the change is executed.

set_actions(aitems: HomieActionBase, force: bool = False, change: bool = True) bool[source]#

Insert the new item containing information for operation.

Parameters:
  • aitems – Constructed action objects for operation.

  • force – Override the default for full idempotency.

  • change – Determine whether the change is executed.

Returns:

Boolean indicating whether or not was changed.

j2parse(value: Any, statics: dict[str, Any] | None = None, literal: bool = True) Any[source]#

Return the provided input using the Jinja2 environment.

Parameters:
  • value – Input that will be processed and returned.

  • statics – Additional values available for parsing.

  • literal – Determine if Python objects are evaled.

Returns:

Provided input using the Jinja2 environment.

class enhomie.homie.HomieConfig(sargs: dict[str, Any] | None = None, files: str | Path | list[str | Path] | list[str] | list[Path] | tuple[str | Path, ...] | set[str] | None = None, cargs: dict[str, Any] | None = None)[source]#

Bases: Config

Contain the configurations from the arguments and files.

Parameters:
  • sargs – Additional arguments on the command line.

  • files – Complete or relative path to config files.

  • cargs – Configuration arguments in dictionary form, which will override contents from the config files.

property params: HomieParams#

Return the Pydantic model containing the configuration.

Warning

This method completely overrides the parent but is based on that code, would be unfortunate if upstream changes meant this breaks or breaks something else.

Returns:

Pydantic model containing the configuration.

merge_params() None[source]#

Update the Pydantic model containing the configuration.

class enhomie.homie.HomieModels[source]#

Bases: object

Return the class object that was imported within method.

classmethod homie() Type[HomieParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod printer() Type[HomiePrinterParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod service() Type[HomieServiceParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod builtins() Type[BltnModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod hubitat() Type[HubiModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod philips() Type[PhueModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod ubiquiti() Type[UbiqModels][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod child() Type[HomieChildParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod origin() Type[HomieOriginParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod device() Type[HomieDeviceParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod group() Type[HomieGroupParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod scene() Type[HomieSceneParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod desire() Type[HomieDesireParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod aspire() Type[HomieAspireParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod plugin() Type[HomiePluginParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod occur() Type[HomieOccurParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod where() Type[HomieWhereParams][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod stage() Type[HomieStage][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod queue() Type[HomieQueueItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod thread() Type[HomieThreadItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod action() Type[HomieActionItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod update() Type[HomieUpdateItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod stream() Type[HomieStreamItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod desired() Type[HomieDesiredItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

classmethod aspired() Type[HomieAspiredItem][source]#

Return the class object that was imported within method.

Returns:

Class object that was imported within method.

class enhomie.homie.HomieService(homie: Homie)[source]#

Bases: object

Multi-threaded service for processing the desired state.

Parameters:

homie – Primary class instance for Homie Automate.

property homie: Homie#

Return the Homie instance to which the instance belongs.

Returns:

Homie instance to which the instance belongs.

property params: HomieServiceParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property actions: HomieActions | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property updates: HomieUpdates | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property streams: HomieStreams | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property restful: HomieRestful | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

property running: list[str]#

Return the list of threads which are determined running.

Returns:

List of threads which are determined running.

property zombies: list[str]#

Return the list of threads which are determined zombies.

Returns:

List of threads which are determined zombies.

property congest: list[tuple[str, int]]#

Return the list of congested threads and members queues.

Returns:

List of congested threads and members queues.

property enqueue: list[tuple[str, int]]#

Return the list of congested threads and members queues.

Returns:

List of congested threads and members queues.

start() None[source]#

Start the various threads within the Homie class object.

operate() None[source]#

Perform the operation related to Homie service members.

operate_updates() None[source]#

Perform the operation related to Homie service members.

operate_streams() None[source]#

Perform the operation related to Homie service members.

operate_healths() None[source]#

Perform the operation related to Homie service members.

check_zombies() bool[source]#

Return the boolean indicating while threads are zombies.

Returns:

Boolean indicating while threads are zombies.

check_congest() bool[source]#

Return the boolean indicating when queues are congested.

Returns:

Boolean indicating when queues are congested.

soft(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.

stop(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.