Search documentation of grizzly

# View Source Grizzly.SwitchBinary (grizzly v7.4.2)

Commands for working with devices that support the Switch Binary command class

# Summary

## Types

report()

The report received after requesting the state fo the switch using the `get/1` function.

set_opt()

Optional parameters used when setting the switch state

set_value()

The value the switch's state can be set to

## Functions

get(node_id, command_opts \\ [])

Request the current state of the switch

set(node_id, target_value, opts \\ [])

Set the target value of the binary switch

# Types

Link to this type

# report()

View Source

    @type report() :: %{
      target_value: Grizzly.ZWave.Commands.SwitchBinaryReport.value(),
      current_value: Grizzly.ZWave.Commands.SwitchBinaryReport.value() | nil,
      duration: byte() | nil,
      version: 1 | 2
    }

The report received after requesting the state fo the switch using the `get/1` function.

Link to this type

# set_opt()

View Source

    @type set_opt() :: {:duration, non_neg_integer()}

Optional parameters used when setting the switch state

- `:duration` - the duration that the transition from current state to target state should take (version 2).

Link to this type

# set_value()

View Source

    @type set_value() :: :on | :off

The value the switch's state can be set to

# Functions

Link to this function

# get(node_id, command_opts \\ [])

View Source

    @spec get(Grizzly.ZWave.node_id(), [Grizzly.command_opt()]) ::
      {:ok, report()}
      | {:queued, reference(), non_neg_integer()}
      | {:error,
         :timeout | :including | :updating_firmware | :nack_response | any()}

Request the current state of the switch

This command will return a `report()` in response.

Link to this function

# set(node_id, target_value, opts \\ [])

View Source

    @spec set(Grizzly.ZWave.node_id(), set_value(), [set_opt() | Grizzly.command_opt()]) ::
      :ok
      | {:queued, reference(), non_neg_integer()}
      | {:error,
         :timeout | :including | :updating_firmware | :nack_response | any()}

Set the target value of the binary switch

Devices that support version 2 of the switch binary command class and optionally be passed a duration that specifies the duration of the transition from the current value to the target value.