MQTT light support unknown state (#21419)

This commit is contained in:
Jan Bouwhuis 2022-02-03 16:52:44 +01:00 committed by GitHub
parent 5f240a53f4
commit fa4ba2f8b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,18 +13,18 @@ The `mqtt` light platform lets you control your MQTT enabled lights through one
## Comparison of light MQTT schemas ## Comparison of light MQTT schemas
| Function | [`default`](#default-schema) | [`json`](#json-schema) | [`template`](#template-schema) | | Function | [`default`](#default-schema) | [`json`](#json-schema) | [`template`](#template-schema) |
|-------------------|------------------------------------------------------------|----------------------------------------------------------------------|------------------------------------------------------------------------------| | ----------------- | ---------------------------- | ---------------------- | ------------------------------ |
| Brightness | ✔ | ✔ | ✔ | | Brightness | ✔ | ✔ | ✔ |
| Color mode | ✔ | ✔ | ✘ | | Color mode | ✔ | ✔ | ✘ |
| Color temperature | ✔ | ✔ | ✔ | | Color temperature | ✔ | ✔ | ✔ |
| Effects | ✔ | ✔ | ✔ | | Effects | ✔ | ✔ | ✔ |
| Flashing | ✘ | ✔ | ✔ | | Flashing | ✘ | ✔ | ✔ |
| HS Color | ✔ | ✔ | ✔ | | HS Color | ✔ | ✔ | ✔ |
| RGB Color | ✔ | ✔ | ✔ | | RGB Color | ✔ | ✔ | ✔ |
| RGBW Color | ✔ | ✔ | ✘ | | RGBW Color | ✔ | ✔ | ✘ |
| RGBWW Color | ✔ | ✔ | ✘ | | RGBWW Color | ✔ | ✔ | ✘ |
| Transitions | ✘ | ✔ | ✔ | | Transitions | ✘ | ✔ | ✔ |
| XY Color | ✔ | ✔ | ✘ | | XY Color | ✔ | ✔ | ✘ |
## Default schema ## Default schema
@ -33,9 +33,9 @@ The `mqtt` light platform with default schema lets you control your MQTT enabled
## Default schema - Configuration ## Default schema - Configuration
In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with a `RETAIN` flag, the MQTT light will receive an instant state update after subscription and will start with the correct state. Otherwise, the initial state of the switch will be `false` / `off`. In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with a `RETAIN` flag, the MQTT light will receive an instant state update after subscription and will start with the correct state. Otherwise, the initial state of the switch will be `unknown`. A MQTT device can reset the current state to `unknown` using a `None` payload.
When a state topic is not available, the light will work in optimistic mode. In this mode, the light will immediately change state after every command. Otherwise, the light will wait for state confirmation from the device (message from `state_topic`). When a state topic is not available, the light will work in optimistic mode. In this mode, the light will immediately change state after every command. Otherwise, the light will wait for state confirmation from the device (message from `state_topic`). The initial state is set to `False` / `off` in optimistic mode.
Optimistic mode can be forced, even if the `state_topic` is available. Try to enable it, if experiencing incorrect light operation. Optimistic mode can be forced, even if the `state_topic` is available. Try to enable it, if experiencing incorrect light operation.