Fibaro RGBW Controller 2: Missing devices

For Z-Wave related questions in Domoticz

Moderator: leecollings

Post Reply
arjanm83
Posts: 14
Joined: Tuesday 15 November 2016 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Fibaro RGBW Controller 2: Missing devices

Post by arjanm83 »

When adding the Fibaro RGBW Controller 2 to Domoticz, I'm missing some devices.
The device needed to switch on/off/dim the light is missing. I tried all devices that were found, but these are not working.
Just the following devices are discovered:

RGBW Controller 2.PNG
RGBW Controller 2.PNG (69.38 KiB) Viewed 2003 times


I want to switch 12v halogen lights connected to the "R"/"Out 1" channel as shown in the manual:

Halogen.PNG
Halogen.PNG (21.88 KiB) Viewed 2003 times

I'm running two instances of Domoticz: 2020.1 and 4.9700. Both instances show the same problem.
For the 2020.1 instance I tried adding the fgrgbw442.xml file and editing the manufacturer_specific.xml as described here: https://www.domoticz.com/forum/viewtopi ... 26#p227691.
These steps resulted in correctly recognizing the module when including, but still not all devices are added.

I know some devices are missing because I included the module to a Fibaro Home Center Lite.
With the Fibaro Home Center Lite more devices are shown and I can switch on/off/dim the light without any problem.
So all wires are connected correctly, I just miss the device in Domoticz to apply the action to.

Anything I can try to have Domoticz find the missing devices?
arjanm83
Posts: 14
Joined: Tuesday 15 November 2016 17:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by arjanm83 »

After discussing this with the author of the adjusted xml files for the FGRGBW-442 he states that the XML-files aren't finished and need further work. That's probably the reason not all devices are being found.

He also states that open-zwave might only support version 2 of the command class color switch and that the module is using version 3. But he's not sure if this is causing the problem.

Concluding, the open-zwave implementation for this device needs further work.
hestia
Posts: 357
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by hestia »

Hi
do you know if there was any progress since then
Concluding, the open-zwave implementation for this device needs further work.
?
Stief
Posts: 11
Joined: Sunday 22 April 2018 7:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Stief »

Any New info on this?
I have 2 of these controllers and can't seem to get them to work. I also manually added the xml and the controllers are seen in Domoticz. But they don't switch anything.
I want to use it als a controller for RGB Led strips. The older version of the controller works just fine. But the version 2 gives me a headeg. I also tried checking it with a mulimeter but when switching it from Domoticz nothing happens ont Out 1 - 4.
ArvidHamersma
Posts: 2
Joined: Sunday 21 February 2021 22:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by ArvidHamersma »

Here the same issue.
With altering the XML's the hardware is reconized, but no devices. :?
When will this issue be resolved? :?:
stuffer
Posts: 12
Joined: Sunday 07 June 2015 9:36
Target OS: Linux
Domoticz version: 3.6367
Location: Utrecht
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by stuffer »

Ok, I had my question ready for a new post but it seems that there are more problems with the Fibaro RGBW2 controller in combination with Domoticz.

I bought 2 new Fibaro2 RGBW controllers (Fibaro RGBW Controller 2), prepared and connected the led strip, included module on the latest stable (2020.2.11995).
Devices are visible but LED strip does not turn on. Checked everything again but doesn't seem to work.

To make sure that it is not my connection skills, I connected a different LED strip, a different power supply, and also the 2nd Fibaro RGBW dimmer. Same result.

Because the controller was released on September 25, 2020, I first excluded the dimmers, brought Domoticz to the latest version through: ./updatebeta, reboot and again included 1 of the RGBW controllers.

Unfortunately still the same result.

To exclude the power supply again and my connection skills, I took a Fibaro RGBW Controller (version 1) out of an existing situation and connected it. Then everything works fine.

Is there any news on this Fibaro RGBW2 controller to include and getting it to work?


------------------------------------EDIT-----------------------------------------------

It seems that this would be the solution to get it to work: https://github.com/domoticz/domoticz/issues/4690
Stief
Posts: 11
Joined: Sunday 22 April 2018 7:36
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Stief »

