added support for DIM-02 and to detect dim func
This commit is contained in:
parent
bedcd550ad
commit
457b41cb3c
2 changed files with 41 additions and 8 deletions
14
mqtt.js
14
mqtt.js
|
|
@ -33,7 +33,7 @@ const getBrightnessCommandTopic = plug => `${getPath(plug)}/setBrightness`;
|
|||
const getBrightnessTopic = plug => `${getPath(plug)}/brightness`;
|
||||
const getCommandTopic = plug => `${getPath(plug)}/set`;
|
||||
|
||||
const getDiscoveryPayload = device => ({
|
||||
const getDiscoveryDimmablePayload = device => ({
|
||||
name: device.name,
|
||||
unique_id: `light.plejd.${device.name.toLowerCase().replace(/ /g, '')}`,
|
||||
state_topic: getStateTopic(device),
|
||||
|
|
@ -45,6 +45,16 @@ const getDiscoveryPayload = device => ({
|
|||
optimistic: false
|
||||
});
|
||||
|
||||
const getDiscoveryPayload = device => ({
|
||||
name: device.name,
|
||||
unique_id: `light.plejd.${device.name.toLowerCase().replace(/ /g, '')}`,
|
||||
state_topic: getStateTopic(device),
|
||||
command_topic: getCommandTopic(device),
|
||||
payload_on: 1,
|
||||
payload_off: 0,
|
||||
optimistic: false
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
class MqttClient extends EventEmitter {
|
||||
|
|
@ -124,7 +134,7 @@ class MqttClient extends EventEmitter {
|
|||
devices.forEach((device) => {
|
||||
logger(`sending discovery for ${device.name}`);
|
||||
|
||||
const payload = getDiscoveryPayload(device);
|
||||
const payload = device.supportsDim ? getDiscoveryDimmablePayload(device) : getDiscoveryPayload(device);
|
||||
self.deviceMap[device.id] = payload.unique_id;
|
||||
|
||||
self.client.publish(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue