homebridge-pollen 1.0.0 → 1.1.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.
package/CLAUDE.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # CLAUDE.md
2
2
 
3
- ## Project Overview
3
+ ## Project overview
4
4
 
5
- Homebridge dynamic platform plugin that fetches pollen data from the Ambee API and exposes it as HomeKit accessories. No runtime dependencies — uses Node.js 20+ built-in `fetch`.
5
+ Homebridge dynamic platform plugin that fetches pollen data from the Ambee API and exposes it as HomeKit air quality sensors. No runtime dependencies — uses Node.js 20+ built-in `fetch`.
6
6
 
7
7
  ## Commands
8
8
 
@@ -10,13 +10,13 @@ Homebridge dynamic platform plugin that fetches pollen data from the Ambee API a
10
10
  - `npm run lint` — ESLint
11
11
  - `npm run dev` — build, link, and start Homebridge with nodemon (auto-restarts on src changes)
12
12
 
13
- ## Homebridge Plugin Architecture
13
+ ## Homebridge plugin architecture
14
14
 
15
15
  ### Registration
16
16
 
17
17
  A Homebridge plugin exports a default function that receives the `API` object and calls `api.registerPlatform(PLATFORM_NAME, PlatformClass)`. The platform name here must match `pluginAlias` in `config.schema.json`. The npm package name (`homebridge-pollen`) is how Homebridge discovers the plugin.
18
18
 
19
- ### Dynamic Platform Plugin Lifecycle
19
+ ### Dynamic platform plugin lifecycle
20
20
 
21
21
  The plugin implements `DynamicPlatformPlugin` from `homebridge`. The lifecycle is:
22
22
 
@@ -30,26 +30,34 @@ The plugin implements `DynamicPlatformPlugin` from `homebridge`. The lifecycle i
30
30
 
31
31
  ### Accessory UUIDs
32
32
 
33
- UUIDs must be deterministic and stable across restarts. Generate them with `api.hap.uuid.generate(stableString)`. This plugin uses `pollen-{category}-{level}-{location}` as the stable string. If the UUID changes, Homebridge treats it as a new accessory and the old one becomes stale.
33
+ UUIDs must be deterministic and stable across restarts. Generate them with `api.hap.uuid.generate(stableString)`. This plugin uses `pollen-{category}-{location}` as the stable string. If the UUID changes, Homebridge treats it as a new accessory and the old one becomes stale.
34
34
 
35
- ### Services and Characteristics
35
+ ### Services and characteristics
36
36
 
37
37
  Each `PlatformAccessory` has one or more `Service` objects. Always check `accessory.getService(ServiceType)` before calling `addService` to avoid duplicates on restore from cache.
38
38
 
39
39
  Key pattern for getting/setting services:
40
40
  ```ts
41
- const service = accessory.getService(api.hap.Service.ContactSensor)
42
- || accessory.addService(api.hap.Service.ContactSensor, displayName);
41
+ const service = accessory.getService(api.hap.Service.AirQualitySensor)
42
+ || accessory.addService(api.hap.Service.AirQualitySensor, displayName);
43
43
  ```
44
44
 
45
45
  **Push model** — use `service.updateCharacteristic(CharType, value)` to push updates. This is preferred over registering `onGet` handlers when data is fetched on a polling interval. HomeKit GET requests return the last pushed value instantly.
46
46
 
47
- ### HomeKit Service Types Used
47
+ ### HomeKit service types used
48
48
 
49
- - **ContactSensor** — `ContactSensorState`: `CONTACT_DETECTED` (0) or `CONTACT_NOT_DETECTED` (1). Used because contact sensor state changes are native HomeKit automation triggers ("When X detected...").
50
- - **AirQualitySensor** — `AirQuality`: `UNKNOWN` (0), `EXCELLENT` (1), `GOOD` (2), `FAIR` (3), `INFERIOR` (4), `POOR` (5).
49
+ - **AirQualitySensor** — `AirQuality`: `UNKNOWN` (0), `EXCELLENT` (1), `GOOD` (2), `FAIR` (3), `INFERIOR` (4), `POOR` (5). Pollen counts are mapped to this scale.
51
50
  - **AccessoryInformation** — always present on every accessory. Set `Manufacturer`, `Model`, `SerialNumber`.
52
51
 
52
+ ### Accessories created
53
+
54
+ - **Pollen** (always) — overall air quality sensor using combined pollen count
55
+ - **Tree Pollen** (optional) — air quality sensor for tree pollen count
56
+ - **Grass Pollen** (optional) — air quality sensor for grass pollen count
57
+ - **Weed Pollen** (optional) — air quality sensor for weed pollen count
58
+
59
+ Enable per-category sensors via `enableCategorySensors` in config.
60
+
53
61
  ### config.schema.json
54
62
 
