Homex.Entity.Button behaviour (homex v0.1.2)

Copy Markdown View Source

A button entity for Homex

Implements a Homex.Entity. See module for available callbacks.

https://www.home-assistant.io/integrations/button.mqtt/

Options

  • :name (String.t/0) - Required. the name of the entity

  • :enabled_by_default (boolean/0) - Flag which defines if the entity should be enabled when first added. The default value is true.

  • :device_class - The type/class of the button to set the icon in the frontend. The device_class can be nil. The default value is nil.

Example

defmodule MyButton do
  use Homex.Entity.Button, name: "my-button"

  def handle_press(entity) do
    IO.puts("my button was pressed")
    entity
  end
end

Summary

Callbacks

get's called when the button is pressed in Home Assistant

sets the buttons attributes

Callbacks

handle_press(entity)

@callback handle_press(entity :: Homex.Entity.t()) :: entity :: Homex.Entity.t()

get's called when the button is pressed in Home Assistant

set_attributes(entity, attributes)

@callback set_attributes(entity :: Homex.Entity.t(), attributes :: Map.t()) ::
  entity :: Homex.Entity.t()

sets the buttons attributes