I ended up returning my v2 controllers and bought a few second hand V1's for a great price.
ArvidHamersma
Posts: 2
Joined: Sunday 21 February 2021 22:08
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Location: Netherlands
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by ArvidHamersma »

Can't return it...
If this isn't resolved anytime soon I'm forced to abandon Domoticz throwing away 2 years of configuring and finetuning
Groentjuh
Posts: 5
Joined: Monday 19 April 2021 0:52
Target OS: Linux
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Groentjuh »

I noticed something that someone might want to look into...

There's a huge difference in pairing this device using "Secure include" and "Include". Most noticeably the missing of the 5 dimmer switch devices you can actually use to control this device in Domoticz! When using "Secure include" is shows up as above, when using "Include" it will be 24+ devices!
- 6 Dimmer switches
- 6 General Voltage measure devices
- Numerous on-/off switches. (Many for scenes)

And most of those are missing somehow when using "Secure include".
gmarchionni
Posts: 13
Joined: Sunday 11 June 2017 0:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by gmarchionni »

Groentjuh wrote: Monday 19 April 2021 1:13 I noticed something that someone might want to look into...

There's a huge difference in pairing this device using "Secure include" and "Include". Most noticeably the missing of the 5 dimmer switch devices you can actually use to control this device in Domoticz! When using "Secure include" is shows up as above, when using "Include" it will be 24+ devices!
- 6 Dimmer switches
- 6 General Voltage measure devices
- Numerous on-/off switches. (Many for scenes)

And most of those are missing somehow when using "Secure include".
found out the same thing.
sciroccojc
Posts: 11
Joined: Thursday 26 March 2020 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by sciroccojc »

Has anyone been able to get these devices working on Domoticz? I was able to get it paired and I have 24 devices showing up in my device list. When I click on the RGBWWZ or the RGBW switches the lights will turn on but I am not able to change the color of the lights. Every time I change the color on the color wheel, I get an error in the event log.

2021-08-18 11:58:38.443 Error: Z-Stick: OpenZWave: Value_Changed: Tried adding value, not succeeded!. Node: 94 (0x5e), CommandClass: COLOR, Label: Target Color, Instance: 1, Index: 5
Groentjuh
Posts: 5
Joined: Monday 19 April 2021 0:52
Target OS: Linux
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Groentjuh »

sciroccojc wrote: Wednesday 18 August 2021 17:58 Has anyone been able to get these devices working on Domoticz? I was able to get it paired and I have 24 devices showing up in my device list. When I click on the RGBWWZ or the RGBW switches the lights will turn on but I am not able to change the color of the lights. Every time I change the color on the color wheel, I get an error in the event log.

2021-08-18 11:58:38.443 Error: Z-Stick: OpenZWave: Value_Changed: Tried adding value, not succeeded!. Node: 94 (0x5e), CommandClass: COLOR, Label: Target Color, Instance: 1, Index: 5
You've got probably 5+ Dimmer switches. 1 Dimmers switch is all over power, 1 dimmer switch is for Red, 1 dimmer switch is for Green, 1 dimmer switch is for Blue, 1 dimmer switch is for White. Setting color using that RGBWWZ device is not working for me either.

I did make a DzVent script once map a virtual RGBWWZ device to the 5 switch devices.
sciroccojc
Posts: 11
Joined: Thursday 26 March 2020 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by sciroccojc »

OK, so it's not just me then... I have a total of 8 dimmer switches. Two of them are the switches labeled as RGBW and RGBWWZ.

I created the following script to change the Red Green and Blue dimmer switches depending on the color set on the color wheel. Unfortunately, this only works if I set the color using a voice command from Alexa. Trying to pick the exact color for red on the color wheel from the mobile app would be just about impossible. The scripts work pretty well, but it would be nice to be able to control the color from my phone as well.

Code: Select all

