HomeElixir.DSL (HomeElixir v0.1.0)
View SourceEntry point for the Home Assistant Elixir DSL.
HomeElixir.DSL declares Home Assistant entities and automations as plain
Elixir code and materializes them into the YAML files Home Assistant reads
from its config/ directory. Generation happens at compile time: as soon
as a module using this DSL finishes compiling, its declarations are turned
into YAML on disk.
Usage
Add use HomeElixir.DSL to a module, then declare entity/2,3 and
automation/2 blocks:
defmodule MyHome.Switches do
use HomeElixir.DSL
entity :input_boolean, "test_switch" do
initial false
end
automation "notify when test switch turns on" do
trigger do
state do
affected_entities [{:input_boolean, "test_switch"}]
to true
end
end
action do
persistent_notification "create" do
message "The test switch is on"
end
end
end
endCompiling MyHome.Switches writes the declared entity and automation to
the folders configured under :home_elixir (see entity_folder and
automation_folder in your config/config.exs).
For the full set of supported entity types, trigger/condition/action
forms, and the helper functions generated for each entity, see
HomeElixir.DSL.Generation and the project README.
What gets injected
Using this DSL in a module also injects:
__home_elixir_entities__/0and__home_elixir_automations__/0— introspection helpers exposing what was declared.get_*/set_*helper functions for every declared entity, backed byHomeAssistantApiClient.restart_home_assistant/0.