55
63
  This file defines the Homebridge UI configuration form. Key fields:
@@ -57,9 +65,9 @@ This file defines the Homebridge UI configuration form. Key fields:
57
65
  - `pluginAlias` — must match `PLATFORM_NAME` passed to `api.registerPlatform()`
58
66
  - `pluginType` — `"platform"` for platform plugins
59
67
  - `singular: true` — only one instance of this platform allowed
60
- - `schema.properties` — defines form fields. Use `"required": true` on required fields. Nested objects with `"expandable": true` render as collapsible sections in the UI.
68
+ - `schema.properties` — defines form fields. Use `"required": true` on required fields.
61
69
 
62
- ### TypeScript Configuration
70
+ ### TypeScript configuration
63
71
 
64
72
  - Target `ES2022` with `module: nodenext` / `moduleResolution: nodenext`
65
73
  - Imports must use `.js` extensions (e.g., `import { Foo } from './foo.js'`) — this is required by nodenext module resolution even though the source files are `.ts`
@@ -73,26 +81,22 @@ This file defines the Homebridge UI configuration form. Key fields:
73
81
  - **Response shape**: `{ message: string, data: [{ Count: { grass_pollen, tree_pollen, weed_pollen }, Risk: {...}, Species: {...}, updatedAt: string }] }`
74
82
  - The `by-place` endpoint accepts zip codes and place names directly
75
83
 
76
- ## Pollen Thresholds
77
-
78
- Default thresholds based on NAB (National Allergy Bureau) guidelines. A count is classified as:
79
- - **Low** if `count <= threshold.low`
80
- - **High** if `count >= threshold.high`
81
- - **Medium** otherwise
84
+ ## Air quality mapping
82
85
 
83
- | Category | Low | High |
84
- |----------|-----|------|
85
- | Overall | 50 | 200 |
86
- | Tree | 15 | 90 |
87
- | Grass | 20 | 200 |
88
- | Weed | 10 | 50 |
86
+ Pollen counts are mapped to HomeKit's AirQuality scale:
89
87
 
90
- Users can override these via `config.thresholds`.
88
+ | Pollen count | AirQuality |
89
+ |--------------|------------|
90
+ | 0-20 | Excellent |
91
+ | 21-80 | Good |
92
+ | 81-200 | Fair |
93
+ | 201-400 | Inferior |
94
+ | 400+ | Poor |
91
95
 
92
- ## Error Handling
96
+ ## Error handling
93
97
 
94
98
  - Missing `apiKey`/`location` — logs error, plugin does not start polling
95
- - 401 — logs clear message about invalid API key, returns cached data
99
+ - 401 — logs error about invalid API key, returns cached data
96
100
  - 429 — logs warning, increments consecutive failure counter for exponential backoff
97
101
  - Network/5xx — logs warning, returns cached data, retries next cycle
98
102
  - Empty data array — logs warning about unsupported location, retains cache
package/CONTRIBUTING.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Contributing
2
2
 
3
- ## Local Development
3
+ ## Local development
4
4
 
5
5
  ### Prerequisites
6
6
 
@@ -40,9 +40,9 @@ npm run build
40
40
 
41
41
  After running `npm run setup` and `npm run dev`, verify in the console output that:
42
42
 
43
- - 3 ContactSensor accessories are registered (Pollen High, Pollen Medium, Pollen Low)
44
- - An initial pollen fetch completes and one sensor shows `DETECTED`
45
- - Debug log lines show the fetched counts and level classifications
43
+ - 1 AirQualitySensor accessory is registered (Pollen)
44
+ - An initial pollen fetch completes and logs the pollen counts
45
+ - The air quality value is set based on the overall pollen count
46
46
 
47
47
  To test optional features, edit `.homebridge/config.json` and add:
48
48
 
@@ -51,12 +51,11 @@ To test optional features, edit `.homebridge/config.json` and add:
51
51
  "platform": "HomebridgePollen",
52
52
  "apiKey": "YOUR_AMBEE_API_KEY",
53
53
  "location": "10001",
54
- "enableCategorySensors": true,
55
- "enableAirQualitySensor": true
54
+ "enableCategorySensors": true
56
55
  }
57
56
  ```
58
57
 
59
- This adds 9 per-category sensors (Tree/Grass/Weed x High/Medium/Low) and 1 AirQualitySensor. Restart the dev server to pick up the changes.
58
+ This adds 3 additional air quality sensors for Tree, Grass, and Weed pollen. Restart the dev server to pick up the changes.
60
59
 
61
60
  ### Pairing with Apple Home
62
61
 
@@ -69,19 +68,19 @@ To test end-to-end in the Home app:
69
68
 
70
69
  The test bridge uses port 51826, so it can run alongside a production Homebridge instance on the default port. When you're done testing, unpair the bridge from Home to avoid stale accessories.
71
70
 
72
- ### Project Structure
71
+ ### Project structure
73
72
 
74
73
  ```
