Homex.Entity.Sensor behaviour (homex v0.1.0)

View Source

A sensor entity for Homex

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

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

Options

Overridable Functions

The following functions can be overridden in your entity:

Default Implementations

All overridable functions have safe default implementations that return the entity unchanged. You only need to override the functions you want to customize.

Example

defmodule MyTemperature do
  use Homex.Entity.Sensor,
    name: "my-temperature",
    unit_of_measurement: "°C",
    device_class: "temperature"

  def handle_timer(entity) do
    value = Sensor.read()
    entity |> set_value(value)
  end
end

Summary

Callbacks

Sets the entity value

Callbacks

set_value(entity, value)

@callback set_value(entity :: Homex.Entity.t(), value :: term()) ::
  entity :: Homex.Entity.t()

Sets the entity value