ha: discovery refactoring

- retain setting
- generate topic and message in the discovery object instead of
creating them all at once
- re-implement relays, lights and sensors discovery
- rework name normalization, use relative magnitude indexes
- replace original lights code with schema: json, subscribe to a special
topic to handle lights instead of using the common API
(still wip - colors, hs, temperature settings)

resolve #630
resolve #1564
resolve #2403
This commit is contained in:
Maxim Prokhorov
2021-01-26 00:50:45 +03:00
parent 0b43af8ed9
commit 4d157ccd5b
26 changed files with 23234 additions and 23031 deletions

View File

@@ -109,6 +109,7 @@ Ticker _light_save_ticker;
unsigned long _light_report_delay = LIGHT_REPORT_DELAY;
Ticker _light_report_ticker;
LightReportListener _light_report;
bool _light_has_controls = false;
bool _light_has_color = false;
@@ -1452,6 +1453,12 @@ bool lightUseCCT() {
return _light_use_cct;
}
// -----------------------------------------------------------------------------
void lightSetReportListener(LightReportListener func) {
_light_report = func;
}
void _lightReport(int report) {
#if MQTT_SUPPORT
if (report & Light::Report::Mqtt) {
@@ -1474,6 +1481,10 @@ void _lightReport(int report) {
lightBroker();
}
#endif
if (_light_report) {
_light_report();
}
}
void _lightReport(Light::Report report) {