Config setting to opt-in to setting Plejd clock time
This commit is contained in:
parent
74716557c8
commit
fa0ba6be31
3 changed files with 28 additions and 19 deletions
|
|
@ -220,7 +220,11 @@ class PlejBLEHandler extends EventEmitter {
|
|||
this.emit('connected');
|
||||
|
||||
// Connected and authenticated, request current time and start ping
|
||||
this._requestCurrentPlejdTime();
|
||||
if (this.config.updatePlejdClock) {
|
||||
this._requestCurrentPlejdTime();
|
||||
} else {
|
||||
logger.info('Plejd clock updates disabled in configuration.');
|
||||
}
|
||||
this.startPing();
|
||||
this.startWriteQueue();
|
||||
|
||||
|
|
@ -668,7 +672,7 @@ class PlejBLEHandler extends EventEmitter {
|
|||
}
|
||||
|
||||
async _requestCurrentPlejdTime() {
|
||||
logger.info('Requesting current Plejd time...');
|
||||
logger.info('Requesting current Plejd clock time...');
|
||||
|
||||
// Eg: 0b0102001b: 0b: id, 0102: read, 001b: time
|
||||
const payload = Buffer.from(
|
||||
|
|
@ -943,10 +947,12 @@ class PlejBLEHandler extends EventEmitter {
|
|||
|| Math.abs(diffSeconds) > 60
|
||||
) {
|
||||
const plejdTime = new Date(plejdTimestampUTC);
|
||||
logger.debug(`Plejd time update ${plejdTime.toString()}, diff ${diffSeconds} seconds`);
|
||||
if (Math.abs(diffSeconds) > 60) {
|
||||
logger.debug(
|
||||
`Plejd clock time update ${plejdTime.toString()}, diff ${diffSeconds} seconds`,
|
||||
);
|
||||
if (this.config.updatePlejdClock && Math.abs(diffSeconds) > 60) {
|
||||
logger.warn(
|
||||
`Plejd time off by more than 1 minute. Reported time: ${plejdTime.toString()}, diff ${diffSeconds} seconds. Time will be set hourly.`,
|
||||
`Plejd clock time off by more than 1 minute. Reported time: ${plejdTime.toString()}, diff ${diffSeconds} seconds. Time will be set hourly.`,
|
||||
);
|
||||
if (this.connectedDevice && deviceId === this.connectedDevice.id) {
|
||||
const newLocalTimestamp = (now.getTime() - offsetSecondsGuess) / 1000;
|
||||
|
|
@ -965,7 +971,7 @@ class PlejBLEHandler extends EventEmitter {
|
|||
});
|
||||
}
|
||||
} else if (deviceId !== BLE_BROADCAST_DEVICE_ID) {
|
||||
logger.info('Got time response. Plejd time in sync with Home Assistant time');
|
||||
logger.info('Got time response. Plejd clock time in sync with Home Assistant time');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -121,20 +121,21 @@ The above is used to notify the add-on when Home Assistant has started successfu
|
|||
|
||||
The plugin needs you to configure some settings before working. You find these on the Add-on page after you've installed it.
|
||||
|
||||
| Parameter | Value |
|
||||
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| site | Name of your Plejd site, the name is displayed in the Plejd app (top bar). |
|
||||
| username | Username of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
|
||||
| password | Password of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
|
||||
| mqttBroker | URL of the MQTT Broker, eg. mqtt://localhost |
|
||||
| mqttUsername | Username of the MQTT broker |
|
||||
| mqttPassword | Password of the MQTT broker |
|
||||
| includeRoomsAsLights | Adds all rooms as lights, making it possible to turn on/off lights by room instead. Setting this to false will ignore all rooms. |
|
||||
| logLevel | Minimim log level. Supported values are `error`, `warn`, `info`, `debug`, `verbose`, `silly` with increasing amount of logging. Do not log more than `info` for production purposes. |
|
||||
| connectionTimeout | Number of seconds to wait when scanning and connecting. Might need to be tweaked on platforms other than RPi 4. Defaults to: 2 seconds. |
|
||||
| writeQueueWaitTime | Wait time between message sent to Plejd over BLE, defaults to 400. If that doesn't work, try changing the value higher in steps of 50. |
|
||||
| Parameter | Value |
|
||||
| -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| site | Name of your Plejd site, the name is displayed in the Plejd app (top bar). |
|
||||
| username | Username of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
|
||||
| password | Password of your Plejd account, this is used to fetch the crypto key and devices from the Plejd API. |
|
||||
| mqttBroker | URL of the MQTT Broker, eg. mqtt://localhost |
|
||||
| mqttUsername | Username of the MQTT broker |
|
||||
| mqttPassword | Password of the MQTT broker |
|
||||
| includeRoomsAsLights | Adds all rooms as lights, making it possible to turn on/off lights by room instead. Setting this to false will ignore all rooms. |
|
||||
| updatePlejdClock | Hourly update Plejd devices' clock if out of sync. Clock is used for time-based scenes. Not recommended if you have a Plejd gateway. Clock updates may flicker scene-controlled devices. |
|
||||
| logLevel | Minimim log level. Supported values are `error`, `warn`, `info`, `debug`, `verbose`, `silly` with increasing amount of logging. Do not log more than `info` for production purposes. |
|
||||
| connectionTimeout | Number of seconds to wait when scanning and connecting. Might need to be tweaked on platforms other than RPi 4. Defaults to: 2 seconds. |
|
||||
| writeQueueWaitTime | Wait time between message sent to Plejd over BLE, defaults to 400. If that doesn't work, try changing the value higher in steps of 50. |
|
||||
|
||||
## Having issues to get the addon working?
|
||||
## Troubleshooting
|
||||
|
||||
If you're having issues to get the addon working, there are a few things you can look into:
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
"mqttPassword": "",
|
||||
"includeRoomsAsLights": false,
|
||||
"preferCachedApiResponse": false,
|
||||
"updatePlejdClock": false,
|
||||
"logLevel": "info",
|
||||
"connectionTimeout": 2,
|
||||
"writeQueueWaitTime": 400
|
||||
|
|
@ -32,6 +33,7 @@
|
|||
"mqttPassword": "str",
|
||||
"includeRoomsAsLights": "bool",
|
||||
"preferCachedApiResponse": "bool",
|
||||
"updatePlejdClock": "bool",
|
||||
"logLevel": "list(error|warn|info|debug|verbose|silly)",
|
||||
"connectionTimeout": "int",
|
||||
"writeQueueWaitTime": "int"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue