mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-28 05:24:29 +00:00
Allow to set device specific occupancy_timeout. #27
This commit is contained in:
+1
-1
@@ -131,7 +131,7 @@ class Controller {
|
||||
// for e.g. click switches where we need to count number of clicks and detect long presses.
|
||||
converters.forEach((converter) => {
|
||||
const publish = (payload) => this.mqttPublishDeviceState(device.ieeeAddr, payload, converter.disableCache !== true);
|
||||
const payload = converter.convert(message, publish);
|
||||
const payload = converter.convert(message, publish, settings.getDevice(device.ieeeAddr));
|
||||
|
||||
if (payload) {
|
||||
publish(payload);
|
||||
|
||||
@@ -176,9 +176,10 @@ const parsers = [
|
||||
devices: ['RTCGQ01LM', 'RTCGQ11LM'],
|
||||
cid: 'msOccupancySensing',
|
||||
type: 'attReport',
|
||||
convert: (msg, publish) => {
|
||||
convert: (msg, publish, options) => {
|
||||
// The occupancy sensor only sends a message when motion detected.
|
||||
// Therefore we need to publish the no_motion detected by ourselves.
|
||||
const timeout = options.occupancy_timeout ? options.occupancy_timeout : occupancyTimeout;
|
||||
const deviceID = msg.endpoints[0].device.ieeeAddr;
|
||||
|
||||
// Stop existing timer because motion is detected and set a new one.
|
||||
@@ -190,7 +191,7 @@ const parsers = [
|
||||
store[deviceID] = setTimeout(() => {
|
||||
publish({occupancy: false})
|
||||
store[deviceID] = null;
|
||||
}, occupancyTimeout * 1000);
|
||||
}, timeout * 1000);
|
||||
return {occupancy: true};
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user