Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Shelly1AddOn #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The following Shelly devices are supported:
* [Shelly 1](https://shelly.cloud/shelly1-open-source/)
* [Shelly 1L](https://shelly.cloud/products/shelly-1l-single-wire-smart-home-automation-relay/)
* [Shelly 1PM](https://shelly.cloud/shelly-1pm-wifi-smart-relay-home-automation/)
* [Shelly 1AddOn](https://shop.shelly.cloud/temperature-sensor-addon-for-shelly-1-1pm-wifi-smart-home-automation)
* Shelly 2
* [Shelly 2.5](https://shelly.cloud/shelly-25-wifi-smart-relay-roller-shutter-home-automation/)
* Shelly 2LED
Expand Down
55 changes: 55 additions & 0 deletions lib/devices/shelly-1-addon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
class Shelly1AddOn {
constructor(device) {
this.device = device
}

async setExternalSensorTemperatureUnit(fahrenheit) {
await this.device.request
.get(`${this.device.host}/settings`)
.query(
{ ext_sensors_temperature_unit: fahrenheit ? 'F' : 'C' }
)
}

async setExternalTemperatureAct(index, overAct, underAct) {
await this.device.request
.get(`${this.device.host}/settings/ext_temperature/${index}`)
.query(
{
overtemp_act: overAct,
undertemp_act: underAct
})
}

async setExternalTemperatureThreshold(index, overtemp, undertemp) {
await this.device.request
.get(`${this.device.host}/settings/ext_temperature/${index}`)
.query(
{
overtemp_threshold_tC: overtemp,
undertemp_threshold_tC: undertemp
})
}

async setExternalHumidityAct(index, overAct, underAct) {
await this.device.request
.get(`${this.device.host}/settings/ext_humidity/${index}`)
.query(
{
overhum_act: overAct,
underhum_act: underAct
})
}

async setExternalHumidityThreshold(index, overhum, underhum) {
await this.device.request
.get(`${this.device.host}/settings/ext_humidity/${index}`)
.query(
{
overhum_threshold: overhum,
underhum_threshold: underhum
})
}
}

module.exports = Shelly1AddOn
3 changes: 3 additions & 0 deletions lib/devices/shelly-1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { Switch } = require('./base')
const Shelly1AddOn = require('./shelly-1-addon')

class Shelly1 extends Switch {
constructor(id, host) {
Expand All @@ -17,6 +18,8 @@ class Shelly1 extends Switch {
this._defineProperty('externalHumidity', [3103], null, Number)

this._defineProperty('externalInput0', [3117], null, Number)

this.addon = new Shelly1AddOn(this)
}
}

Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

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