Homex (homex v0.1.0)
View SourceConfiguration
You can configure Homex through a normal config entry like
import Config
config :homex,
broker: [host: "localhost", port: 1883],
entities: [MyEntity]The available options are documented in Homex.Config.
Usage
Define a module for the type of entity you want to use. The available types are:
defmodule MySwitch do
use Homex.Entity.Switch, name: "my-switch"
def handle_on(state) do
IO.puts("Switch turned on")
{:noreply, state}
end
def handle_off(state) do
IO.puts("Switch turned off")
{:noreply, state}
end
endConfigure broker and entities. Entities can also be added/removed at runtime with Homex.add_entity/1 or Homex.remove_entity/1.
import Config
config :homex,
entities: [MySwitch]Add homex to you supervision tree
defmodule MyApp.Application do
def start(_type, _args) do
children =
[
...,
Homex,
...
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end
Summary
Functions
Returns a specification to start this module under a supervisor.