Skip to content

Commit

Permalink
fixup! Add Aqara TVOC Sensor Support with history
Browse files Browse the repository at this point in the history
  • Loading branch information
sieren committed Sep 11, 2021
1 parent 7fe31e1 commit 36d6dec
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/HueSensor.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ const daylightPeriods = {
Day: { lightlevel: 65535, daylight: true, dark: false }
}

const eveRoom2sensors = ['lumi.airmonitor.acn01']

// ===== Homebridge ============================================================

// Link this module to homebridge.
Expand Down Expand Up @@ -237,6 +235,7 @@ function HueSensor (accessory, id, obj) {
this.infoService = this.accessory.getInfoService(this)

let durationKey = 'duration'
let temperatureHistory = 'weather'
switch (this.obj.type) {
case 'ZGPSwitch':
case 'ZLLSwitch':
Expand Down Expand Up @@ -930,13 +929,11 @@ function HueSensor (accessory, id, obj) {
} else if (
this.obj.manufacturername === 'LUMI' && (
this.obj.modelid === 'lumi.weather' ||
this.obj.modelid === 'lumi.sensor_ht' ||
this.obj.modelid === 'lumi.airmonitor.acn01'
this.obj.modelid === 'lumi.sensor_ht'
)
) {
// Xiaomi temperature/humidity sensor
// Xiaomi Aqara weather sensor
// Xiaomi Aqara airquality sensor
} else if (
this.obj.manufacturername === 'Heiman' &&
(this.obj.modelid === 'TH-H_V15' || this.obj.modelid === 'TH-T_V15')
Expand All @@ -960,6 +957,9 @@ function HueSensor (accessory, id, obj) {
) {
// Develco smoke sensor
// Develco heat sensor
} else if (this.obj.modelid === 'lumi.airmonitor.acn01') {
// Xiaomi Aquara TVOC Sensor
temperatureHistory = 'room2'
} else {
this.log.warn(
'%s: %s: warning: unknown %s sensor %j',
Expand All @@ -975,7 +975,7 @@ function HueSensor (accessory, id, obj) {
key: 'temperature',
name: 'temperature',
unit: '°C',
history: eveRoom2sensors.includes(this.obj.modelid) ? 'room2' : 'weather',
history: temperatureHistory,
homekitValue: function (v) { return v ? Math.round(v / 10) / 10 : 0 }
}
break
Expand Down Expand Up @@ -1085,12 +1085,14 @@ function HueSensor (accessory, id, obj) {
if (
this.obj.manufacturername === 'LUMI' && (
this.obj.modelid === 'lumi.weather' ||
this.obj.modelid === 'lumi.sensor_ht' ||
this.obj.modelid === 'lumi.airmonitor.acn01'
this.obj.modelid === 'lumi.sensor_ht'
)
) {
// Xiaomi Aqara weather sensor
// Xiaomi Mi temperature/humidity sensor
} else if (this.obj.modelid === 'lumi.airmonitor.acn01') {
// Xiaomi Aquara TVOC Sensor
temperatureHistory = 'room2'
} else if (
this.obj.manufacturername === 'Heiman' &&
(this.obj.modelid === 'TH-H_V15' || this.obj.modelid === 'TH-T_V15')
Expand All @@ -1111,7 +1113,7 @@ function HueSensor (accessory, id, obj) {
key: 'humidity',
name: 'humidity',
unit: '%',
history: eveRoom2sensors.includes(this.obj.modelid) ? 'room2' : 'weather',
history: temperatureHistory,
homekitValue: function (v) { return v ? Math.round(v / 100) : 0 }
}
break
Expand Down

0 comments on commit 36d6dec

Please sign in to comment.