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. General Discussion
  3. Possible to change LED effects from controller/domoticz?

Possible to change LED effects from controller/domoticz?

Scheduled Pinned Locked Moved General Discussion
5 Posts 4 Posters 3.1k Views 5 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.
  • Cliff KarlssonC Offline
    Cliff KarlssonC Offline
    Cliff Karlsson
    wrote on last edited by
    #1

    I found a site with several led-effects for ws2812b strips. Is it possible somehow to "store" multiple effects in an arduino sketch and then somehow decide witch effect to run from the controller/domoticz?

    one effect looked like this:

    void loop() {
      SnowSparkle(0x10, 0x10, 0x10, 20, random(100,1000));
    }
    
    void SnowSparkle(byte red, byte green, byte blue, int SparkleDelay, int SpeedDelay) {
      setAll(red,green,blue);
      
      int Pixel = random(NUM_LEDS);
      setPixel(Pixel,0xff,0xff,0xff);
      showStrip();
      delay(SparkleDelay);
      setPixel(Pixel,red,green,blue);
      showStrip();
      delay(SpeedDelay);
    }
    

    Another like this:

    void loop() {
      RunningLights(0xff,0xff,0x00, 50);
    }
    
    void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
      int Position=0;
      
      for(int i=0; i<NUM_LEDS*2; i++)
      {
          Position++; // = 0; //Position + Rate;
          for(int i=0; i<NUM_LEDS; i++) {
            // sine wave, 3 offset waves make a rainbow!
            //float level = sin(i+Position) * 127 + 128;
            //setPixel(i,level,0,0);
            //float level = sin(i+Position) * 127 + 128;
            setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
                       ((sin(i+Position) * 127 + 128)/255)*green,
                       ((sin(i+Position) * 127 + 128)/255)*blue);
          }
          
          showStrip();
          delay(WaveDelay);
      }
    }
    
    1 Reply Last reply
    0
    • dbemowskD Offline
      dbemowskD Offline
      dbemowsk
      wrote on last edited by dbemowsk
      #2

      What I did for my thermostat controller to set the thermostat mode (Off, Heat, Cool, Auto) was to create a dummy switch as a selector.
      alt text
      When creating a selector switch, you can create custom selector levels. This is where I would put your different pattern selections.
      selector switch
      On the MySensors side, create a child node using S_INFO and V_TEXT. In my case, I named that "Furnace Mode" on the domoticz side. This is just the device that will pass the information to your MySensors device to do the switching. I then use a lua script in Domoticz that looks like this:

      --
      -- Thermostat mode switch to MySensors
      --
      commandArray = {}
      
      --if (devicechanged['Thermostat Mode'] ~= nil and (devicechanged['Thermostat Mode'] ~= otherdevices['Furnace Mode'])) then
      --   commandArray['Furnace Mode'] = devicechanged['Thermostat Mode']
      --   print('Setting thermostat mode to ' .. devicechanged['Thermostat Mode'])
      --end
      
      --if (devicechanged['Furnace Mode'] ~= nil and (devicechanged['Furnace Mode'] ~= otherdevices['Thermostat Mode'])) then
      --   commandArray['Thermostat Mode'] = devicechanged['Furnace Mode']
      --   print('Setting furnace mode to ' .. devicechanged['Furnace Mode'])
      --end
      
      if (devicechanged['Thermostat Mode'] == 'Off') then
          ttidx = otherdevices_idx['Furnace Mode']
          -- print("Furnace Mode idx: " .. ttidx)
          commandArray['UpdateDevice'] = ttidx..'|0|O'
          print("Furnace Mode = O")
      elseif (devicechanged['Thermostat Mode'] == 'Heat') then
          ttidx = otherdevices_idx['Furnace Mode']
          -- print("Furnace Mode idx: " .. ttidx)
          commandArray['UpdateDevice'] = ttidx..'|0|H'
          print("Furnace Mode = H")
      elseif (devicechanged['Thermostat Mode'] == 'Cool') then
          ttidx = otherdevices_idx['Furnace Mode']
          -- print("Furnace Mode idx: " .. ttidx)
          commandArray['UpdateDevice'] = ttidx..'|0|C'
          print("Furnace Mode = C")
      elseif (devicechanged['Thermostat Mode'] == 'Auto') then
          ttidx = otherdevices_idx['Furnace Mode']
          -- print("Furnace Mode idx: " .. ttidx)
          commandArray['UpdateDevice'] = ttidx..'|0|A'
          print("Furnace Mode = A")
      end
      
      return commandArray
      

      This is what takes the information from the dummy switch and converts it to the MySensors node. As you see the "|0|O", |0|H", "|0|C", "|0|A" , the O, H, C, and A are what you would test for in your MySensors node under your receive() function. The O, H, C and A can be anything you want, so you could name them "pattern1", "pattern2", etc... and in your lua script you would format like:

      commandArray['UpdateDevice'] = ttidx..'|0|pattern1'
      

      Hope that helps some.

      Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
      Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

      1 Reply Last reply
      2
      • nagelcN Offline
        nagelcN Offline
        nagelc
        wrote on last edited by
        #3

        Nice. I did not know about the selector switch in Domiticz. I will have to give it a try.

        I have an LED array that I keep by my bedside with 3 patterns. The primary is a sunrise alarm. Domoticz tells it when to turn on and then it gradually lightens in a sunrise like pattern. The next is a fake TV that I have Domoticz turn on randomly when away. The third is just a dimmable light -- It is supposed to respond to a button on the node itself, but I haven't made the hardware upgrade yet.

        I used a more brute force method. I present a different sensor ID for each pattern, then have three corresponding switches in Domoticz. To select a particular pattern, just turn that switch on in Domoticz. When the node receives a message, it checks which sensor ID the message is for and sets the corresponding pattern on or off as the message dictates.

        When your node switches patterns, have it send an Off message for the previously running pattern back to Domiticz, or the Domoticz switches will get out of sync.

        The selector switch seems more elegant, but having separate switches for each function is another approach.

        1 Reply Last reply
        0
        • dbemowskD Offline
          dbemowskD Offline
          dbemowsk
          wrote on last edited by
          #4

          The selector switch is a dummy switch device. Make sure you have "Dummy Devices" added under Setup > Devices. Under Type, select "Dummy (Does nothing, use for virtual switches only)". Then when you go to your "Switches" tab, click the "Manual Light/Switch" button at the top.

          Vera Plus running UI7 with MySensors, Sonoffs and 1-Wire devices
          Visit my website for more Bits, Bytes and Ramblings from me: http://dan.bemowski.info/

          1 Reply Last reply
          1
          • Tore André RosanderT Offline
            Tore André RosanderT Offline
            Tore André Rosander
            wrote on last edited by
            #5

            @AWI has a nice piece of code that is exactly what you are looking for, try searching for mood light here on the forum.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            11

            Online

            11.7k

            Users

            11.2k

            Topics

            113.0k

            Posts


            Copyright 2019 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