# `Hassock.Registries`
[🔗](https://github.com/bbangert/hassock/blob/v0.3.0/lib/hassock/registries.ex#L1)

Fetch Home Assistant's floor, area, device, entity and label registries.

Each function sends the matching `config/*_registry/list` command through
`Hassock.Connection.command/4` and decodes the items into structs.
Options: `:timeout` in ms (default 30 s; the entity registry of a large
install is several MB).

`list_entities/2` uses `config/entity_registry/list`, which returns full
entries including `hidden_by` and `disabled_by`. HA's frontend uses the
compact `config/entity_registry/list_for_display` instead: it abbreviates
keys and leaves out disabled entities and some fields. Call it with
`Hassock.command/4` if you need it.

To keep the registries current, subscribe to their update events
(`Hassock.Protocol.registry_event_types/0`) or use `Hassock.RegistryCache`.

# `kind`

```elixir
@type kind() :: :floor | :area | :device | :entity | :label
```

# `decode`

```elixir
@spec decode(kind(), map()) :: struct()
```

Decode one registry item of `kind` into its struct.

# `id`

```elixir
@spec id(struct()) :: String.t()
```

The key that identifies an item of `kind`.

# `kinds`

```elixir
@spec kinds() :: [kind()]
```

The registry kinds, in dependency order (floors before areas, ...).

# `list`

```elixir
@spec list(GenServer.server(), kind(), keyword()) ::
  {:ok, [struct()]}
  | {:error, Hassock.Connection.command_error() | {:unexpected_result, term()}}
```

List one registry by kind.

# `list_areas`

```elixir
@spec list_areas(GenServer.server(), keyword()) ::
  {:ok, [Hassock.Area.t()]} | {:error, Hassock.Connection.command_error()}
```

List all areas.

# `list_devices`

```elixir
@spec list_devices(GenServer.server(), keyword()) ::
  {:ok, [Hassock.Device.t()]} | {:error, Hassock.Connection.command_error()}
```

List all devices.

# `list_entities`

```elixir
@spec list_entities(GenServer.server(), keyword()) ::
  {:ok, [Hassock.EntityEntry.t()]}
  | {:error, Hassock.Connection.command_error()}
```

List all entity registry entries.

# `list_floors`

```elixir
@spec list_floors(GenServer.server(), keyword()) ::
  {:ok, [Hassock.Floor.t()]} | {:error, Hassock.Connection.command_error()}
```

List all floors.

# `list_labels`

```elixir
@spec list_labels(GenServer.server(), keyword()) ::
  {:ok, [Hassock.Label.t()]} | {:error, Hassock.Connection.command_error()}
```

List all labels.

---

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