Homex.Manager (homex v0.1.0)

View Source

Central manager for broker and entities.

The mananger is responsible to manage the communication with the MQTT broker and keeps track of all registered entities.

Summary

Functions

Adds multiple modules to the entities and updates the discovery config, so that Home Assistant also adds the entities. Returns a list of started modules.

Adds a module to the entities and updates the discovery config, so that Home Assistant also adds this entity.

Returns a specification to start this module under a supervisor.

Let's you publish additional messages to a topic

Removes a registered module from the entities and updates the discovery config, so that Home Assistant also removes this entity.

Types

pubopt()

@type pubopt() :: {:retain, boolean()} | {:qos, qos() | qos_name()}

qos()

@type qos() :: 0 | 1 | 2

qos_name()

@type qos_name() ::
  :qos0 | :at_most_once | :qos1 | :at_least_once | :qos2 | :exactly_once

Functions

add_entities(entities)

@spec add_entities([atom()]) :: [atom()]

Adds multiple modules to the entities and updates the discovery config, so that Home Assistant also adds the entities. Returns a list of started modules.

add_entity(module)

@spec add_entity(atom()) :: :ok | {:error, atom()}

Adds a module to the entities and updates the discovery config, so that Home Assistant also adds this entity.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

connected?()

@spec connected?() :: boolean()

publish(topic, payload, opts \\ [])

@spec publish(String.t(), binary() | map(), [pubopt()]) ::
  :ok | {:error, Jason.EncodeError.t() | Exception.t()}

Let's you publish additional messages to a topic

remove_entity(module)

@spec remove_entity(atom()) :: :ok | {:error, atom()}

Removes a registered module from the entities and updates the discovery config, so that Home Assistant also removes this entity.

start_link(config)