75
74
  src/
76
75
  ├── index.ts # Entry point — registers platform with Homebridge
77
- ├── settings.ts # Constants and default thresholds
78
- ├── types.ts # TypeScript interfaces and helper functions
76
+ ├── settings.ts # Constants (plugin name, API URL, poll intervals)
77
+ ├── types.ts # TypeScript interfaces
79
78
  ├── pollenService.ts # Ambee API client (fetch, parse, cache)
80
79
  ├── platform.ts # DynamicPlatformPlugin (discovery, polling)
81
- └── platformAccessory.ts # Maps pollen data to HomeKit services
80
+ └── platformAccessory.ts # Maps pollen data to HomeKit AirQualitySensor
82
81
  ```
83
82
 
84
- ## Submitting Changes
83
+ ## Submitting changes
85
84
 
86
85
  1. Create a branch from `main`.
87
86
  2. Make your changes and verify `npm run build` and `npm run lint` pass.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # homebridge-pollen
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/homebridge-pollen)](https://www.npmjs.com/package/homebridge-pollen)
4
- [![license](https://img.shields.io/npm/l/homebridge-pollen)](LICENSE)
4
+ [![downloads](https://img.shields.io/npm/dm/homebridge-pollen)](https://www.npmjs.com/package/homebridge-pollen)
5
+ [![license](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
6
 
6
- Homebridge plugin that exposes pollen levels as HomeKit sensors using the [Ambee API](https://www.getambee.com/).
7
+ Homebridge plugin that exposes pollen levels as HomeKit air quality sensors using the [Ambee API](https://www.getambee.com/).
7
8
 
8
9
  ## Features
9
10
 
10
- - **Contact sensors for automations** — Pollen levels are exposed as contact sensors, which can trigger HomeKit automations natively ("When Pollen High detected...")
11
+ - **Air quality sensors** — Pollen counts are mapped to HomeKit's 5-level air quality scale (Excellent, Good, Fair, Inferior, Poor)
11
12
  - **Per-category sensors** — Optionally add separate sensors for tree, grass, and weed pollen
12
- - **Air quality sensor** — Optionally add an air quality sensor that maps overall pollen count to a 1-5 severity scale
13
13
  - **No runtime dependencies** — Uses Node.js 20+ built-in `fetch`
14
14
 
15
15
  ## Requirements
@@ -65,60 +65,27 @@ You can configure the plugin using the Homebridge UI or by editing your `config.
65
65
  | `apiKey` | Yes | — | Your Ambee API key |
66
66
  | `location` | Yes | — | Zip code or place name to fetch pollen data for |
67
67
  | `pollInterval` | No | `60` | How often to fetch pollen data, in minutes (minimum 15) |
68
- | `enableCategorySensors` | No | `false` | Add 9 additional sensors for tree/grass/weed at each level |
69
- | `enableAirQualitySensor` | No | `false` | Add an air quality sensor accessory |
70
- | `thresholds` | No | — | Override default pollen count thresholds (see below) |
68
+ | `enableCategorySensors` | No | `false` | Add 3 additional sensors for tree, grass, and weed pollen |
71
69
 
72
70
  ## How it works
73
71
 
74
- The plugin creates contact sensors that represent pollen levels. By default, you get three sensors:
72
+ The plugin creates an air quality sensor that displays the overall pollen level. Pollen counts are mapped to HomeKit's air quality scale:
75
73
 
76
- - **Pollen High** Triggered when pollen count is high
77
- - **Pollen Medium** — Triggered when pollen count is medium
78
- - **Pollen Low** — Triggered when pollen count is low
79
-
80
- Contact sensors are used because their state changes are native HomeKit automation triggers. This lets you create automations like "When Pollen High is detected, turn on the air purifier."
74
+ | Pollen count | Air quality |
75
+ |--------------|-------------|
76
+ | 0-20 | Excellent |
77
+ | 21-80 | Good |
78
+ | 81-200 | Fair |
79
+ | 201-400 | Inferior |
80
+ | 400+ | Poor |
81
81
 
82
82
  ### Optional sensors
83
83
 
84
- When `enableCategorySensors` is enabled, you get 9 additional sensors:
85
-
86
- - Tree Pollen High / Medium / Low
87
- - Grass Pollen High / Medium / Low
88
- - Weed Pollen High / Medium / Low
89
-
90
- When `enableAirQualitySensor` is enabled, you get a single air quality sensor that maps the overall pollen count to HomeKit's 5-level air quality scale.
91
-
92
- ## Pollen thresholds
93
-
94
- Pollen counts are classified as Low, Medium, or High based on thresholds from the National Allergy Bureau (NAB). You can override these defaults in your configuration.
84
+ When `enableCategorySensors` is enabled, you get 3 additional air quality sensors:
95
85
 
