hoffmation-base 3.6.1 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/lib/action/airQualitySensorChangeAction.d.ts +16 -0
  2. package/lib/action/airQualitySensorChangeAction.js +15 -0
  3. package/lib/action/index.d.ts +1 -0
  4. package/lib/action/index.js +3 -1
  5. package/lib/devices/sharedFunctions/airQualitySensor.d.ts +27 -0
  6. package/lib/devices/sharedFunctions/airQualitySensor.js +87 -0
  7. package/lib/devices/sharedFunctions/index.d.ts +1 -0
  8. package/lib/devices/sharedFunctions/index.js +1 -0
  9. package/lib/devices/unifi/index.d.ts +1 -0
  10. package/lib/devices/unifi/index.js +1 -0
  11. package/lib/devices/unifi/own-unifi-air-quality-sensor.d.ts +81 -0
  12. package/lib/devices/unifi/own-unifi-air-quality-sensor.js +164 -0
  13. package/lib/devices/unifi/own-unifi-camera.d.ts +6 -5
  14. package/lib/devices/unifi/own-unifi-camera.js +14 -24
  15. package/lib/devices/unifi/protect-module.d.ts +11 -0
  16. package/lib/devices/unifi/protect-module.js +16 -0
  17. package/lib/devices/unifi/unifi-logger.d.ts +5 -5
  18. package/lib/devices/unifi/unifi-logger.js +9 -8
  19. package/lib/devices/unifi/unifi-protect.d.ts +38 -7
  20. package/lib/devices/unifi/unifi-protect.js +199 -66
  21. package/lib/enums/DeviceCapability.d.ts +1 -0
  22. package/lib/enums/DeviceCapability.js +1 -0
  23. package/lib/enums/commandType.d.ts +1 -0
  24. package/lib/enums/commandType.js +1 -0
  25. package/lib/enums/deviceType.d.ts +1 -0
  26. package/lib/enums/deviceType.js +1 -0
  27. package/lib/interfaces/baseDevices/iAirQualityCollector.d.ts +23 -0
  28. package/lib/interfaces/baseDevices/iAirQualityCollector.js +2 -0
  29. package/lib/interfaces/baseDevices/iAirQualitySensor.d.ts +97 -0
  30. package/lib/interfaces/baseDevices/iAirQualitySensor.js +7 -0
  31. package/lib/interfaces/baseDevices/index.d.ts +2 -0
  32. package/lib/interfaces/baseDevices/index.js +2 -0
  33. package/lib/interfaces/iPersist.d.ts +6 -1
  34. package/lib/services/dbo/postgreSqlPersist.d.ts +3 -1
  35. package/lib/services/dbo/postgreSqlPersist.js +34 -1
  36. package/lib/tsconfig.tsbuildinfo +1 -1
  37. package/package.json +4 -3
@@ -292,7 +292,31 @@ BEGIN
292
292
  constraint humiditysensordevicedata_pk
293
293
  primary key ("deviceID", date)
294
294
  );
295
-
295
+
296
+ END IF;
297
+
298
+ IF (SELECT to_regclass('hoffmation_schema."AirQualitySensorDeviceData"') IS NULL) Then
299
+ create table if not exists hoffmation_schema."AirQualitySensorDeviceData"
300
+ (
301
+ "deviceID" varchar(60) not null
302
+ constraint "AirQualitySensorDeviceData_DeviceInfo_null_fk"
303
+ references hoffmation_schema."DeviceInfo"
304
+ on delete set null,
305
+ aqi double precision,
306
+ co2 double precision,
307
+ nox double precision,
308
+ "pm1p0" double precision,
309
+ "pm2p5" double precision,
310
+ "pm4p0" double precision,
311
+ "pm10p0" double precision,
312
+ tvoc double precision,
313
+ vape double precision,
314
+ voc double precision,
315
+ date timestamp not null,
316
+ constraint airqualitysensordevicedata_pk
317
+ primary key ("deviceID", date)
318
+ );
319
+
296
320
  END IF;
297
321
 
298
322
  IF (SELECT to_regclass('hoffmation_schema."BatteryDeviceData"') IS NULL) Then
@@ -478,6 +502,15 @@ $$;`);
478
502
  `);
479
503
  }
480
504
  /** @inheritDoc */
505
+ persistAirQualitySensor(device) {
506
+ const readings = device.airQuality;
507
+ const value = (metric) => (metric === interfaces_1.UNDEFINED_AIR_QUALITY_VALUE ? 'null' : `${metric}`);
508
+ this.query(`
509
+ insert into hoffmation_schema."AirQualitySensorDeviceData" ("deviceID", "aqi", "co2", "nox", "pm1p0", "pm2p5", "pm4p0", "pm10p0", "tvoc", "vape", "voc", "date")
510
+ values ('${device.id}', ${value(readings.aqi)}, ${value(readings.co2)}, ${value(readings.nox)}, ${value(readings.pm1p0)}, ${value(readings.pm2p5)}, ${value(readings.pm4p0)}, ${value(readings.pm10p0)}, ${value(readings.tvoc)}, ${value(readings.vape)}, ${value(readings.voc)}, '${new Date().toISOString()}');
511
+ `);
512
+ }
513
+ /** @inheritDoc */
481
514
  persistBatteryDevice(device) {
482
515
  this.query(`
483
516
  insert into hoffmation_schema."BatteryDeviceData" ("deviceID", "battery", "date")