return {
	on = {
		devices = {
	        'Kitchen Cabinet LED'
	    },
	},
	execute = function(domoticz, triggeredItem)
        local red = domoticz.devices('Cabinet LED - Red')
        local green = domoticz.devices('Cabinet LED - Green')
        local blue = domoticz.devices('Cabinet LED - Blue')
        local softwhite = domoticz.devices('Cabinet LED - Soft White')
        if (triggeredItem.active) then
            -- If color is "Red"
            if (triggeredItem.color == '{"b":0,"cw":0,"g":0,"m":3,"r":255,"t":0,"ww":0}') then
                red.dimTo(100)
                green.switchOff()
                blue.switchOff()
            -- If color is "Green"
            elseif (triggeredItem.color == '{"b":0,"cw":0,"g":255,"m":3,"r":0,"t":0,"ww":0}') then
                red.switchOff()
                green.dimTo(100)
                blue.switchOff()
            -- If color is "Blue"
            elseif (triggeredItem.color == '{"b":255,"cw":0,"g":0,"m":3,"r":0,"t":0,"ww":0}') then
                red.switchOff()
                green.switchOff()
                blue.dimTo(100)
            -- If color is "Yellow"
            elseif (triggeredItem.color == '{"b":0,"cw":0,"g":255,"m":3,"r":255,"t":0,"ww":0}') then
                red.dimTo(100)
                green.dimTo(50)
                blue.switchOff()
            -- If color is "Pink"
            elseif (triggeredItem.color == '{"b":203,"cw":0,"g":190,"m":3,"r":255,"t":0,"ww":0}') then
                red.dimTo(100)
                green.switchOff()
                blue.dimTo(50)
             -- If color is "Orange"
            elseif (triggeredItem.color == '{"b":0,"cw":0,"g":165,"m":3,"r":255,"t":0,"ww":0}') then
                red.dimTo(100)
                green.dimTo(30)
                blue.switchOff()
             -- If color is "Purple"
            elseif (triggeredItem.color == '{"b":255,"cw":0,"g":35,"m":3,"r":170,"t":0,"ww":0}') then
                red.dimTo(100)
                green.dimTo(5)
                blue.dimTo(50)
             -- If color is "Soft White"
            elseif (triggeredItem.color == '{"b":0,"cw":51,"g":0,"m":2,"r":0,"t":204,"ww":204}') then
                red.switchOff()
                green.switchOff()
                blue.switchOff()
                softwhite.switchOn()
             -- If color is "White"
            elseif (triggeredItem.color == '{"b":0,"cw":178,"g":0,"m":2,"r":0,"t":77,"ww":77}') then
                red.dimTo(100)
                green.dimTo(100)
                blue.dimTo(100)
                
            end
        end
	end
}

I also created this little script to set the dim level on the Red Green and Blue dimmers back to 1 and then switch them off every time the main LED switch is turned off.

Code: Select all

return {
	on = {
		devices = {
	        'Cabinet LED'
	    },
	},
	execute = function(domoticz, triggeredItem)
        local red = domoticz.devices('Cabinet LED - Red')
        local green = domoticz.devices('Cabinet LED - Green')
        local blue = domoticz.devices('Cabinet LED - Blue')
        local softwhite = domoticz.devices('Cabinet LED - Soft White')
        if (not triggeredItem.active) then
            red.dimTo(1)
            green.dimTo(1)
            blue.dimTo(1)
            softwhite.dimTo(1)
            red.switchOff()
            green.switchOff()
            blue.switchOff()
            softwhite.switchOff()
        end
	end
}
Last edited by sciroccojc on Wednesday 18 August 2021 19:22, edited 2 times in total.
Groentjuh
Posts: 5
Joined: Monday 19 April 2021 0:52
Target OS: Linux
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Groentjuh »

I had put together the following DzVents, which needs a virtual RGBWWZ device, which can be used to set color. It will however not set the color to that virtual device when the value of the dimmer changes. I didn't fully test it. It should be a good start to use either way.

Code: Select all

