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. OpenHAB
  4. Is V_RGB Supported in OpenHAB?

Is V_RGB Supported in OpenHAB?

Scheduled Pinned Locked Moved OpenHAB
3 Posts 2 Posters 34 Views 2 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.
  • A Offline
    A Offline
    Aloha
    wrote on last edited by
    #1

    Hi,

    Is it possible to send a hex value (ff0000) with type 40 (V_RGB) from OpenHAB? Or is it possible to create a custom item with type 40?

    I want the message sent to look like this: 8;1;1;0;40;ffc550

    Cheers

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hard-shovel
      wrote on last edited by
      #2

      Hi

      Openhab and the MySensors binding use the HSTtype format (hue, saturation, brightness) for color information.
      The binding automatically converts the HSBtype to the MySensors format of RRGGBB.
      So you need to use the HSBType fromRGB(int R, int G, int B) function

      items

      Color   Mock_RGB_LED     "Mock RGB LED (HSB)     "  (test254) { channel = "mysensors:rgbLight:gatewayWIFI3:Mock_RGB_LED:rgb" } 
      String  test_RGB_HexString "Test Color RGB hexS [0x%s]" (test254) 
      Number  test_RGB_Red	" Test Colour Red    [%s]"  (test254)
      Number  test_RGB_Green  " Test Colour Green  [%s]"  (test254)
      Number  test_RGB_Blue   " Test Colour Blue   [%s]"  (test254)
      

      Rules

      val String filename = "rgb-light.rules"
      
      rule "System startup"
              when
                      System started
              then
      /*Initial value of colors*/
          if (test_RGB_Red.state == NULL) test_RGB_Red.postUpdate(0)
      	if (test_RGB_Green.state == NULL) test_RGB_Green.postUpdate(0)
          if (test_RGB_Blue.state == NULL) test_RGB_Blue.postUpdate(0)
      end
      rule "Test Colour Channels RGB to Mysensors"
      when
      	Item test_RGB_Red   changed or
      	Item test_RGB_Green changed or
      	Item test_RGB_Blue  changed
      then
          val int r = (test_RGB_Red.state as Number).intValue
          val int g = (test_RGB_Green.state as Number).intValue
          val int b = (test_RGB_Blue.state as Number).intValue
          logInfo(filename, "Input Conversion: r:" + r + " g:" + g + " b:" + b)
         var HSBType hsb = HSBType.fromRGB(r, g, b)
          logInfo(filename, "Input Conversion: hsb" + hsb)	
          Mock_RGB_LED.sendCommand(hsb)
      end
      
      
      rule "RGB Hex -> HSB"
      when
          Item test_RGB_HexString received update
      then
          var rgb = test_RGB_HexString.state.toString
      
          var r = Integer::parseInt(rgb.substring(0, 2), 16)
          var g = Integer::parseInt(rgb.substring(2, 4), 16)
          var b = Integer::parseInt(rgb.substring(4, 6), 16)
      
          logInfo(filename, "Input Conversion: r" + r + " g" + g + " b" + b)
          var HSBType hsb = HSBType.fromRGB(r, g, b)
          logInfo(filename, "Input Conversion: hsb" + hsb)
          
          Mock_RGB_LED.sendCommand(hsb)	
      end
      
      /* I find this most useful for testing the node the Node */
      rule "Test Colour Channels RGB to Mysensors"
      when
          Item test_RGB_Red   changed or
          Item test_RGB_Green changed or
          Item test_RGB_Blue  changed
      then
          var int r = (test_RGB_Red.state as Number).intValue
          var int g = (test_RGB_Green.state as Number).intValue
          var int b = (test_RGB_Blue.state as Number).intValue
          logInfo(filename, "Input Conversion: r:" + r + " g:" + g + " b:" + b)
          var HSBType hsb = HSBType.fromRGB(r, g, b)
          logInfo(filename, "Input Conversion: hsb" + hsb)	
          Mock_RGB_LED.sendCommand(hsb)
      end	
      
      
      
      1 Reply Last reply
      0
      • A Offline
        A Offline
        Aloha
        wrote on last edited by
        #3

        Thank you @hard-shovel! It works. It doesn't store the value between reboots but I guess that's a different topic which I will look into.

        Cheers

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


        17

        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