Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. Domoticz
  4. Creating a RGB selector and adding it to Domoticz

Creating a RGB selector and adding it to Domoticz

Scheduled Pinned Locked Moved Domoticz
5 Posts 3 Posters 5.7k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mfalkviddM Offline
    mfalkviddM Offline
    mfalkvidd
    Mod
    wrote on last edited by mfalkvidd
    #1

    I have created a node which has an RGB selector. I want to send the selected value to Domoticz whenever the selection is changed. The value should then be used to control one or more other nodes with RGB leds.

    I have setup the RGB selector with gw.present(0, S_RGB_LIGHT, "RGB"). When sending the first selected value, a new device was available in Domoticz. I added the Device in Domoticz and it shows as a Type=Lighting Limitless/Applamp and Subtype=RGB.

    When the messages are sent, the serial debug log on the selector looks like this:

    send: 6-6-0-0 s=0,c=1,t=40,pt=0,l=6,sg=0,st=ok:f8c0ff
    send: 6-6-0-0 s=0,c=1,t=40,pt=0,l=6,sg=0,st=ok:fafdff
    

    The Domoticz log looks like this:

    2016-01-29 22:37:40	On
    2016-01-29 22:37:23	Off
    2016-01-29 22:37:22	On
    2016-01-29 22:37:16	Off
    2016-01-29 22:37:16	Off
    2016-01-29 22:37:15	Off
    2016-01-29 22:37:06	On
    2016-01-29 22:37:05	On
    

    I don't want On/Off, I want the RGB hexstring that was sent. Does anyone know what I'm doing wrong?

    I'm not sure if the problem is with the MySensors code or the Domoticz configuration. I am using Domoticz 2.3530

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sundberg84
      Hardware Contributor
      wrote on last edited by sundberg84
      #2

      Said it before - coding isnt my strong side :) but looking at the code in parseline() it looks like it doesnt do anything in Domoticz...
      https://github.com/domoticz/domoticz/blob/master/hardware/MySensorsBase.cpp#L1844
      In the other hand the case S_RGBW_LIGHT: (a bit below) seem to be coded...

      What du you think?

      Edit: Nah, see now in the code below that V_RGB is used... and also V_RGBW as well.

      Controller: Proxmox VM - Home Assistant
      MySensors GW: Arduino Uno - W5100 Ethernet, Gw Shield Nrf24l01+ 2,4Ghz
      MySensors GW: Arduino Uno - Gw Shield RFM69, 433mhz
      RFLink GW - Arduino Mega + RFLink Shield, 433mhz

      1 Reply Last reply
      0
      • mfalkviddM Offline
        mfalkviddM Offline
        mfalkvidd
        Mod
        wrote on last edited by
        #3

        Thanks! Great idea to look at the Domoticz source.
        There is no break; after S_RGB_LIGHT, so the execution will continue with S_COLOR_SENSOR so Domoticz seems to handle RGB_LIGHT and COLOR_SENSOR exactly the same. That should be fine I think. I'll continue digging through the code.

        1 Reply Last reply
        0
        • mfalkviddM Offline
          mfalkviddM Offline
          mfalkvidd
          Mod
          wrote on last edited by
          #4

          Looks like I need to upgrade to the Domoticz beta https://www.domoticz.com/forum/viewtopic.php?f=42&t=8039

          1 Reply Last reply
          1
          • F Offline
            F Offline
            flopp
            wrote on last edited by
            #5

            This is the code i am using and it is working fine with MyS 1.5.1 and Domoticz 3.5877.

            /*PROJECT: MySensors / RGB test for Light & Sensor
             PROGRAMMER: AWI/GizMoCuz
             DATE: september 27, 2015/ last update: October 10, 2015
             FILE: AWI_RGB.ino
             LICENSE: Public domain
            
             Hardware: Nano and MySensors 1.5
                
             Special:
              uses Fastled library with NeoPixel (great & fast RBG/HSV universal library)       https://github.com/FastLED/FastLED
             
             Remarks:
              Fixed node-id
              Added option to request/apply last light state from gateway
              
             Domoticz typicals - 2015 10 10:
              - Domoticz is using HUE values internally, there might be a slight difference then using direct RGB colors.
            */
            
            #include <MySensor.h>
            #include <SPI.h>
            #include <FastLED.h>
            
            
            const int stripPin = 4 ;                  // pin where 2812 LED strip is connected
            
            const int numPixel = 3 ;                  // set to number of pixels
            
            #define NODE_ID 254                       // fixed MySensors node id
            
            #define CHILD_ID 0                  // Child Id's
            
            CRGB leds[numPixel];
            
            char actRGBvalue[] = "000000";               // Current RGB value
            uint16_t actRGBbrightness = 0xFF ;         // Controller Brightness 
            int actRGBonoff=0;                        // OnOff flag
            
            MySensor gw;
            
            MyMessage lastColorStatusMsg(CHILD_ID,V_VAR1);
            
            void setup() {
              FastLED.addLeds<NEOPIXEL, stripPin >(leds, numPixel); // initialize led strip
            
              gw.begin(incomingMessage, NODE_ID, false);      // initialize MySensors
              gw.sendSketchInfo("AWI RGB Light", "1.1");
              gw.present(CHILD_ID, S_RGB_LIGHT);        // present to controller
            
              // Flash the "hello" color sequence: R, G, B, black. 
              colorBars();
            
              //Request the last stored colors settings
              gw.request(CHILD_ID, V_VAR1);
            }
            
            void loop() {
              gw.process();                       // wait for incoming messages
            }
            
            void colorBars()
            {
              SendColor2AllLEDs( CRGB::Red );   FastLED.show(); delay(500);
              SendColor2AllLEDs( CRGB::Green ); FastLED.show(); delay(500);
              SendColor2AllLEDs( CRGB::Blue );  FastLED.show(); delay(500);
              SendColor2AllLEDs( CRGB::Black ); FastLED.show(); delay(500);
            } 
            
            void SendColor2AllLEDs(const CRGB lcolor)
            {
              for(int i = 0 ; i < numPixel ; i++) {
                leds[i] = lcolor;
              }
            }
            
            void SendLastColorStatus()
            {
              String cStatus=actRGBvalue+String("&")+String(actRGBbrightness)+String("&")+String(actRGBonoff);
              gw.send(lastColorStatusMsg.set(cStatus.c_str()));
            }
            
            String getValue(String data, char separator, int index)
            {
             int found = 0;
              int strIndex[] = {0, -1};
              int maxIndex = data.length()-1;
              for(int i=0; i<=maxIndex && found<=index; i++){
              if(data.charAt(i)==separator || i==maxIndex){
              found++;
              strIndex[0] = strIndex[1]+1;
              strIndex[1] = (i == maxIndex) ? i+1 : i;
              }
             }
              return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
            }
            
            void incomingMessage(const MyMessage &message) {
              if (message.type == V_RGB) {            // check for RGB type
                actRGBonoff=1;
                strcpy(actRGBvalue, message.getString());    // get the payload
                SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
                SendLastColorStatus();
              }
              else if (message.type == V_DIMMER) {           // if DIMMER type, adjust brightness
                actRGBonoff=1;
                actRGBbrightness = map(message.getLong(), 0, 100, 0, 255);
                FastLED.setBrightness( actRGBbrightness );
                SendLastColorStatus();
              }
              else if (message.type == V_STATUS) {           // if on/off type, toggle brightness
                actRGBonoff = message.getInt();
                FastLED.setBrightness((actRGBonoff == 1)?actRGBbrightness:0);
                SendLastColorStatus();
              }
              else if (message.type==V_VAR1) {            // color status
                String szMessage=message.getString();
                strcpy(actRGBvalue, getValue(szMessage,'&',0).c_str());
                actRGBbrightness=atoi(getValue(szMessage,'&',1).c_str());
                actRGBonoff=atoi(getValue(szMessage,'&',2).c_str());
                SendColor2AllLEDs(strtol(actRGBvalue, NULL, 16));
                FastLED.setBrightness((actRGBonoff == 1)?actRGBbrightness:0);
              }
              FastLED.show();
            }
            
            

            When you get the RGB Light in Device, add it and edit the Device to be a Dimmer instead then click on the three cubes and start to select the color you like

            1 Reply Last reply
            1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            2

            Online

            12.0k

            Users

            11.2k

            Topics

            113.4k

            Posts


            Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • MySensors
            • OpenHardware.io
            • Categories
            • Recent
            • Tags
            • Popular