Skip to content

Commit

Permalink
Support for Shelly1AddOn
Browse files Browse the repository at this point in the history
  • Loading branch information
tritter committed Sep 3, 2021
1 parent f83b5d0 commit 5e8c01b
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,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

0 comments on commit 5e8c01b

Please sign in to comment.