setState method

Future<void> setState(
  1. bool newState
)

Set the current state of the switch.

Implementation

Future<void> setState(bool newState) async {
  final newStateValue = newState ? 0xFF : 0x00;
  await commandHandler!.request(ZwRequest<void>(
    logger,
    id,
    buildSendDataRequest(id, [
      COMMAND_CLASS_SWITCH_BINARY,
      SWITCH_BINARY_SET,
      newStateValue,
    ]),
  ));
  state = newState;
  stateValue = newStateValue;
}