Table of Contents

Class BinarySensor

Namespace
HaMqttDiscoverable.Entities
Assembly
HaMqttDiscoverable.dll

A read-only two-state value reported to Home Assistant, e.g. a door sensor or a motion detector.

public sealed class BinarySensor : HaEntity<BinarySensorConfig>, IAsyncDisposable
Inheritance
BinarySensor
Implements
Inherited Members

Constructors

BinarySensor(HaMqttConnection, BinarySensorConfig)

Creates a binary sensor from the given config.

public BinarySensor(HaMqttConnection connection, BinarySensorConfig config)

Parameters

connection HaMqttConnection
config BinarySensorConfig

Methods

PublishStateAsync(bool, bool, CancellationToken)

Publishes the sensor's "on"/"off" state.

public Task PublishStateAsync(bool isOn, bool retain = true, CancellationToken cancellationToken = default)

Parameters

isOn bool
retain bool
cancellationToken CancellationToken

Returns

Task