-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1450 Squashed commit of the following: commit 81cfb8a52c1d0ad106ebbcc47d52998f0c9e35c4 Author: dgreif <[email protected]> Date: Fri Aug 9 09:15:03 2024 -0400 Update readme commit cd14182ba037988b47963c874959f841bc16bfd3 Author: dgreif <[email protected]> Date: Fri Aug 9 09:09:16 2024 -0400 Fix lint commit 49aba72627253519ab01c5da7ddd1e87ecac7ca4 Author: dgreif <[email protected]> Date: Fri Aug 9 09:09:00 2024 -0400 Release notes commit 5029d2c Author: Vyacheslav Andreykiv <[email protected]> Date: Fri Aug 9 06:02:35 2024 -0700 Added water valve support (#1451) Co-authored-by: Vyacheslav Andreykiv <[email protected]>
- Loading branch information
Showing
5 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'homebridge-ring': minor | ||
'ring-client-api': minor | ||
--- | ||
|
||
Add support for water valves. Note, these have not been tested extensively so please let us know if you run into issues. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { BaseDeviceAccessory } from './base-device-accessory' | ||
import type { RingDevice } from 'ring-client-api' | ||
import { hap } from './hap' | ||
import { RingPlatformConfig } from './config' | ||
import { PlatformAccessory } from 'homebridge' | ||
import { logInfo } from 'ring-client-api/util' | ||
|
||
export class Valve extends BaseDeviceAccessory { | ||
constructor( | ||
public readonly device: RingDevice, | ||
public readonly accessory: PlatformAccessory, | ||
public readonly config: RingPlatformConfig, | ||
) { | ||
super() | ||
|
||
const { Characteristic, Service } = hap | ||
|
||
this.registerCharacteristic({ | ||
characteristicType: Characteristic.On, | ||
serviceType: Service.Switch, | ||
getValue: (data) => this.isOpen(data.valveState), | ||
setValue: (value) => this.setOnState(value), | ||
}) | ||
} | ||
|
||
isOpen(status: RingDevice['data']['valveState']): boolean { | ||
if (status === 'open') { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
setOnState(on: boolean) { | ||
logInfo(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`) | ||
if (on) { | ||
return this.device.sendCommand('valve.open') | ||
} | ||
return this.device.sendCommand('valve.close') | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters