Skip to content

Commit

Permalink
Improve support current supported devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Apr 23, 2018
1 parent e7b4cb3 commit 54ca2dd
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ class Controller {

const device = message.endpoints[0].device;

if (!device) {
logger.warn('Message without device!');
return;
}

// Check if this is a new device.
if (!settings.getDevice(device.ieeeAddr)) {
logger.info(`New device with address ${device.ieeeAddr} connected!`);
Expand Down
10 changes: 5 additions & 5 deletions lib/converters/zigbee2mqtt.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ const parsers = [
}

store[deviceID] = setTimeout(() => {
publish({occupancy: 'no_motion'})
publish({occupancy: false})
store[deviceID] = null;
}, noMotionTimeout * 60 * 1000);
return {occupancy: 'motion'};
return {occupancy: true};
}
},
{
devices: ['MCCGQ01LM', 'MCCGQ11LM'],
cid: 'genOnOff',
type: 'attReport',
convert: (msg) => {return {state: msg.data.data['onOff'] ? 'open' : 'closed'}}
convert: (msg) => {return {contact: msg.data.data['onOff'] === 0}}
},
{
devices: ['LED1545G12', '7146060PH', 'LED1537R6'],
Expand Down Expand Up @@ -188,13 +188,13 @@ const parsers = [

// Ignore parsers (these message dont need parsing).
{
devices: ['WXKG11LM', 'MCCGQ11LM'],
devices: ['WXKG11LM', 'MCCGQ11LM', 'MCCGQ01LM', 'WXKG01LM', 'LED1545G12', '7146060PH', 'LED1537R6'],
cid: 'genOnOff',
type: 'devChange',
convert: () => null
},
{
devices: ['WXKG11LM', 'MCCGQ11LM', 'RTCGQ11LM', 'WSDCGQ11LM', 'SJCGQ11LM'],
devices: ['WXKG11LM', 'MCCGQ11LM', 'RTCGQ11LM', 'WSDCGQ11LM', 'SJCGQ11LM', 'MCCGQ01LM', 'RTCGQ01LM', 'WXKG01LM', 'WSDCGQ01LM'],
cid: 'genBasic',
type: 'devChange',
convert: () => null
Expand Down
8 changes: 4 additions & 4 deletions lib/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ const devices = {
model: 'MCCGQ01LM',
vendor: 'Xiaomi',
description: 'MiJia door & window contact sensor',
supports: 'open and closed state',
homeassistant: [homeassistant.binary_sensor_state]
supports: 'contact',
homeassistant: [homeassistant.binary_sensor_contact]
},
'lumi.sensor_magnet.aq2': {
model: 'MCCGQ11LM',
vendor: 'Xiaomi',
description: 'Aqara door & window contact sensor',
supports: 'open and closed state',
homeassistant: [homeassistant.binary_sensor_state]
supports: 'contact',
homeassistant: [homeassistant.binary_sensor_contact]
},
'lumi.sensor_wleak.aq1': {
model: 'SJCGQ11LM',
Expand Down
14 changes: 7 additions & 7 deletions lib/homeassistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ const homeassistant = {
type: 'binary_sensor',
object_id: 'occupancy',
discovery_payload: {
payload_on: 'motion',
payload_off: 'no_motion',
payload_on: true,
payload_off: false,
value_template: '{{ value_json.occupancy }}',
device_class: 'motion',
json_attributes: ['battery']
}
},
'binary_sensor_state': {
'binary_sensor_contact': {
type: 'binary_sensor',
object_id: 'state',
object_id: 'contact',
discovery_payload: {
payload_on: 'open',
payload_off: 'closed',
value_template: '{{ value_json.state }}',
payload_on: false,
payload_off: true,
value_template: '{{ value_json.contact }}',
device_class: 'door',
json_attributes: ['battery']
}
Expand Down

0 comments on commit 54ca2dd

Please sign in to comment.