-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
353 additions
and
5 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,32 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: npm publish | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish --access=public | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
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 |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
.AppleDouble | ||
.LSOverride | ||
|
||
# Compile | ||
out | ||
|
||
# Logs | ||
logs | ||
*.log | ||
|
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,49 @@ | ||
import { BinarySensor, Online, ScryptedDeviceBase, Setting, SettingValue, Settings } from "@scrypted/sdk"; | ||
import { StorageSettings, StorageSettingsDevice } from "@scrypted/sdk/storage-settings"; | ||
|
||
export class MoenBase extends ScryptedDeviceBase implements Online, Settings, BinarySensor, StorageSettingsDevice { | ||
storageSettings = new StorageSettings(this, { | ||
exposeCriticalNotificationsToSecuritySystem: { | ||
title: "Expose Critical Notifications to Security System", | ||
type: "boolean", | ||
description: "Expose notifications as a BinarySensor for the Security System to alert on.", | ||
readonly: true | ||
}, | ||
exposeWarningNotificationsToSecuritySystem: { | ||
title: "Expose Warning Notifications to Security System", | ||
type: "boolean", | ||
description: "Expose notifications as a BinarySensor for the Security System to alert on.", | ||
readonly: true | ||
} | ||
}); | ||
|
||
constructor(nativeId?: string) { | ||
super(nativeId); | ||
} | ||
|
||
getSettings(): Promise<Setting[]> { | ||
return this.storageSettings.getSettings(); | ||
} | ||
|
||
putSetting(key: string, value: SettingValue): Promise<void> { | ||
return this.storageSettings.putSetting(key, value); | ||
} | ||
|
||
refresh (data: any) { | ||
this.online = data.isConnected; | ||
|
||
let alarm: boolean = false; | ||
|
||
if (this.storageSettings.values.exposeCriticalNotificationsToSecuritySystem) | ||
alarm = data.notifications.criticalCount > 0; | ||
|
||
if (this.storageSettings.values.exposeWarningNotificationsToSecuritySystem) | ||
alarm = alarm || data.notifications.warningCount > 0; | ||
|
||
this.binaryState = alarm; | ||
} | ||
|
||
convertToCelsius (tempF: number) { | ||
return (tempF - 32) * 5/9; | ||
} | ||
} |
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,8 @@ | ||
import { Battery, OnOff, Online, ScryptedDeviceBase, Thermometer } from "@scrypted/sdk"; | ||
import { MoenBase } from "./MoenBase"; | ||
|
||
export class MoenFaucet extends MoenBase implements OnOff, Battery, Thermometer { | ||
constructor(nativeId: string) { | ||
super(nativeId); | ||
} | ||
} |
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,23 @@ | ||
import { Battery, FloodSensor, HumiditySensor, Online, ScryptedDeviceBase, TemperatureUnit, Thermometer } from "@scrypted/sdk"; | ||
import { MoenBase } from "./MoenBase"; | ||
|
||
export class MoenLeakSensor extends MoenBase implements Battery, Thermometer, HumiditySensor, FloodSensor { | ||
constructor(nativeId?: string, data?: any) { | ||
super(nativeId); | ||
|
||
this.refresh(data); | ||
} | ||
|
||
refresh (data: any) { | ||
super.refresh(data); | ||
|
||
this.temperature = this.convertToCelsius(data.fwProperties.telemetry_temperature); | ||
this.humidity = data.fwProperties.telemetry_humidity; | ||
this.batteryLevel = data.fwProperties.telemetry_battery_percent; | ||
this.flooded = data.fwProperties.telemetry_water; | ||
} | ||
|
||
setTemperatureUnit(temperatureUnit: TemperatureUnit): Promise<void> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
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,11 @@ | ||
import { Battery, FloodSensor, HumiditySensor, Online, ScryptedDeviceBase, TemperatureUnit, Thermometer } from "@scrypted/sdk"; | ||
import { MoenBase } from "./MoenBase"; | ||
|
||
export class MoenSumpPumpSensor extends MoenBase implements Battery, Thermometer, HumiditySensor, FloodSensor { | ||
constructor(nativeId?: string) { | ||
super(nativeId); | ||
} | ||
setTemperatureUnit(temperatureUnit: TemperatureUnit): Promise<void> { | ||
throw new Error("Method not implemented."); | ||
} | ||
} |
Oops, something went wrong.