96
- | Category | Low (at or below) | High (at or above) |
97
- |----------|-------------------|---------------------|
98
- | Overall | 50 | 200 |
99
- | Tree | 15 | 90 |
100
- | Grass | 20 | 200 |
101
- | Weed | 10 | 50 |
102
-
103
- Counts between the low and high thresholds are classified as Medium.
104
-
105
- ### Customizing thresholds
106
-
107
- ```json
108
- {
109
- "platforms": [
110
- {
111
- "platform": "HomebridgePollen",
112
- "apiKey": "your-api-key",
113
- "location": "10001",
114
- "thresholds": {
115
- "overall": { "low": 30, "high": 150 },
116
- "tree": { "low": 10, "high": 60 }
117
- }
118
- }
119
- ]
120
- }
121
- ```
86
+ - **Tree Pollen** Air quality based on tree pollen count
87
+ - **Grass Pollen** — Air quality based on grass pollen count
88
+ - **Weed Pollen** Air quality based on weed pollen count
122
89
 
123
90
  ## License
124
91
 
@@ -2,7 +2,7 @@
2
2
  "pluginAlias": "HomebridgePollen",
3
3
  "pluginType": "platform",
4
4
  "singular": true,
5
- "headerDisplay": "Exposes pollen levels from the [Ambee API](https://www.getambee.com/) as HomeKit contact sensors for automation.",
5
+ "headerDisplay": "Exposes pollen levels from the [Ambee API](https://www.getambee.com/) as HomeKit air quality sensors.",
6
6
  "footerDisplay": "For help, see the [README](https://github.com/pburtchaell/homebridge-pollen).",
7
7
  "schema": {
8
8
  "type": "object",
@@ -31,87 +31,7 @@
31
31
  "title": "Enable Per-Category Sensors",
32
32
  "type": "boolean",
33
33
  "default": false,
34
- "description": "Add 9 additional sensors for Tree/Grass/Weed x High/Medium/Low."
35
- },
36
- "enableAirQualitySensor": {
37
- "title": "Enable Air Quality Sensor",
38
- "type": "boolean",
39
- "default": false,
40
- "description": "Add an AirQualitySensor accessory that maps overall pollen count to a 1-5 severity scale."
41
- },
42
- "thresholds": {
43
- "title": "Threshold Overrides",
44
- "type": "object",
45
- "expandable": true,
46
- "description": "Override default pollen count thresholds for level classification.",
47
- "properties": {
48
- "overall": {
49
- "title": "Overall",
50
- "type": "object",
51
- "properties": {
52
- "low": {
53
- "title": "Low Threshold",
54
- "type": "integer",
55
- "default": 50,
56
- "description": "Counts at or below this value are classified as Low."
57
- },
58
- "high": {
59
- "title": "High Threshold",
60
- "type": "integer",
61
- "default": 200,
62
- "description": "Counts at or above this value are classified as High."
63
- }
64
- }
65
- },
66
- "tree": {
67
- "title": "Tree",
68
- "type": "object",
69
- "properties": {
70
- "low": {
71
- "title": "Low Threshold",
72
- "type": "integer",
73
- "default": 15
74
- },
75
- "high": {
76
- "title": "High Threshold",
77
- "type": "integer",
78
- "default": 90
79
- }
80
- }
81
- },
82
- "grass": {
83
- "title": "Grass",
84
- "type": "object",
85
- "properties": {
86
- "low": {
87
- "title": "Low Threshold",
88
- "type": "integer",
89
- "default": 20
90
- },
91
- "high": {
92
- "title": "High Threshold",
93
- "type": "integer",
94
- "default": 200
95
- }
96
- }
97
- },
98
- "weed": {
99
- "title": "Weed",
100
- "type": "object",
101
- "properties": {
102
- "low": {
103
- "title": "Low Threshold",
104
- "type": "integer",
105
- "default": 10
106
- },
107
- "high": {
108
- "title": "High Threshold",
109
- "type": "integer",
110
- "default": 50
111
- }
112
- }
113
- }
114
- }
34
+ "description": "Add 3 additional air quality sensors for Tree, Grass, and Weed pollen."
115
35
  }
116
36
  }
117
37
  }
package/dist/platform.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PollenPlatform = void 0;
4
4
  const settings_js_1 = require("./settings.js");
5
- const types_js_1 = require("./types.js");
6
5
  const pollenService_js_1 = require("./pollenService.js");
7
6
  const platformAccessory_js_1 = require("./platformAccessory.js");
8
7
  class PollenPlatform {
@@ -23,8 +22,7 @@ class PollenPlatform {
23
22
  + 'Plugin will not start.');
24
23
  return;
25
24
  }