return {
  on = {
    devices = {
      144
    },
    httpResponses = { 'newColorRetrieved' }
  },
  data = {
    brightnessDeviceOn = { initial = nil },
    redDeviceOn = { initial = nil },
    greenDeviceOn = { initial = nil },
    blueDeviceOn = { initial = nil },
    whiteDeviceOn = { initial = nil }
  },
  execute = function(domoticz, device)
    brightnessDeviceId = 126
    redDeviceId = 127
    greenDeviceId = 128
    blueDeviceId = 129
    whiteDeviceId = 130
    rgbwDeviceId = 144

    -- Prepare needed devices
    if (device.idx == brightnessDeviceId) then
      brightnessDevice = device
    else
      brightnessDevice = domoticz.devices(brightnessDeviceId)
    end

    if (device.idx == redDeviceId) then
      redDevice = device
    else
      redDevice = domoticz.devices(redDeviceId)
    end

    if (device.idx == greenDeviceId) then
      greenDevice = device
    else
      greenDevice = domoticz.devices(greenDeviceId)
    end

    if (device.idx == blueDeviceId) then
      blueDevice = device
    else
      blueDevice = domoticz.devices(blueDeviceId)
    end

    if (device.idx == whiteDeviceId) then
      whiteDevice = device
    else
      whiteDevice = domoticz.devices(whiteDeviceId)
    end

    if (device.idx == rgbwDeviceId) then
      rgbwDevice = domoticz.devices(rgbwDeviceId)
    else
      rgbwDevice = domoticz.devices(rgbwDeviceId)
    end
    
    -- First run saving dimmer states for on-off commands
    if (domoticz.data.brightnessDeviceOn == nil) then
        domoticz.data.brightnessDeviceOn = brightnessDevice.active
    end
    if (domoticz.data.redDeviceOn == nil) then
        domoticz.data.redDeviceOn = redDevice.active
    end
    if (domoticz.data.greenDeviceOn == nil) then
        domoticz.data.greenDeviceOn = greenDevice.active
    end
    if (domoticz.data.blueDeviceOn == nil) then
        domoticz.data.blueDeviceOn = blueDevice.active
    end
    if (domoticz.data.whiteDeviceOn == nil) then
        domoticz.data.whiteDeviceOn = whiteDevice.active
    end
    
    if (device.isDevice == true and device.idx == rgbwDeviceId) then
      -- This is a massive hack, but rgbwDevice.Color is not updated at this point. It still holds the previous value, so reload!
      domoticz.openURL({
        url = domoticz.settings['Domoticz url'] .. '/json.htm?type=devices&rid=' .. rgbwDevice.idx,
        method = 'GET',
        callback = 'newColorRetrieved'
      })
    elseif (device.isHTTPResponse == true and device.trigger == 'newColorRetrieved') then
      domoticz.log('dzVent: Sync to Dimmer + RGBW-devices', domoticz.LOG_INFO)
      rgbwDeviceState = device.json['result'][1]['Data'];
      rgbwDeviceLevel = device.json['result'][1]['Level'];
      rgbwDeviceColor = domoticz.utils.fromJSON(device.json['result'][1]['Color']);

      -- Set wanted values for all dimmer devices
      wantedBrightness = nil
      wantedRed = nil
      wantedGreen = nil
      wantedBlue = nil
      wantedWhite = nil

      -- Handle off and on states in a manner that will not remove previous brightness/color information
      if (rgbwDeviceState == "Off") then
        wantedBrightness = 100
        wantedRed = nil
        wantedGreen = nil
        wantedBlue = nil
        wantedWhite = nil
      elseif (rgbwDeviceState == "On") then
        wantedBrightness = 100

        if (domoticz.data.redDeviceOn == true) then
          wantedRed = redDevice.lastLevel
        else
          wantedRed = 0
        end

        if (domoticz.data.greenDeviceOn == true) then
          wantedGreen = greenDevice.lastLevel
        else
          wantedGreen = 0
        end

        if (domoticz.data.blueDeviceOn == true) then
          wantedBlue = blueDevice.lastLevel
        else
          wantedBlue = 0
        end

        if (domoticz.data.whiteDeviceOn == true) then
          wantedWhite = whiteDevice.lastLevel
        else
          wantedWhite = 0
        end
      elseif (rgbwDeviceState == "Set Color" or string.gmatch(rgbwDeviceState, '^Set Level: %d+ \\%$')) then
        if (rgbwDeviceColor.m == 1) then
          -- domoticz.log('dzVent: Mode 1', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = 0
          wantedGreen = 0
          wantedBlue = 0
          wantedWhite = rgbwDeviceLevel
        elseif (rgbwDeviceColor.m == 3) then
          -- domoticz.log('dzVent: Mode 3', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = domoticz.utils.round(rgbwDeviceColor.r * rgbwDeviceLevel / 255)
          wantedGreen = domoticz.utils.round(rgbwDeviceColor.g * rgbwDeviceLevel / 255)
          wantedBlue = domoticz.utils.round(rgbwDeviceColor.b * rgbwDeviceLevel / 255)
          wantedWhite = 0
        elseif (rgbwDeviceColor.m == 4) then
          -- domoticz.log('dzVent: Mode 4', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = domoticz.utils.round(rgbwDeviceColor.r * rgbwDeviceLevel / 255)
          wantedGreen = domoticz.utils.round(rgbwDeviceColor.g * rgbwDeviceLevel / 255)
          wantedBlue = domoticz.utils.round(rgbwDeviceColor.b * rgbwDeviceLevel / 255)
          wantedWhite = domoticz.utils.round((rgbwDeviceColor.ww + rgbwDeviceColor.cw) * rgbwDeviceLevel / 2 / 255)
        end
      end

      if
        (wantedRed ~= nil and
          ((wantedRed == 0 and (redDevice.state ~= "Off" and redDevice.level ~= wantedRed)) or
            (wantedRed ~= 0 and (redDevice.state == "Off" or redDevice.level ~= wantedRed))))
       then
        -- domoticz.log('dzVent: set redDevice level to: ' .. wantedRed .. ' from ' .. redDevice.level, domoticz.LOG_INFO)

        domoticz.data.redDeviceOn = (wantedRed ~= 0)
        if (wantedRed == 0) then
          redDevice.setState("Off")
        else
          redDevice.setLevel(wantedRed)
        end
      elseif (wantedRed == nil) then
        redDevice.setState("Off")
      end

      if
        (wantedGreen ~= nil and
          ((wantedGreen == 0 and (greenDevice.state ~= "Off" and greenDevice.level ~= wantedGreen)) or
            (wantedGreen ~= 0 and (greenDevice.state == "Off" or greenDevice.level ~= wantedGreen))))
       then
        -- domoticz.log('dzVent: set greenDevice level to: ' .. wantedGreen .. ' from ' .. greenDevice.level, domoticz.LOG_INFO)

        domoticz.data.greenDeviceOn = (wantedGreen ~= 0)
        if (wantedGreen == 0) then
          greenDevice.setState("Off")
        else
          greenDevice.setLevel(wantedGreen)
        end
      elseif (wantedGreen == nil) then
        greenDevice.setState("Off")
      end

      if
        (wantedBlue ~= nil and
          ((wantedBlue == 0 and (blueDevice.state ~= "Off" and blueDevice.level ~= wantedBlue)) or
            (wantedBlue ~= 0 and (blueDevice.state == "Off" or blueDevice.level ~= wantedBlue))))
       then
        -- domoticz.log('dzVent: set blueDevice level to: ' .. wantedBlue .. ' from ' .. blueDevice.level, domoticz.LOG_INFO)

        domoticz.data.blueDeviceOn = (wantedBlue ~= 0)
        if (wantedBlue == 0) then
          blueDevice.setState("Off")
        else
          blueDevice.setLevel(wantedBlue)
        end
      elseif (wantedBlue == nil) then
        blueDevice.setState("Off")
      end

      if
        (wantedWhite ~= nil and
          ((wantedWhite == 0 and (whiteDevice.state ~= "Off" and whiteDevice.level ~= wantedWhite)) or
            (wantedWhite ~= 0 and (whiteDevice.state == "Off" or whiteDevice.level ~= wantedWhite))))
       then
        -- domoticz.log("dzVent: set whiteDevice level to: " .. wantedWhite .. " from " .. whiteDevice.level, domoticz.LOG_INFO)

        domoticz.data.whiteDeviceOn = (wantedWhite ~= 0)
        if (wantedWhite == 0) then
          whiteDevice.setState("Off")
        else
          whiteDevice.setLevel(wantedWhite)
        end
      elseif (wantedWhite == nil) then
        whiteDevice.setState("Off")
      end

      if
        (wantedBrightness ~= nil and
          ((wantedBrightness == 0 and (brightnessDevice.state ~= "Off" and brightnessDevice.level ~= wantedBrightness)) or
            (wantedBrightness ~= 0 and (brightnessDevice.state == "Off" or brightnessDevice.level ~= wantedBrightness))))
       then
        -- domoticz.log('dzVent: set brightnessDevice level to: ' .. wantedBrightness .. ' from ' .. brightnessDevice.level, domoticz.LOG_INFO)

        domoticz.data.brightnessDeviceOn = (wantedBrightness ~= 0)
        if (wantedBrightness == 0) then
          brightnessDevice.setState("Off")
        else
          brightnessDevice.setLevel(wantedBrightness)
        end
      elseif (wantedBrightness == nil) then
        brightnessDevice.setState("Off")
      end
    end
  end
}
sciroccojc
Posts: 11
Joined: Thursday 26 March 2020 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by sciroccojc »

WOW! This script works beautifully! Thank you!
sciroccojc
Posts: 11
Joined: Thursday 26 March 2020 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by sciroccojc »

I can't seem to get this script working when I add the Red Green Blue and SoftWhite dimmers as hidden devices. Any Ideas?
Groentjuh
Posts: 5
Joined: Monday 19 April 2021 0:52
Target OS: Linux
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Groentjuh »

sciroccojc wrote: Wednesday 18 August 2021 21:11 I can't seem to get this script working when I add the Red Green Blue and SoftWhite dimmers as hidden devices. Any Ideas?
I do not know why that would be the case. Did you use device id or names?
sciroccojc
Posts: 11
Joined: Thursday 26 March 2020 21:50
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by sciroccojc »

I kept the script how it was. I only removed the switches from active, changed the names to have a "$" at the beginning of each name and then set them back to active.
Groentjuh
Posts: 5
Joined: Monday 19 April 2021 0:52
Target OS: Linux
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by Groentjuh »

Technically I wrote this script for working with device IDs in mind. Did you try using those instead of device names? In my domoticz the script works fine when the Fibaro devices are hidden. Does the log contain any clues?
mcjackdus
Posts: 15
Joined: Monday 22 October 2018 10:34
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Fibaro RGBW Controller 2: Missing devices

Post by mcjackdus »

Groentjuh wrote: Wednesday 18 August 2021 18:33 I had put together the following DzVents, which needs a virtual RGBWWZ device, which can be used to set color. It will however not set the color to that virtual device when the value of the dimmer changes. I didn't fully test it. It should be a good start to use either way.

Code: Select all

return {
  on = {
    devices = {
      144
    },
    httpResponses = { 'newColorRetrieved' }
  },
  data = {
    brightnessDeviceOn = { initial = nil },
    redDeviceOn = { initial = nil },
    greenDeviceOn = { initial = nil },
    blueDeviceOn = { initial = nil },
    whiteDeviceOn = { initial = nil }
  },
  execute = function(domoticz, device)
    brightnessDeviceId = 126
    redDeviceId = 127
    greenDeviceId = 128
    blueDeviceId = 129
    whiteDeviceId = 130
    rgbwDeviceId = 144

    -- Prepare needed devices
    if (device.idx == brightnessDeviceId) then
      brightnessDevice = device
    else
      brightnessDevice = domoticz.devices(brightnessDeviceId)
    end

    if (device.idx == redDeviceId) then
      redDevice = device
    else
      redDevice = domoticz.devices(redDeviceId)
    end

    if (device.idx == greenDeviceId) then
      greenDevice = device
    else
      greenDevice = domoticz.devices(greenDeviceId)
    end

    if (device.idx == blueDeviceId) then
      blueDevice = device
    else
      blueDevice = domoticz.devices(blueDeviceId)
    end

    if (device.idx == whiteDeviceId) then
      whiteDevice = device
    else
      whiteDevice = domoticz.devices(whiteDeviceId)
    end

    if (device.idx == rgbwDeviceId) then
      rgbwDevice = domoticz.devices(rgbwDeviceId)
    else
      rgbwDevice = domoticz.devices(rgbwDeviceId)
    end
    
    -- First run saving dimmer states for on-off commands
    if (domoticz.data.brightnessDeviceOn == nil) then
        domoticz.data.brightnessDeviceOn = brightnessDevice.active
    end
    if (domoticz.data.redDeviceOn == nil) then
        domoticz.data.redDeviceOn = redDevice.active
    end
    if (domoticz.data.greenDeviceOn == nil) then
        domoticz.data.greenDeviceOn = greenDevice.active
    end
    if (domoticz.data.blueDeviceOn == nil) then
        domoticz.data.blueDeviceOn = blueDevice.active
    end
    if (domoticz.data.whiteDeviceOn == nil) then
        domoticz.data.whiteDeviceOn = whiteDevice.active
    end
    
    if (device.isDevice == true and device.idx == rgbwDeviceId) then
      -- This is a massive hack, but rgbwDevice.Color is not updated at this point. It still holds the previous value, so reload!
      domoticz.openURL({
        url = domoticz.settings['Domoticz url'] .. '/json.htm?type=devices&rid=' .. rgbwDevice.idx,
        method = 'GET',
        callback = 'newColorRetrieved'
      })
    elseif (device.isHTTPResponse == true and device.trigger == 'newColorRetrieved') then
      domoticz.log('dzVent: Sync to Dimmer + RGBW-devices', domoticz.LOG_INFO)
      rgbwDeviceState = device.json['result'][1]['Data'];
      rgbwDeviceLevel = device.json['result'][1]['Level'];
      rgbwDeviceColor = domoticz.utils.fromJSON(device.json['result'][1]['Color']);

      -- Set wanted values for all dimmer devices
      wantedBrightness = nil
      wantedRed = nil
      wantedGreen = nil
      wantedBlue = nil
      wantedWhite = nil

      -- Handle off and on states in a manner that will not remove previous brightness/color information
      if (rgbwDeviceState == "Off") then
        wantedBrightness = 100
        wantedRed = nil
        wantedGreen = nil
        wantedBlue = nil
        wantedWhite = nil
      elseif (rgbwDeviceState == "On") then
        wantedBrightness = 100

        if (domoticz.data.redDeviceOn == true) then
          wantedRed = redDevice.lastLevel
        else
          wantedRed = 0
        end

        if (domoticz.data.greenDeviceOn == true) then
          wantedGreen = greenDevice.lastLevel
        else
          wantedGreen = 0
        end

        if (domoticz.data.blueDeviceOn == true) then
          wantedBlue = blueDevice.lastLevel
        else
          wantedBlue = 0
        end

        if (domoticz.data.whiteDeviceOn == true) then
          wantedWhite = whiteDevice.lastLevel
        else
          wantedWhite = 0
        end
      elseif (rgbwDeviceState == "Set Color" or string.gmatch(rgbwDeviceState, '^Set Level: %d+ \\%$')) then
        if (rgbwDeviceColor.m == 1) then
          -- domoticz.log('dzVent: Mode 1', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = 0
          wantedGreen = 0
          wantedBlue = 0
          wantedWhite = rgbwDeviceLevel
        elseif (rgbwDeviceColor.m == 3) then
          -- domoticz.log('dzVent: Mode 3', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = domoticz.utils.round(rgbwDeviceColor.r * rgbwDeviceLevel / 255)
          wantedGreen = domoticz.utils.round(rgbwDeviceColor.g * rgbwDeviceLevel / 255)
          wantedBlue = domoticz.utils.round(rgbwDeviceColor.b * rgbwDeviceLevel / 255)
          wantedWhite = 0
        elseif (rgbwDeviceColor.m == 4) then
          -- domoticz.log('dzVent: Mode 4', domoticz.LOG_INFO)
          wantedBrightness = 100
          wantedRed = domoticz.utils.round(rgbwDeviceColor.r * rgbwDeviceLevel / 255)
          wantedGreen = domoticz.utils.round(rgbwDeviceColor.g * rgbwDeviceLevel / 255)
          wantedBlue = domoticz.utils.round(rgbwDeviceColor.b * rgbwDeviceLevel / 255)
          wantedWhite = domoticz.utils.round((rgbwDeviceColor.ww + rgbwDeviceColor.cw) * rgbwDeviceLevel / 2 / 255)
        end
      end

      if
        (wantedRed ~= nil and
          ((wantedRed == 0 and (redDevice.state ~= "Off" and redDevice.level ~= wantedRed)) or
            (wantedRed ~= 0 and (redDevice.state == "Off" or redDevice.level ~= wantedRed))))
       then
        -- domoticz.log('dzVent: set redDevice level to: ' .. wantedRed .. ' from ' .. redDevice.level, domoticz.LOG_INFO)

        domoticz.data.redDeviceOn = (wantedRed ~= 0)
        if (wantedRed == 0) then
          redDevice.setState("Off")
        else
          redDevice.setLevel(wantedRed)
        end
      elseif (wantedRed == nil) then
        redDevice.setState("Off")
      end

      if
        (wantedGreen ~= nil and
          ((wantedGreen == 0 and (greenDevice.state ~= "Off" and greenDevice.level ~= wantedGreen)) or
            (wantedGreen ~= 0 and (greenDevice.state == "Off" or greenDevice.level ~= wantedGreen))))
       then
        -- domoticz.log('dzVent: set greenDevice level to: ' .. wantedGreen .. ' from ' .. greenDevice.level, domoticz.LOG_INFO)

        domoticz.data.greenDeviceOn = (wantedGreen ~= 0)
        if (wantedGreen == 0) then
          greenDevice.setState("Off")
        else
          greenDevice.setLevel(wantedGreen)
        end
      elseif (wantedGreen == nil) then
        greenDevice.setState("Off")
      end

      if
        (wantedBlue ~= nil and
          ((wantedBlue == 0 and (blueDevice.state ~= "Off" and blueDevice.level ~= wantedBlue)) or
            (wantedBlue ~= 0 and (blueDevice.state == "Off" or blueDevice.level ~= wantedBlue))))
       then
        -- domoticz.log('dzVent: set blueDevice level to: ' .. wantedBlue .. ' from ' .. blueDevice.level, domoticz.LOG_INFO)

        domoticz.data.blueDeviceOn = (wantedBlue ~= 0)
        if (wantedBlue == 0) then
          blueDevice.setState("Off")
        else
          blueDevice.setLevel(wantedBlue)
        end
      elseif (wantedBlue == nil) then
        blueDevice.setState("Off")
      end

      if
        (wantedWhite ~= nil and
          ((wantedWhite == 0 and (whiteDevice.state ~= "Off" and whiteDevice.level ~= wantedWhite)) or
            (wantedWhite ~= 0 and (whiteDevice.state == "Off" or whiteDevice.level ~= wantedWhite))))
       then
        -- domoticz.log("dzVent: set whiteDevice level to: " .. wantedWhite .. " from " .. whiteDevice.level, domoticz.LOG_INFO)

        domoticz.data.whiteDeviceOn = (wantedWhite ~= 0)
        if (wantedWhite == 0) then
          whiteDevice.setState("Off")
        else
          whiteDevice.setLevel(wantedWhite)
        end
      elseif (wantedWhite == nil) then
        whiteDevice.setState("Off")
      end

      if
        (wantedBrightness ~= nil and
          ((wantedBrightness == 0 and (brightnessDevice.state ~= "Off" and brightnessDevice.level ~= wantedBrightness)) or
            (wantedBrightness ~= 0 and (brightnessDevice.state == "Off" or brightnessDevice.level ~= wantedBrightness))))
       then
        -- domoticz.log('dzVent: set brightnessDevice level to: ' .. wantedBrightness .. ' from ' .. brightnessDevice.level, domoticz.LOG_INFO)

        domoticz.data.brightnessDeviceOn = (wantedBrightness ~= 0)
        if (wantedBrightness == 0) then
          brightnessDevice.setState("Off")
        else
          brightnessDevice.setLevel(wantedBrightness)
        end
      elseif (wantedBrightness == nil) then
        brightnessDevice.setState("Off")
      end
    end
  end
}
Can you please explain how i need to setup this script
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest