Skip to content

Commit 97a8c5f

Browse files
author
Excodibur
committed
Added support for dimming via core:LightIntensityState
1 parent c8f175f commit 97a8c5f

File tree

8 files changed

+9362
-195
lines changed

8 files changed

+9362
-195
lines changed

.github/workflows/build-test-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
node-version: [14.x]
24+
node-version: [14.x, 16.x]
2525

2626
steps:
2727
- uses: actions/checkout@v3

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Placeholder for the next version (add instead of version-number-headline below):
44
## **WORK IN PROGRESS**
55
-->
6+
## 0.8.0 (2022-08-26)
7+
- Added support for dimming via core:LightIntensityState
8+
69
## 0.7.2 (2022-06-15)
710
- Fix switching between local and online api
811

io-package.json

Lines changed: 185 additions & 173 deletions
Large diffs are not rendered by default.

lib/tahoma.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ Tahoma.prototype.getCreateStateOptions4Widget = function (widget) {
199199
"role": "sensor"
200200
};
201201

202+
case "DimmerLight":
203+
return {
204+
"role": "light.dimmer",
205+
"features": {
206+
"intensity": true
207+
}
208+
};
202209
default:
203210
return {
204211
"role": "state"
@@ -253,6 +260,16 @@ Tahoma.prototype.getCreateStateOptions4State = function (widget, stateName) {
253260
"write": true, // mandatory, default true
254261
"role": "switch" // mandatory
255262
};
263+
} else if (stateName === "core:LightIntensityState") {
264+
return {
265+
"type": "number", // optional, default "number"
266+
"read": true, // mandatory, default true
267+
"write": true, // mandatory, default true
268+
"min": 0, // optional, default 0
269+
"max": 100, // optional, default 100
270+
"unit": "W", // optional, default W
271+
"role": "level.dimmer" // mandatory
272+
};
256273
} else {
257274
return {
258275
"read": true,
@@ -1299,11 +1316,11 @@ Tahoma.prototype.updateDeviceState = function (event) {
12991316
if (object.type === "channel") {
13001317
try {
13011318
let subStates;
1302-
if(typeof value === "object") {
1319+
if (typeof value === "object")
13031320
subStates = value;
1304-
} else {
1321+
else
13051322
subStates = JSON.parse(value);
1306-
}
1323+
13071324
const channelPath = key;
13081325
for (const [attrName, attrValue] of Object.entries(subStates)) {
13091326
controller.ackStateValues[channelPath + "." + attrName] = attrValue;
@@ -1382,6 +1399,9 @@ Tahoma.prototype.onApplyChange = function (attribute, id, value, slow) {
13821399
} else if (attribute === "onoff") {
13831400
commandName = "setOnOff";
13841401
stateName = "core:OnOffState";
1402+
} else if (attribute === "intensity") {
1403+
commandName = "setIntensity";
1404+
stateName = "core:LightIntensityState";
13851405
}
13861406

13871407
controller.context.getState(id.substr(0, id.indexOf(".states.")) + ".deviceURL", function (err, state) {
@@ -1547,6 +1567,10 @@ Tahoma.prototype.onOnOffStateChange = function (id, value) {
15471567
return controller.onApplyChange("onoff", id, value);
15481568
};
15491569

1570+
Tahoma.prototype.onIntensityStateChange = function (id, value) {
1571+
return controller.onApplyChange("intensity", id, value);
1572+
};
1573+
15501574
Tahoma.prototype.onExecuteCommand = function (id) {
15511575
controller.context.getState(id.substr(0, id.indexOf(".commands.")) + ".oid", function (err, state) {
15521576
if (!err && state) {

main.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ function processStateChange (id, value) {
174174
controller.onSetOrientation(id, value);
175175
else if (id.match(/^actionGroups.*\.commands\.execute/) && value)
176176
controller.onExecuteCommand(id, value);
177+
else if (id.match(/^devices.*\.states\.core:LightIntensityState$/))
178+
controller.onIntensityStateChange(id, value);
177179
else if (id.match(/^devices.*\.commands\./) && value) {
178180
if (id.endsWith(":slow")) {
179181
adapter.log.debug("Triggered command with slow mode: " + id);

0 commit comments

Comments
 (0)