Skip to content

Commit

Permalink
v2.0.2 (#524)
Browse files Browse the repository at this point in the history
## [2.0.2](https://github.com/donavanbecker/homebridge-rainbird/releases/tag/v2.0.2) (2024-02-13)

### What's Changed
- Housekeeping and updated dependencies.

**Full Changelog**: v2.0.1...v2.0.2
  • Loading branch information
donavanbecker authored Feb 13, 2024
1 parent 302f097 commit 48c8fde
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 59 deletions.
1 change: 0 additions & 1 deletion .github/workflows/beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ jobs:
with:
footer_title: "RainBird"
secrets:
DISCORD_WEBHOOK_URL_LATEST: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}
DISCORD_WEBHOOK_URL_BETA: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }}
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ jobs:
footer_title: "RainBird"
secrets:
DISCORD_WEBHOOK_URL_LATEST: ${{ secrets.DISCORD_WEBHOOK_URL_LATEST }}
DISCORD_WEBHOOK_URL_BETA: ${{ secrets.DISCORD_WEBHOOK_URL_BETA }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file. This project uses [Semantic Versioning](https://semver.org/)

## [2.0.2](https://github.com/donavanbecker/homebridge-rainbird/releases/tag/v2.0.2) (2024-02-13)

### What's Changed
- Housekeeping and updated dependencies.

**Full Changelog**: https://github.com/donavanbecker/homebridge-rainbird/compare/v2.0.1...v2.0.2

## [2.0.1](https://github.com/donavanbecker/homebridge-rainbird/releases/tag/v2.0.1) (2024-02-13)

### What's Changed
Expand Down
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Rainbird",
"name": "homebridge-rainbird",
"version": "2.0.1",
"version": "2.0.2",
"description": "The Rainbird plugin allows you to access your Rainbird device(s) from HomeKit.",
"homepage": "https://github.com/donavanbecker/homebridge-rainbird#readme",
"author": {
Expand Down
9 changes: 7 additions & 2 deletions src/devices/ContactSensor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* ContactSensor.ts: homebridge-rainbird.
*/
import { Service, CharacteristicValue, PlatformAccessory } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { fromEvent } from 'rxjs';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

/**
* Platform Accessory
Expand Down
9 changes: 7 additions & 2 deletions src/devices/DelayIrrigationSwitch.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* DelayIrrigationSwitch.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

export class DelayIrrigationSwitch extends DeviceBase {
// Service
Expand Down
81 changes: 57 additions & 24 deletions src/devices/DeviceBase.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* DeviceBase.ts: homebridge-rainbird.
*/
import { API, HAP, Logging, PlatformAccessory } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';

import { RainbirdPlatform } from '../platform.js';
import { DevicesConfig, RainbirdPlatformConfig } from '../settings.js';

export abstract class DeviceBase {
public readonly api: API;
public readonly log: Logging;
public readonly config!: RainbirdPlatformConfig;
protected readonly hap: HAP;
// Service

// Config
protected deviceLogging!: string;
Expand All @@ -25,8 +29,10 @@ export abstract class DeviceBase {
this.config = this.platform.config;
this.hap = this.api.hap;

this.logs(device);
this.refreshRate(device);
this.deviceLogs(device);
this.getDeviceRefreshRate(device);
this.deviceConfigOptions(device);
this.deviceContext(accessory, device);

// Set accessory information
accessory
Expand All @@ -39,29 +45,56 @@ export abstract class DeviceBase {
.updateValue(accessory.context.FirmwareRevision);
}

logs(device: DevicesConfig) {
async deviceLogs(device: DevicesConfig): Promise<void> {
if (this.platform.debugMode) {
this.deviceLogging = this.accessory.context.logging = 'debugMode';
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
this.debugWarnLog(`Lock: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
} else if (device.logging) {
this.deviceLogging = this.accessory.context.logging = device.logging;
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
} else if (this.platform.config.options?.logging) {
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
this.debugWarnLog(`Lock: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
} else if (this.config.logging) {
this.deviceLogging = this.accessory.context.logging = this.config.logging;
this.debugWarnLog(`Lock: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
} else {
this.deviceLogging = this.accessory.context.logging = 'standard';
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
this.debugWarnLog(`Lock: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
}
}

refreshRate(device: DevicesConfig) {
async getDeviceRefreshRate(device: DevicesConfig): Promise<void> {
if (device.refreshRate) {
if (device.refreshRate < 1800) {
device.refreshRate = 1800;
this.warnLog('Refresh Rate cannot be set to lower the 5 mins, as Lock detail (battery level, etc) are unlikely to change within that period');
}
this.deviceRefreshRate = this.accessory.context.refreshRate = device.refreshRate;
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
} else if (this.platform.config.options!.refreshRate) {
this.deviceRefreshRate = this.accessory.context.refreshRate = this.platform.config.options!.refreshRate;
this.debugLog(`${this.constructor.name}: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
this.debugLog(`Lock: ${this.accessory.displayName} Using Device Config refreshRate: ${this.deviceRefreshRate}`);
} else if (this.config.refreshRate) {
this.deviceRefreshRate = this.accessory.context.refreshRate = this.config.refreshRate;
this.debugLog(`Lock: ${this.accessory.displayName} Using Platform Config refreshRate: ${this.deviceRefreshRate}`);
}
}

async deviceConfigOptions(device: DevicesConfig): Promise<void> {
const deviceConfig = {};
if (device.logging !== undefined) {
deviceConfig['logging'] = device.logging;
}
if (device.refreshRate !== undefined) {
deviceConfig['refreshRate'] = device.refreshRate;
}
if (Object.entries(deviceConfig).length !== 0) {
this.infoLog(`Lock: ${this.accessory.displayName} Config: ${JSON.stringify(deviceConfig)}`);
}
}

async deviceContext(accessory: PlatformAccessory, device: DevicesConfig): Promise<void> {
if (device.firmware) {
accessory.context.FirmwareRevision = device.firmware;
} else if (accessory.context.FirmwareRevision === undefined) {
accessory.context.FirmwareRevision = await this.platform.getVersion();
} else {
accessory.context.FirmwareRevision = '3';
}
}

Expand All @@ -70,44 +103,44 @@ export abstract class DeviceBase {
*/
infoLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
this.platform.log.info(String(...log));
this.log.info(String(...log));
}
}

warnLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
this.platform.log.warn(String(...log));
this.log.warn(String(...log));
}
}

debugWarnLog({ log = [] }: { log?: any[]; } = {}): void {
debugWarnLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
if (this.deviceLogging?.includes('debug')) {
this.platform.log.warn('[DEBUG]', String(...log));
this.log.warn('[DEBUG]', String(...log));
}
}
}

errorLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
this.platform.log.error(String(...log));
this.log.error(String(...log));
}
}

debugErrorLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
if (this.deviceLogging?.includes('debug')) {
this.platform.log.error('[DEBUG]', String(...log));
this.log.error('[DEBUG]', String(...log));
}
}
}

debugLog(...log: any[]): void {
if (this.enablingDeviceLogging()) {
if (this.deviceLogging === 'debug') {
this.platform.log.info('[DEBUG]', String(...log));
this.log.info('[DEBUG]', String(...log));
} else {
this.platform.log.debug(String(...log));
this.log.debug(String(...log));
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/devices/IrrigationSystem.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* IrrigationSystem.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { Subject, fromEvent, interval } from 'rxjs';
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

/**
* Platform Accessory
Expand Down
9 changes: 7 additions & 2 deletions src/devices/LeakSensor.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* LeakSensor.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { fromEvent } from 'rxjs';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

export class LeakSensor extends DeviceBase {
// Service
Expand Down
9 changes: 7 additions & 2 deletions src/devices/ProgramSwitch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* ProgramSwitch.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { fromEvent } from 'rxjs';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

export class ProgramSwitch extends DeviceBase {
private programSwitch!: {
Expand Down
9 changes: 7 additions & 2 deletions src/devices/StopIrrigationSwitch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* StopIrrigationSwitch.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { fromEvent } from 'rxjs';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

export class StopIrrigationSwitch extends DeviceBase {
private stopIrrigationSwitch!: {
Expand Down
9 changes: 7 additions & 2 deletions src/devices/ZoneValve.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* ZoneValue.ts: homebridge-rainbird.
*/
import { Service, PlatformAccessory, CharacteristicValue, UnknownContext } from 'homebridge';
import { RainbirdPlatform } from '../platform.js';
import { RainBirdService } from 'rainbird';
import { fromEvent, interval, Subject } from 'rxjs';
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
import { DevicesConfig } from '../settings.js';

import { DeviceBase } from './DeviceBase.js';
import { DevicesConfig } from '../settings.js';
import { RainbirdPlatform } from '../platform.js';

export class ZoneValve extends DeviceBase {
private zoneId: number;
Expand Down
5 changes: 4 additions & 1 deletion src/homebridge-ui/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable no-console */
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* server.ts: homebridge-rainbird.
*/
import { HomebridgePluginUiServer } from '@homebridge/plugin-ui-utils';
import fs from 'fs';

Expand Down
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
/* Copyright(C) 2021-2023, donavanbecker (https://github.com/donavanbecker). All rights reserved.
/* Copyright(C) 2021-2024, donavanbecker (https://github.com/donavanbecker) & mantorok1 (https://github.com/mantorok1). All rights reserved.
*
* index.ts: homebridge-noip plugin registration.
* index.ts: homebridge-rainbird.
*/
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
import { API } from 'homebridge';

import { RainbirdPlatform } from './platform.js';
import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';

// Register our platform with homebridge.
export default (api: API): void => {
Expand Down
Loading

0 comments on commit 48c8fde

Please sign in to comment.