-
Notifications
You must be signed in to change notification settings - Fork 14
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
1 parent
6c97e8d
commit 06ef18d
Showing
14 changed files
with
669 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
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,15 @@ | ||
export const AIRCO_CAPABILITIES_MAPPING = { | ||
switch: 'onoff', | ||
temp_set: 'target_temperature', | ||
temp_current: 'measure_temperature', | ||
humidity_set: 'target_humidity', | ||
humidity_current: 'measure_humidity', | ||
lock: 'child_lock', | ||
} as const; | ||
|
||
export type HomeySocketSettings = { | ||
temp_set_scaling: '0' | '1' | '2' | '3'; | ||
temp_current_scaling: '0' | '1' | '2' | '3'; | ||
humidity_set_scaling: '0' | '1' | '2' | '3'; | ||
humidity_current_scaling: '0' | '1' | '2' | '3'; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,86 @@ | ||
import TuyaOAuth2Device from '../../lib/TuyaOAuth2Device'; | ||
import { TuyaStatus } from '../../types/TuyaTypes'; | ||
|
||
module.exports = class TuyaOAuth2DeviceHeater extends TuyaOAuth2Device { | ||
async onOAuth2Init(): Promise<void> { | ||
await super.onOAuth2Init(); | ||
|
||
if (this.hasCapability('onoff')) { | ||
this.registerCapabilityListener('onoff', value => this.onOffCapabilityListener(value)); | ||
} | ||
|
||
if (this.hasCapability('target_temperature')) { | ||
this.registerCapabilityListener('target_temperature', value => this.targetTemperatureCapabilityListener(value)); | ||
} | ||
|
||
if (this.hasCapability('target_humidity')) { | ||
this.registerCapabilityListener('target_humidity', value => this.targetHumidityCapabilityListener(value)); | ||
} | ||
|
||
if (this.hasCapability('child_lock')) { | ||
this.registerCapabilityListener('child_lock', value => this.childLockCapabilityListener(value)); | ||
} | ||
} | ||
|
||
async onTuyaStatus(status: TuyaStatus, changedStatusCodes: string[]): Promise<void> { | ||
await super.onTuyaStatus(status, changedStatusCodes); | ||
|
||
if (typeof status['switch'] === 'boolean') { | ||
this.setCapabilityValue('onoff', status['switch']).catch(this.error); | ||
} | ||
|
||
if (typeof status['temp_current'] === 'number') { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('temp_current_scaling') ?? '0', 10); | ||
this.setCapabilityValue('measure_temperature', status['temp_current'] / scaling).catch(this.error); | ||
} | ||
|
||
if (typeof status['temp_set'] === 'number') { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('temp_set_scaling') ?? '0', 10); | ||
this.setCapabilityValue('target_temperature', status['temp_set'] / scaling).catch(this.error); | ||
} | ||
|
||
if (typeof status['humidity_current'] === 'number') { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('temp_current_scaling') ?? '0', 10); | ||
this.setCapabilityValue('measure_humidity', status['humidity_current'] / scaling).catch(this.error); | ||
} | ||
|
||
if (typeof status['humidity_set'] === 'number') { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('temp_set_scaling') ?? '0', 10); | ||
this.setCapabilityValue('target_humidity', status['humidity_set'] / scaling).catch(this.error); | ||
} | ||
|
||
if (typeof status['lock'] === 'boolean') { | ||
this.setCapabilityValue('child_lock', status['lock']).catch(this.error); | ||
} | ||
} | ||
|
||
async onOffCapabilityListener(value: boolean): Promise<void> { | ||
await this.sendCommand({ | ||
code: 'switch', | ||
value: value, | ||
}); | ||
} | ||
|
||
async targetTemperatureCapabilityListener(value: number): Promise<void> { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('temp_set_scaling') ?? '0', 10); | ||
await this.sendCommand({ | ||
code: 'temp_set', | ||
value: value * scaling, | ||
}); | ||
} | ||
|
||
async targetHumidityCapabilityListener(value: number): Promise<void> { | ||
const scaling = 10.0 ** Number.parseInt(this.getSetting('humidity_set_scaling') ?? '0', 10); | ||
await this.sendCommand({ | ||
code: 'humidity_set', | ||
value: value * scaling, | ||
}); | ||
} | ||
|
||
async childLockCapabilityListener(value: boolean): Promise<void> { | ||
await this.sendCommand({ | ||
code: 'lock', | ||
value: value, | ||
}); | ||
} | ||
}; |
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,9 @@ | ||
{ | ||
"$extends": "tuya", | ||
"class": "airconditioning", | ||
"name": { | ||
"en": "Air Conditioning", | ||
"nl": "Airconditioning" | ||
}, | ||
"capabilities": ["onoff", "target_temperature", "measure_temperature"] | ||
} |
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 @@ | ||
{ | ||
"actions": [ | ||
{ | ||
"id": "airco_set_child_lock", | ||
"$filter": "capabilities=child_lock", | ||
"title": { | ||
"en": "Set child lock" | ||
}, | ||
"titleFormatted": { | ||
"en": "Set child lock [[value]]" | ||
}, | ||
"args": [ | ||
{ | ||
"name": "value", | ||
"type": "checkbox", | ||
"title": { "en": "Value" } | ||
} | ||
] | ||
} | ||
], | ||
"conditions": [], | ||
"triggers": [] | ||
} |
Oops, something went wrong.