Improve MQTT behavior and add experimental parsing for color temp support from Plejd API (#298)
* Update underlying docker containers and dependencies. * Minor linting and code issues fixes * Update supported devices section * Improve Mqtt message properties - retain, etc. - Retain discovery messages - Don't retain others - Set QoS to 1 consistently to ensure at least once delivery - Set session timeout to ensure a reasonable TTL on messages * Code and logic to remove any retained mqtt messages for SET/STATE/AVAILABILITY * Temporary restructure of init flow for mqtt. - No longer wait for HA birth message - Don't listen to incoming messages until old retained messages have been purged. - More details in https://github.com/icanos/hassio-plejd/issues/218 * Fix lingering incorrect access of connectedDevice.id * Fix to avoid Home Assistant setting retain flag on MQTT SET STATE messages * Parse new TRAIT=15, assuming this means dimmable and tunable white * Clarify TRAITS bitmask values * Add experimental parsing for color temp support from Plejd API * Lint fixes * Remove null coalescing operator since we don't compile code * Handle case where outputSettings is null in PlejdApi * Solve MQTT errors due to deprecated api color_temp and unsupported removal of retained state messages
This commit is contained in:
parent
a789d913d7
commit
b3c6334f0c
10 changed files with 255 additions and 147 deletions
|
|
@ -42,7 +42,10 @@ const GATT_CHRC_ID = 'org.bluez.GattCharacteristic1';
|
|||
const PAYLOAD_POSITION_OFFSET = 5;
|
||||
const DIM_LEVEL_POSITION_OFFSET = 7;
|
||||
|
||||
const delay = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
|
||||
const delay = (timeout) =>
|
||||
new Promise((resolve) => {
|
||||
setTimeout(resolve, timeout);
|
||||
});
|
||||
|
||||
class PlejBLEHandler extends EventEmitter {
|
||||
adapter;
|
||||
|
|
@ -303,11 +306,14 @@ class PlejBLEHandler extends EventEmitter {
|
|||
|
||||
// After we've authenticated, we need to hook up the event listener
|
||||
// for changes to lastData.
|
||||
this.characteristics.lastDataProperties.on('PropertiesChanged', (
|
||||
iface,
|
||||
properties,
|
||||
// invalidated (third param),
|
||||
) => this._onLastDataUpdated(iface, properties));
|
||||
this.characteristics.lastDataProperties.on(
|
||||
'PropertiesChanged',
|
||||
(
|
||||
iface,
|
||||
properties,
|
||||
// invalidated (third param),
|
||||
) => this._onLastDataUpdated(iface, properties),
|
||||
);
|
||||
this.characteristics.lastData.StartNotify();
|
||||
this.consecutiveReconnectAttempts = 0;
|
||||
this.emit(PlejBLEHandler.EVENTS.connected);
|
||||
|
|
@ -657,7 +663,7 @@ class PlejBLEHandler extends EventEmitter {
|
|||
logger.info('Requesting current Plejd time...');
|
||||
|
||||
const payload = this._createHexPayload(
|
||||
this.connectedDevice.id,
|
||||
this.connectedDeviceId,
|
||||
BLE_CMD_TIME_UPDATE,
|
||||
'',
|
||||
BLE_REQUEST_RESPONSE,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue