# `Homex.Entity`
[🔗](https://github.com/kevinschweikert/homex/blob/v0.1.2/lib/homex/entity.ex#L1)

Defines the behaviour and struct for an entity implementation

# `t`

```elixir
@type t() :: %Homex.Entity{
  changes: map(),
  handlers: map(),
  keys: MapSet.t(),
  private: map(),
  values: map()
}
```

# `config`

```elixir
@callback config() :: map()
```

The Home Assistant component config definition

# `handle_init`

```elixir
@callback handle_init(entity :: t()) :: entity :: t()
```

Configures the intial state for the switch

# `handle_message`

```elixir
@callback handle_message(
  {topic :: String.t(), payload :: term()},
  entity :: t()
) :: entity :: t()
```

Handle a new message from the subscriptions

# `handle_timer`

```elixir
@callback handle_timer(entity :: Entity.t()) :: entity :: t()
```

If an `update_interval` is set, this callback will be fired

# `name`

```elixir
@callback name() :: String.t()
```

The given name of the entity

# `platform`

```elixir
@callback platform() :: String.t()
```

The Home Assistant platform

# `subscriptions`

```elixir
@callback subscriptions() :: [String.t()]
```

The list of topics to subscribe to

# `unique_id`

```elixir
@callback unique_id() :: String.t()
```

The unique id of the entity

# `get_private`

```elixir
@spec get_private(t(), atom()) :: term()
```

Gets the value from the Entity struct

# `implements_behaviour?`

```elixir
@spec implements_behaviour?(atom()) :: boolean()
```

Checks if the given module implements the behaviour from this module

# `put_private`

```elixir
@spec put_private(t(), atom(), term()) :: t()
```

Puts a value into the Entity struct to retrieve it later. Can be used as a key-value store for user data

---

*Consult [api-reference.md](api-reference.md) for complete listing*
