onInit() {
        id = this.getData().id;
        const settings = this.getSettings();
        ipAddr = settings.ip;
        devices = new Command(ipAddr, null);

        isState = devices.getState(ipAddr);
        isDimming = true;
        this.setCapabilityValue('onoff', isState);

        this.pollDevice(id);

        var kod = devices.getState(ipAddr);
        this.registerCapabilityListener("onoff", async (value) => {
            const settings = this.getSettings();
            return await devices.setOnOff(settings.ip, value);
		});

        if (isDimming) {
            var dimdata = devices.getDimming(ipAddr);
            this.setCapabilityValue('dim', dimdata);
            this.registerCapabilityListener("dim", async (value) => {
                if (value < 0) {
                    value = 0;
                } else if(value > 100) {
                    value = 100;
                }
                const settings = this.getSettings();
                devices.setBrightness(settings.ip, value);
			});
		}
	}
// this method is called when the Device is inited

this method is called when the Device is inited
this method is called when the Device is inited
onInit() {
        id = this.getData().id;
        const settings = this.getSettings();
        ipAddr = settings.ip;
        devices = new Command(ipAddr, null);
        isState = devices.getState(ipAddr);
        isDimming = true;
        this.setCapabilityValue('onoff', isState);
        this.pollDevice(id);
        var kod = devices.getState(ipAddr);
        this.registerCapabilityListener("onoff", async (value) => {
            const settings = this.getSettings();
            return await devices.setOnOff(settings.ip, value);
		});
        if (isDimming) {
            var dimdata = devices.getDimming(ipAddr);
            this.setCapabilityValue('dim', dimdata);
            this.registerCapabilityListener("dim", async (value) => {
                if (value < 0) {
                    value = 0;
                } else if(value > 100) {
                    value = 100;
                }
                const settings = this.getSettings();
                devices.setBrightness(settings.ip, value);
			});
		}
	}
onInit ( ) { id = this . getData ( ) . id ; const settings = this . getSettings ( ) ; ipAddr = settings . ip ; devices = new Command ( ipAddr , null ) ; isState = devices . getState ( ipAddr ) ; isDimming = true ; this . setCapabilityValue ( 'onoff' , isState ) ; this . pollDevice ( id ) ; var kod = devices . getState ( ipAddr ) ; this . registerCapabilityListener ( "onoff" , async ( value ) => { const settings = this . getSettings ( ) ; return await devices . setOnOff ( settings . ip , value ) ; } ) ; if ( isDimming ) { var dimdata = devices . getDimming ( ipAddr ) ; this . setCapabilityValue ( 'dim' , dimdata ) ; this . registerCapabilityListener ( "dim" , async ( value ) => { if ( value < 0 ) { value = 0 ; } else if ( value > 100 ) { value = 100 ; } const settings = this . getSettings ( ) ; devices . setBrightness ( settings . ip , value ) ; } ) ; } }
this method is called when the Device is inited
this method is called when the Device is inited