0.17.0 release - improve startup and fix color temp (#324)

* Add working support for color temperature

* Lint fixes

* Fix to config json version to make it build

* Clean up and BLE constants and prepare for lightlevel UUID

* Eagerly send HA discovery, standardize colorTemp, clean up MQTT subscribe

* Fix typo in MqttClient

* Listen to HA birth messages to make devices available after HA restart

- Extract constants to common file

* Prepare for 0.17.0 release
This commit is contained in:
Victor 2025-09-12 08:36:02 +02:00 committed by GitHub
parent d801410200
commit 1766afb2e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 650 additions and 165 deletions

View file

@ -1,4 +1,4 @@
const EventEmitter = require('events');
const { EventEmitter } = require('events');
const Configuration = require('./Configuration');
const Logger = require('./Logger');
@ -55,6 +55,15 @@ class PlejdAddon extends EventEmitter {
process.on(signal, this.processCleanupFunc);
});
// Eagerly send discovery as soon as possible
try {
logger.verbose('Eagerly sending discovery to Home Assistant.');
this.mqttClient.sendDiscoveryToHomeAssistant();
} catch (err) {
logger.error('Error in eager discovery send', err);
}
// Send discovery again on MQTT connect to ensure Home Assistant receives device info after reconnects or broker restarts.
this.mqttClient.on(MqttClient.EVENTS.connected, () => {
try {
logger.verbose('connected to mqtt.');
@ -72,7 +81,7 @@ class PlejdAddon extends EventEmitter {
try {
const { uniqueId } = device;
if (device.typeName === 'Scene') {
if (device.typeName === MqttClient.DEVICE_TYPES.SCENE) {
// we're triggering a scene, lets do that and jump out.
// since scenes aren't "real" devices.
this.sceneManager.executeScene(uniqueId);
@ -93,7 +102,7 @@ class PlejdAddon extends EventEmitter {
if (typeof command === 'string') {
// switch command
state = command === 'ON';
state = command === MqttClient.STATE.ON;
commandObj = {
state,
};
@ -106,7 +115,7 @@ class PlejdAddon extends EventEmitter {
});
} else {
// eslint-disable-next-line prefer-destructuring
state = command.state === 'ON';
state = command.state === MqttClient.STATE.ON;
commandObj = command;
}