homebridge-brother-printer 0.2.2 → 0.3.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/CHANGELOG.md +7 -0
- package/README.md +6 -2
- package/config.schema.json +7 -0
- package/lib/accessory.js +41 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0 - 2026-11-07
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Optional Toner Low contact sensor (`lowTonerSensor`, Ink Low on inkjets). It opens when
|
|
7
|
+
the toner or ink is low, by the same rule as the battery, so Home sends a notification
|
|
8
|
+
with its own name instead of "battery is low". Off by default.
|
|
9
|
+
|
|
3
10
|
## 0.2.2 - 2026-11-03
|
|
4
11
|
|
|
5
12
|
### Changed
|
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ Each printer gets these sensors:
|
|
|
20
20
|
- **Toner / Ink** (battery level on the Printer accessory): the toner or ink %, with Home's
|
|
21
21
|
native low-battery alert at or below your threshold. On color printers it shows the
|
|
22
22
|
lowest color, so the alert fires when any color runs low.
|
|
23
|
+
- **Toner Low** (optional contact sensor): Opens when the toner or ink is low, so Home
|
|
24
|
+
notifies "Printer Toner Low opened" instead of "battery is low".
|
|
23
25
|
- **Toner / ink tiles** (optional humidity sensors): the level as a number on its own tile,
|
|
24
26
|
one per color on color printers.
|
|
25
27
|
|
|
@@ -81,6 +83,7 @@ Set it up in the plugin's settings screen, or in `config.json`:
|
|
|
81
83
|
| `snmpVersion` | `auto` | `auto` tries v2c, then v1. Set `1` for older printers that only answer v1. |
|
|
82
84
|
| `pollInterval` | `60` | Seconds between polls (10–3600). |
|
|
83
85
|
| `lowTonerThreshold` | `10` | Toner or ink % at or below which Home shows it as low (any color, on color printers). |
|
|
86
|
+
| `lowTonerSensor` | `false` | Add a Toner Low contact sensor (Ink Low on inkjets) that opens when any supply is low, by the same rule as the battery. |
|
|
84
87
|
| `faultSensor` | `true` | Add the Printer Problem contact sensor. |
|
|
85
88
|
| `tonerTile` | `false` | Add humidity sensors showing the toner or ink %, one per color on color printers. They also count in Home's climate summary. |
|
|
86
89
|
| `showDrum` | `false` | Add drum life as a second battery. See below. |
|
|
@@ -94,8 +97,9 @@ HomeKit has no printer accessory type, so the plugin uses the closest sensors an
|
|
|
94
97
|
words them its own way:
|
|
95
98
|
|
|
96
99
|
- The printing sensor reads **Detected** / **Not Detected**.
|
|
97
|
-
- Low toner or ink is announced as **"battery is low"**. For a clearer message,
|
|
98
|
-
|
|
100
|
+
- Low toner or ink is announced as **"battery is low"**. For a clearer message, turn on
|
|
101
|
+
`lowTonerSensor`: its contact sensor opens at the same point and Home notifies it by
|
|
102
|
+
name ("Printer Toner Low opened"). Turn on its notifications in the Home app.
|
|
99
103
|
- Home shows only one battery per accessory. With `showDrum` on, it may show the drum
|
|
100
104
|
instead of the toner, which is why the drum is off by default. It's still read, and the
|
|
101
105
|
plugin logs a warning when it nears end of life. Apps like Eve show both.
|
package/config.schema.json
CHANGED
|
@@ -80,6 +80,12 @@
|
|
|
80
80
|
"maximum": 100,
|
|
81
81
|
"description": "On color printers, the battery shows the lowest color and turns low when any color reaches this."
|
|
82
82
|
},
|
|
83
|
+
"lowTonerSensor": {
|
|
84
|
+
"title": "Low toner sensor",
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"default": false,
|
|
87
|
+
"description": "Adds a contact sensor that opens when toner or ink is low, so Home notifies \"Printer Toner Low opened\" instead of \"battery is low\". Turn on notifications for it in the Home app."
|
|
88
|
+
},
|
|
83
89
|
"showDrum": {
|
|
84
90
|
"title": "Show drum life as a second battery",
|
|
85
91
|
"type": "boolean",
|
|
@@ -142,6 +148,7 @@
|
|
|
142
148
|
"expandable": true,
|
|
143
149
|
"items": [
|
|
144
150
|
"printers[].lowTonerThreshold",
|
|
151
|
+
"printers[].lowTonerSensor",
|
|
145
152
|
"printers[].showDrum",
|
|
146
153
|
"printers[].lowDrumThreshold",
|
|
147
154
|
"printers[].tonerTile",
|
package/lib/accessory.js
CHANGED
|
@@ -62,6 +62,7 @@ class PrinterAccessory {
|
|
|
62
62
|
this.showDrum = config.showDrum === true;
|
|
63
63
|
this.tonerTile = config.tonerTile === true;
|
|
64
64
|
this.faultSensor = config.faultSensor !== false;
|
|
65
|
+
this.lowTonerSensor = config.lowTonerSensor === true;
|
|
65
66
|
this.offlineAfter = Math.max(1, Number(config.offlineAfter) || 3);
|
|
66
67
|
this.debug = config.debug === true;
|
|
67
68
|
|
|
@@ -128,6 +129,11 @@ class PrinterAccessory {
|
|
|
128
129
|
this.removeSubtype(Service.ContactSensor, 'problem');
|
|
129
130
|
}
|
|
130
131
|
|
|
132
|
+
// The low toner sensor is created once the printer says toner or ink;
|
|
133
|
+
// here only one restored from the cache is picked up.
|
|
134
|
+
const lowSvc = acc.getServiceById(Service.ContactSensor, 'lowToner');
|
|
135
|
+
if (lowSvc && this.lowTonerSensor) { this.lowSensor = lowSvc; } else if (lowSvc) { acc.removeService(lowSvc); }
|
|
136
|
+
|
|
131
137
|
// Supply tiles are created once the printer says which colors it has;
|
|
132
138
|
// here only the ones restored from the cache are picked up.
|
|
133
139
|
for (const [color, subtype] of Object.entries(TILE_SUBTYPE)) {
|
|
@@ -164,6 +170,31 @@ class PrinterAccessory {
|
|
|
164
170
|
}
|
|
165
171
|
}
|
|
166
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Low toner as a contact sensor that opens when any supply is low. Home words
|
|
175
|
+
* a low battery as "battery is low"; this gives a notification with its own
|
|
176
|
+
* name, e.g. "Printer Toner Low opened".
|
|
177
|
+
*/
|
|
178
|
+
ensureLowSensor(kind) {
|
|
179
|
+
if (!this.lowTonerSensor || this.lowSensor) { return; }
|
|
180
|
+
const { Service, Characteristic: C } = this.hap;
|
|
181
|
+
const name = `${this.name} ${kind} Low`;
|
|
182
|
+
const svc = this.accessory.addService(Service.ContactSensor, name, 'lowToner');
|
|
183
|
+
this.label(svc, name);
|
|
184
|
+
if (!svc.testCharacteristic(C.StatusActive)) { svc.addOptionalCharacteristic(C.StatusActive); }
|
|
185
|
+
svc.getCharacteristic(C.StatusActive).updateValue(true);
|
|
186
|
+
this.occupancy.addLinkedService(svc);
|
|
187
|
+
this.guard(svc.getCharacteristic(C.ContactSensorState));
|
|
188
|
+
this.lowSensor = svc;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
removeLowSensor() {
|
|
192
|
+
if (!this.lowSensor) { return; }
|
|
193
|
+
this.guarded = this.guarded.filter((ch) => !this.lowSensor.characteristics.includes(ch));
|
|
194
|
+
this.accessory.removeService(this.lowSensor);
|
|
195
|
+
this.lowSensor = null;
|
|
196
|
+
}
|
|
197
|
+
|
|
167
198
|
/**
|
|
168
199
|
* Home ignores StatusActive on sensors. It shows "No Response" only when a
|
|
169
200
|
* read fails, so while the printer is offline the state reads fail too.
|
|
@@ -178,6 +209,7 @@ class PrinterAccessory {
|
|
|
178
209
|
[this.drum, C.BatteryLevel],
|
|
179
210
|
[this.drum, C.StatusLowBattery],
|
|
180
211
|
[this.problem, C.ContactSensorState],
|
|
212
|
+
[this.lowSensor, C.ContactSensorState],
|
|
181
213
|
...Object.values(this.tiles).map((svc) => [svc, C.CurrentRelativeHumidity]),
|
|
182
214
|
];
|
|
183
215
|
for (const [svc, type] of pairs) {
|
|
@@ -266,6 +298,7 @@ class PrinterAccessory {
|
|
|
266
298
|
this.occupancy.updateCharacteristic(C.StatusActive, online);
|
|
267
299
|
for (const svc of Object.values(this.tiles)) { svc.updateCharacteristic(C.StatusActive, online); }
|
|
268
300
|
if (this.problem) { this.problem.updateCharacteristic(C.StatusActive, online); }
|
|
301
|
+
if (this.lowSensor) { this.lowSensor.updateCharacteristic(C.StatusActive, online); }
|
|
269
302
|
if (!online) {
|
|
270
303
|
this.occupancy.updateCharacteristic(C.OccupancyDetected, 0);
|
|
271
304
|
// Push the failure so Home shows "No Response" without waiting for a read
|
|
@@ -343,6 +376,7 @@ class PrinterAccessory {
|
|
|
343
376
|
this.guarded = this.guarded.filter((ch) => !this.toner.characteristics.includes(ch));
|
|
344
377
|
this.toner = null;
|
|
345
378
|
}
|
|
379
|
+
this.removeLowSensor();
|
|
346
380
|
return;
|
|
347
381
|
}
|
|
348
382
|
if (!this.toner) {
|
|
@@ -363,6 +397,13 @@ class PrinterAccessory {
|
|
|
363
397
|
? C.StatusLowBattery.BATTERY_LEVEL_LOW
|
|
364
398
|
: C.StatusLowBattery.BATTERY_LEVEL_NORMAL);
|
|
365
399
|
|
|
400
|
+
this.ensureLowSensor(kind);
|
|
401
|
+
if (this.lowSensor) {
|
|
402
|
+
this.lowSensor.updateCharacteristic(C.ContactSensorState, low.length || flagged
|
|
403
|
+
? C.ContactSensorState.CONTACT_NOT_DETECTED
|
|
404
|
+
: C.ContactSensorState.CONTACT_DETECTED);
|
|
405
|
+
}
|
|
406
|
+
|
|
366
407
|
this.ensureTiles(d);
|
|
367
408
|
for (const s of d.supplies) {
|
|
368
409
|
if (this.tiles[s.color]) { this.tiles[s.color].updateCharacteristic(C.CurrentRelativeHumidity, clamp(s.level)); }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-brother-printer",
|
|
3
3
|
"displayName": "Brother Printer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "Brother laser and inkjet printers in HomeKit: printing state, problem alerts and toner or ink levels, read locally over SNMP.",
|
|
6
6
|
"author": "Manuel Zamfir",
|
|
7
7
|
"license": "MIT",
|