@@ -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+
15501574Tahoma . prototype . onExecuteCommand = function ( id ) {
15511575 controller . context . getState ( id . substr ( 0 , id . indexOf ( ".commands." ) ) + ".oid" , function ( err , state ) {
15521576 if ( ! err && state ) {
0 commit comments