26
- const thresholds = (0, types_js_1.resolveThresholds)(pollenConfig, settings_js_1.DEFAULT_THRESHOLDS);
27
- this.pollenService = new pollenService_js_1.PollenService(pollenConfig.apiKey, pollenConfig.location, thresholds, this.log);
25
+ this.pollenService = new pollenService_js_1.PollenService(pollenConfig.apiKey, pollenConfig.location, this.log);
28
26
  this.api.on('didFinishLaunching', () => {
29
27
  this.discoverDevices(pollenConfig);
30
28
  this.startPolling(pollenConfig);
@@ -72,42 +70,24 @@ class PollenPlatform {
72
70
  buildAccessoryDefinitions(config) {
73
71
  const location = config.location;
74
72
  const definitions = [];
75
- // Default 3 overall sensors: High, Medium, Low
76
- const overallLevels = ['High', 'Medium', 'Low'];
77
- for (const level of overallLevels) {
78
- definitions.push({
79
- id: `pollen-overall-${level}-${location}`,
80
- name: `Pollen ${level}`,
81
- type: 'contact',
82
- level,
83
- category: 'overall',
84
- });
85
- }
86
- // Optional per-category sensors (9 total)
73
+ // Main pollen air quality sensor (always created)
74
+ definitions.push({
75
+ id: `pollen-overall-${location}`,
76
+ name: 'Pollen',
77
+ category: 'overall',
78
+ });
79
+ // Optional per-category sensors
87
80
  if (config.enableCategorySensors) {
88
81
  const categories = ['tree', 'grass', 'weed'];
89
- const levels = ['High', 'Medium', 'Low'];
90
82
  for (const category of categories) {
91
- for (const level of levels) {
92
- const label = category.charAt(0).toUpperCase() + category.slice(1);
93
- definitions.push({
94
- id: `pollen-${category}-${level}-${location}`,
95
- name: `${label} Pollen ${level}`,
96
- type: 'contact',
97
- level,
98
- category,
99
- });
100
- }
83
+ const label = category.charAt(0).toUpperCase() + category.slice(1);
84
+ definitions.push({
85
+ id: `pollen-${category}-${location}`,
86
+ name: `${label} Pollen`,
87
+ category,
88
+ });
101
89
  }
102
90
  }
103
- // Optional air quality sensor
104
- if (config.enableAirQualitySensor) {
105
- definitions.push({
106
- id: `pollen-airquality-${location}`,
107
- name: 'Pollen Air Quality',
108
- type: 'airquality',
109
- });
110
- }
111
91
  return definitions;
112
92
  }
113
93
  startPolling(config) {
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";;;AAOA,+CAMuB;AAEvB,yCAA+C;AAC/C,yDAAmD;AACnD,iEAAgE;AAEhE,MAAa,cAAc;IAOP;IACA;IACA;IARD,iBAAiB,GAAwB,EAAE,CAAC;IAC5C,QAAQ,GAAwC,IAAI,GAAG,EAAE,CAAC;IACnE,aAAa,CAAiB;IAC9B,SAAS,CAAkC;IAEnD,YACkB,GAAW,EACX,MAAsB,EACtB,GAAQ;QAFR,QAAG,GA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
9
9
  private readonly Characteristic;
10
10
  constructor(accessory: PlatformAccessory, definition: AccessoryDefinition, api: API, log: Logger);
11
11
  updatePollenData(data: ParsedPollenData): void;
12
- private updateContactSensor;
13
- private updateAirQuality;
14
12
  private mapCountToAirQuality;
15
13
  }
@@ -18,43 +18,19 @@ class PollenAccessoryHandler {
18
18
  .setCharacteristic(this.Characteristic.Manufacturer, 'Ambee')
19
19
  .setCharacteristic(this.Characteristic.Model, 'Pollen Sensor')
20
20
  .setCharacteristic(this.Characteristic.SerialNumber, definition.id);
21
- if (definition.type === 'airquality') {
22
- this.service = this.accessory.getService(this.api.hap.Service.AirQualitySensor)
23
- || this.accessory.addService(this.api.hap.Service.AirQualitySensor, definition.name);
24
- }
25
- else {
26
- this.service = this.accessory.getService(this.api.hap.Service.ContactSensor)
27
- || this.accessory.addService(this.api.hap.Service.ContactSensor, definition.name);
28
- }
21
+ this.service = this.accessory.getService(this.api.hap.Service.AirQualitySensor)
22
+ || this.accessory.addService(this.api.hap.Service.AirQualitySensor, definition.name);
29
23
  this.service.setCharacteristic(this.Characteristic.Name, definition.name);
30
24
  }
31
25
  updatePollenData(data) {
32
- if (this.definition.type === 'airquality') {
33
- this.updateAirQuality(data);
34
- }
35
- else {
36
- this.updateContactSensor(data);
37
- }
38
- }
39
- updateContactSensor(data) {
40
26
  const category = this.definition.category;
41
- const targetLevel = this.definition.level;
42
- const currentLevel = data[category].level;
43
- const isDetected = currentLevel === targetLevel;
44
- const state = isDetected
45
- ? this.Characteristic.ContactSensorState.CONTACT_DETECTED
46
- : this.Characteristic.ContactSensorState.CONTACT_NOT_DETECTED;
47
- this.service.updateCharacteristic(this.Characteristic.ContactSensorState, state);
48
- this.log.debug(`${this.definition.name}: ${category} level is ${currentLevel}, `
49
- + `sensor ${targetLevel} → ${isDetected ? 'DETECTED' : 'NOT_DETECTED'}`);
50
- }
51
- updateAirQuality(data) {
52
- const quality = this.mapCountToAirQuality(data.overall.count);
27
+ const count = data[category].count;
28
+ const quality = this.mapCountToAirQuality(count);
53
29
  this.service.updateCharacteristic(this.Characteristic.AirQuality, quality);
54
- this.log.debug(`${this.definition.name}: overall count=${data.overall.count}, AirQuality=${quality}`);
30
+ this.log.debug(`${this.definition.name}: ${category} count=${count}, AirQuality=${quality}`);
55
31
  }
56
32
  mapCountToAirQuality(count) {
57
- // Map total pollen count to HomeKit AirQuality enum (0-5)
33
+ // Map pollen count to HomeKit AirQuality enum (0-5)
58
34
  // 0=UNKNOWN, 1=EXCELLENT, 2=GOOD, 3=FAIR, 4=INFERIOR, 5=POOR
59
35
  if (count <= 20) {
60
36
  return this.Characteristic.AirQuality.EXCELLENT;
@@ -1 +1 @@
1
- {"version":3,"file":"platformAccessory.js","sourceRoot":"","sources":["../src/platformAccessory.ts"],"names":[],"mappings":";;;AASA,MAAa,sBAAsB;IAKd;IACA;IACA;IACA;IAPF,OAAO,CAAU;IACjB,cAAc,CAAwB;IAEvD,YACmB,SAA4B,EAC5B,UAA+B,EAC/B,GAAQ,EACR,GAAW;QAHX,cAAS,GAAT,SAAS,CAAmB;QAC5B,eAAU,GAAV,UAAU,CAAqB;QAC/B,QAAG,GAAH,GAAG,CAAK;QACR,QAAG,GAAH,GAAG,CAAQ;QAE5B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC;QAElD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,oBAAoB,CAAE;aAClE,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,OAAO,CAAC;aAC5D,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,eAAe,CAAC;aAC7D,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;QAEtE,IAAI,UAAU,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACrC,IAAI,C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ge';
2
- import type { Thresholds } from './settings.js';
3
2
  import type { ParsedPollenData } from './types.js';
4
3
  export declare class PollenService {
5
4
  private readonly apiKey;
6
5
  private readonly location;
7
- private readonly thresholds;
8
6
  private readonly log;
9
7
  private cache;
10
8
  private consecutiveFailures;
11
- constructor(apiKey: string, location: string, thresholds: Thresholds, log: Logger);
9
+ constructor(apiKey: string, location: string, log: Logger);
12
10
  fetchPollenData(): Promise<ParsedPollenData | null>;
13
11
  getBackoffMultiplier(): number;
14
12
  getCachedData(): ParsedPollenData | null;
@@ -2,18 +2,31 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PollenService = void 0;
4
4
  const settings_js_1 = require("./settings.js");
5
- const types_js_1 = require("./types.js");
5
+ // Internal thresholds for level classification (used for logging)
6
+ const THRESHOLDS = {
7
+ overall: { low: 50, high: 200 },
8
+ tree: { low: 15, high: 90 },
9
+ grass: { low: 20, high: 200 },
10
+ weed: { low: 10, high: 50 },
11
+ };
12
+ function classifyLevel(count, thresholds) {
13
+ if (count >= thresholds.high) {
14
+ return 'High';
15
+ }
16
+ if (count <= thresholds.low) {
17
+ return 'Low';
18
+ }
19
+ return 'Medium';
20
+ }
6
21
  class PollenService {
7
22
  apiKey;
8
23
  location;
9
- thresholds;
10
24
  log;
11
25
  cache = null;
12
26
  consecutiveFailures = 0;
13
- constructor(apiKey, location, thresholds, log) {
27
+ constructor(apiKey, location, log) {
14
28
  this.apiKey = apiKey;
15
29
  this.location = location;
16
- this.thresholds = thresholds;
17
30
  this.log = log;
18
31
  }
19
32
  async fetchPollenData() {
@@ -55,25 +68,25 @@ class PollenService {
55
68
  const parsed = {
56
69
  overall: {
57
70
  count: totalCount,
58
- level: (0, types_js_1.classifyLevel)(totalCount, this.thresholds.overall),
71
+ level: classifyLevel(totalCount, THRESHOLDS.overall),
59
72
  },
60
73
  tree: {
61
74
  count: treeCount,
62
- level: (0, types_js_1.classifyLevel)(treeCount, this.thresholds.tree),
75
+ level: classifyLevel(treeCount, THRESHOLDS.tree),
63
76
  },
64
77
  grass: {
65
78
  count: grassCount,
66
- level: (0, types_js_1.classifyLevel)(grassCount, this.thresholds.grass),
79
+ level: classifyLevel(grassCount, THRESHOLDS.grass),
67
80
  },
68
81
  weed: {
69
82
  count: weedCount,
70
- level: (0, types_js_1.classifyLevel)(weedCount, this.thresholds.weed),
83
+ level: classifyLevel(weedCount, THRESHOLDS.weed),
71
84
  },
72
85
  timestamp: item.updatedAt,
73
86
  };
74
87
  this.cache = parsed;
75
88
  this.consecutiveFailures = 0;
76
- this.log.debug(`Pollen data updated: overall=${totalCount} (${parsed.overall.level}), `
89
+ this.log.info(`Pollen data updated: overall=${totalCount} (${parsed.overall.level}), `
77
90
  + `tree=${treeCount} (${parsed.tree.level}), `
78
91
  + `grass=${grassCount} (${parsed.grass.level}), `
79
92
  + `weed=${weedCount} (${parsed.weed.level})`);
@@ -1 +1 @@
1
- {"version":3,"file":"pollenService.js","sourceRoot":"","sources":["../src/pollenService.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAG/C,yCAA2C;AAE3C,MAAa,aAAa;IAKL;IACA;IACA;IACA;IAPX,KAAK,GAA4B,IAAI,CAAC;IACtC,mBAAmB,GAAG,CAAC,CAAC;IAEhC,YACmB,MAAc,EACd,QAAgB,EAChB,UAAsB,EACtB,GAAW;QAHX,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,eAAU,GAAV,UAAU,CAAY;QACtB,QAAG,GAAH,GAAG,CAAQ;IAC3B,CAAC;IAEJ,KAAK,CAAC,eAAe;QACnB,MAAM,GAAG,GAAG,GAAG,4BAAc,iCAAiC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAElG,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;gBAChC,OAAO,EAAE;oBACP,WAAW,EAAE,IAAI,CAAC,MAAM;oBACxB,cAAc,EAAE,k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,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;YAE7B,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,gCAAgC,UAAU,KAAK,MAAM,CAAC,OAAO,CAAC,KAAK,KAAK;kBACtE,QAAQ,SAAS,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK;kBAC5C,SAAS,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK;kBAC/C,QAAQ,SAAS,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,GAAG,CAC7C,CAAC;YAEF,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,CAAC,GAAG,CAAC,IAAI,CACX,gCAAgC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI;kBAChF,gDAAgD,IAAI,CAAC,mBAAmB,EAAE,CAC7E,CAAC;YACF,OAAO,IAAI,CAAC,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED,oBAAoB;QAClB,IAAI,IAAI,CAAC,mBAAmB,IAAI,CAAC,EAAE,CAAC;YAClC,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF;AA/GD,sCA+GC"}
@@ -3,14 +3,3 @@ export declare const PLUGIN_NAME = "homebridge-pollen";
3
3
  export declare const AMBEE_BASE_URL = "https://api.ambeedata.com";
4
4
  export declare const DEFAULT_POLL_INTERVAL = 60;
5
5
  export declare const MIN_POLL_INTERVAL = 15;
6
- export interface ThresholdRange {
7
- low: number;
8
- high: number;
9
- }
10
- export interface Thresholds {
11
- overall: ThresholdRange;
12
- tree: ThresholdRange;
13
- grass: ThresholdRange;
14
- weed: ThresholdRange;
15
- }
16
- export declare const DEFAULT_THRESHOLDS: Thresholds;
package/dist/settings.js CHANGED
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_THRESHOLDS = exports.MIN_POLL_INTERVAL = exports.DEFAULT_POLL_INTERVAL = exports.AMBEE_BASE_URL = exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
3
+ exports.MIN_POLL_INTERVAL = exports.DEFAULT_POLL_INTERVAL = exports.AMBEE_BASE_URL = exports.PLUGIN_NAME = exports.PLATFORM_NAME = void 0;
4
4
  exports.PLATFORM_NAME = 'HomebridgePollen';
5
5
  exports.PLUGIN_NAME = 'homebridge-pollen';
6
6
  exports.AMBEE_BASE_URL = 'https://api.ambeedata.com';
7
7
  exports.DEFAULT_POLL_INTERVAL = 60; // minutes
8
8
  exports.MIN_POLL_INTERVAL = 15; // minutes
9
- exports.DEFAULT_THRESHOLDS = {
10
- overall: { low: 50, high: 200 },
11
- tree: { low: 15, high: 90 },
12
- grass: { low: 20, high: 200 },
13
- weed: { low: 10, high: 50 },
14
- };
15
9
  //# sourceMappingURL=settings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,kBAAkB,CAAC;AACnC,QAAA,WAAW,GAAG,mBAAmB,CAAC;AAElC,QAAA,cAAc,GAAG,2BAA2B,CAAC;AAE7C,QAAA,qBAAqB,GAAG,EAAE,CAAC,CAAC,UAAU;AACtC,QAAA,iBAAiB,GAAG,EAAE,CAAC,CAAC,UAAU;AAclC,QAAA,kBAAkB,GAAe;IAC5C,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;IAC/B,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;IAC3B,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;IAC7B,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;CAC5B,CAAC"}
1
+ {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,kBAAkB,CAAC;AACnC,QAAA,WAAW,GAAG,mBAAmB,CAAC;AAElC,QAAA,cAAc,GAAG,2BAA2B,CAAC;AAE7C,QAAA,qBAAqB,GAAG,EAAE,CAAC,CAAC,UAAU;AACtC,QAAA,iBAAiB,GAAG,EAAE,CAAC,CAAC,UAAU"}
package/dist/types.d.ts CHANGED
@@ -1,29 +1,9 @@
1
1
  import type { PlatformConfig } from 'homebridge';
2
- import type { Thresholds } from './settings.js';
3
2
  export interface PollenConfig extends PlatformConfig {
4
3
  apiKey: string;
5
4
  location: string;
6
5
  pollInterval?: number;
7
6
  enableCategorySensors?: boolean;
8
- enableAirQualitySensor?: boolean;
9
- thresholds?: Partial<{
10
- overall: Partial<{
11
- low: number;
12
- high: number;
13
- }>;
14
- tree: Partial<{
15
- low: number;
16
- high: number;
17
- }>;
18
- grass: Partial<{
19
- low: number;
20
- high: number;
21
- }>;
22
- weed: Partial<{
23
- low: number;
24
- high: number;
25
- }>;
26
- }>;
27
7
  }
28
8
  export interface AmbeePollenCount {
29
9
  grass_pollen: number;
@@ -63,16 +43,8 @@ export interface ParsedPollenData {
63
43
  weed: CategoryData;
64
44
  timestamp: string;
65
45
  }
66
- export type AccessoryType = 'contact' | 'airquality';
67
46
  export interface AccessoryDefinition {
68
47
  id: string;
69
48
  name: string;
70
- type: AccessoryType;
71
- level?: PollenLevel;
72
- category?: PollenCategory;
49
+ category: PollenCategory;
73
50
  }
74
- export declare function classifyLevel(count: number, thresholds: {
75
- low: number;
76
- high: number;
77
- }): PollenLevel;
78
- export declare function resolveThresholds(config: PollenConfig, defaults: Thresholds): Thresholds;
package/dist/types.js CHANGED
@@ -1,26 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.classifyLevel = classifyLevel;
4
- exports.resolveThresholds = resolveThresholds;
5
- function classifyLevel(count, thresholds) {
6
- if (count >= thresholds.high) {
7
- return 'High';
8
- }
9
- if (count <= thresholds.low) {
10
- return 'Low';
11
- }
12
- return 'Medium';
13
- }
14
- function resolveThresholds(config, defaults) {
15
- const overrides = config.thresholds;
16
- if (!overrides) {
17
- return defaults;
18
- }
19
- return {
20
- overall: { ...defaults.overall, ...overrides.overall },
21
- tree: { ...defaults.tree, ...overrides.tree },
22
- grass: { ...defaults.grass, ...overrides.grass },
23
- weed: { ...defaults.weed, ...overrides.weed },
24
- };
25
- }
26
3
  //# sourceMappingURL=types.js.map
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAyEA,sCAQC;AAED,8CAWC;AArBD,SAAgB,aAAa,CAAC,KAAa,EAAE,UAAyC;IACpF,IAAI,KAAK,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,IAAI,UAAU,CAAC,GAAG,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,iBAAiB,CAAC,MAAoB,EAAE,QAAoB;IAC1E,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC;IACpC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO;QACL,OAAO,EAAE,EAAE,GAAG,QAAQ,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE;QACtD,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE;QAC7C,KAAK,EAAE,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,SAAS,CAAC,KAAK,EAAE;QAChD,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,SAAS,CAAC,IAAI,EAAE;KAC9C,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-pollen",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Homebridge plugin that exposes pollen levels as HomeKit sensors using the Ambee API",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",