Skip to content

Commit

Permalink
updating packages, changing GET log level, adding serial number support
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrashears5 committed Jun 4, 2022
1 parent 0850db3 commit dc0f5bf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<b>Automate Homebridge based on interval or cron</b>

[![CI/CD](https://github.com/kbrashears5/typescript-homebridge-schedule/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/kbrashears5/typescript-homebridge-schedule/actions/workflows/ci-cd.yml)
[![codecov](https://codecov.io/gh/kbrashears5/typescript-homebridge-schedule/branch/master/graph/badge.svg?token=06RRABIO9Y)](https://codecov.io/gh/kbrashears5/typescript-homebridge-schedule)
[![npm](https://img.shields.io/npm/v/homebridge-schedule)](https://img.shields.io/npm/v/homebridge-schedule)
[![downloads](https://img.shields.io/npm/dt/homebridge-schedule)](https://img.shields.io/npm/dt/homebridge-schedule)

Expand Down Expand Up @@ -37,17 +36,19 @@ Add accessories to your `config.json` similar to below for interval based schedu
{
"accessory": "Schedule",
"name": "Hourly",
"interval": 60
"interval": 60,
"serial": "123456789"
}
]
}
```

| Property | Description |
| --------- | -------------------------------- |
| Accessory | Must be "Schedule" |
| Name | Unique name for the dummy switch |
| Interval | Interval, in minutes |
| Property | Description |
| --------- | --------------------------------------------------------------------- |
| Accessory | Must be "Schedule" |
| Name | Unique name for the dummy switch |
| Interval | Interval, in minutes |
| Serial | Serial number to give the accessory in HomeKit. Defaults to 123456789 |

Upon startup of Homebridge, the device will turn on at the specified interval

Expand All @@ -65,17 +66,19 @@ Add accessories to your `config.json` similar to below for cron based schedules:
{
"accessory": "Schedule",
"name": "Hourly",
"cron": "* * * * * *"
"cron": "* * * * * *",
"serial": "123456789"
}
]
}
```

| Property | Description |
| --------- | -------------------------------- |
| Accessory | Must be "Schedule" |
| Name | Unique name for the dummy switch |
| Cron | Cron string |
| Property | Description |
| --------- | --------------------------------------------------------------------- |
| Accessory | Must be "Schedule" |
| Name | Unique name for the dummy switch |
| Cron | Cron string |
| Serial | Serial number to give the accessory in HomeKit. Defaults to 123456789 |

Cron string details: https://www.npmjs.com/package/cron

Expand Down
6 changes: 6 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"type": "string",
"required": true
},
"serial": {
"description": "Serial for the schedule accessory (changing this will break existing HomeKit automations), defaults to '123456789'",
"title": "Serial",
"type": "string",
"required": false
},
"interval": {
"title": "Interval",
"type": "number",
Expand Down
34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-schedule",
"version": "1.0.135",
"version": "1.0.136",
"description": "Scheduled, repeatable triggers for Homebridge automation with HomeKit",
"repository": {
"type": "git",
Expand All @@ -23,28 +23,28 @@
],
"main": "dist/schedule-accessory.js",
"dependencies": {
"cron": "~1.8.2",
"typescript-helper-functions": "~1.0.157"
"cron": "~2.0.0",
"typescript-helper-functions": "~1.0.158"
},
"devDependencies": {
"@types/cron": "~1.7.3",
"@types/jest": "~27.4.0",
"@types/node": "~17.0.15",
"@typescript-eslint/eslint-plugin": "~5.10.2",
"@typescript-eslint/parser": "~5.10.2",
"eslint": "~8.8.0",
"eslint-config-prettier": "~8.3.0",
"eslint-plugin-jest": "~26.0.0",
"@types/cron": "~2.0.0",
"@types/jest": "~28.1.0",
"@types/node": "~17.0.39",
"@typescript-eslint/eslint-plugin": "~5.27.0",
"@typescript-eslint/parser": "~5.27.0",
"eslint": "~8.17.0",
"eslint-config-prettier": "~8.5.0",
"eslint-plugin-jest": "~26.4.6",
"eslint-plugin-prettier": "~4.0.0",
"homebridge": "~1.4.0",
"jest": "~27.5.0",
"jest-junit": "~13.0.0",
"homebridge": "~1.4.1",
"jest": "~28.1.0",
"jest-junit": "~13.2.0",
"node-git-hooks": "~1.0.6",
"npm-run-all": "~4.1.5",
"prettier": "~2.5.1",
"prettier": "~2.6.2",
"rimraf": "~3.0.2",
"ts-jest": "~27.1.3",
"typescript": "~4.5.5"
"ts-jest": "~28.0.4",
"typescript": "~4.7.3"
},
"files": [
"LICENSE",
Expand Down
7 changes: 5 additions & 2 deletions src/schedule-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ let hap: HAP;
class ScheduleAccessory implements AccessoryPlugin {
private readonly log: Logging;
private readonly name: string;
private readonly serial: string;
private scheduleOn = false;

private readonly switchService: Service;
Expand All @@ -31,11 +32,13 @@ class ScheduleAccessory implements AccessoryPlugin {

this.log = log;
this.name = config.name;
this.serial = (config.serial ?? '123456789').trim();

// log config parameters
log.debug(`Name: [${config.name}]`);
log.debug(`Interval: [${config.interval}]`);
log.debug(`Cron: [${config.cron}]`);
log.debug(`Serial: [${config.serial}]`);

// determine what was provided by config
let intervalSupplied = true;
Expand Down Expand Up @@ -66,7 +69,7 @@ class ScheduleAccessory implements AccessoryPlugin {
.on(
CharacteristicEventTypes.GET,
(callback: CharacteristicGetCallback) => {
this.log.info(`Schedule: [${this.scheduleOn ? 'ON' : 'OFF'}]`);
this.log.debug(`Schedule: [${this.scheduleOn ? 'ON' : 'OFF'}]`);

callback(undefined, this.scheduleOn);
},
Expand All @@ -92,7 +95,7 @@ class ScheduleAccessory implements AccessoryPlugin {

this.informationService = new hap.Service.AccessoryInformation()
.setCharacteristic(hap.Characteristic.Manufacturer, 'Homebridge Schedule')
.setCharacteristic(hap.Characteristic.SerialNumber, '123456789')
.setCharacteristic(hap.Characteristic.SerialNumber, this.serial)
.setCharacteristic(hap.Characteristic.Model, config.interval);

log.info('Initialization complete');
Expand Down

0 comments on commit dc0f5bf

Please sign in to comment.