Announcement

Collapse
No announcement yet.

Color Control - Decimal to HEX?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Color Control - Decimal to HEX?

    I've noticed that HomeSeer creates color devices (ie. LED Strips) and stores the custom color values in decimal format. However, I have some third-party software that I'm using (thehomeremote.com) that is expecting HEX. Is there a simple way to convert the Color Control to store HEX values?

    Thanks in advance for the help.

    #2
    Originally posted by begunfx View Post
    I've noticed that HomeSeer creates color devices (ie. LED Strips) and stores the custom color values in decimal format. However, I have some third-party software that I'm using (thehomeremote.com) that is expecting HEX. Is there a simple way to convert the Color Control to store HEX values?

    Thanks in advance for the help.
    From a quick google search if you want to do it yourself.


    To get a hexadecimal color, follow these three steps: Multiply the first number by 16. Multiply the second number by 1. Add the two totals together.
    ...
    For example:
    • A=10.
    • B=11.
    • C=12.
    • D=13.
    • E=14.
    • F=15

    Comment


      #3
      Or there is a built in HEX conversion in VB.Net. So an untested snippet should be something like.

      Code:
      [COLOR=#800000][B]Dim[/B][/COLOR] decValue [COLOR=#800000][B]As[/B][/COLOR] [COLOR=#800000][B]Integer[/B][/COLOR] [COLOR=#808030]=[/COLOR] [B]245[/B]
      [COLOR=#800000][B]Dim[/B][/COLOR] hexString [COLOR=#800000][B]As[/B][/COLOR] [COLOR=#800000][B]String[/B][/COLOR] [COLOR=#808030]=[/COLOR] [COLOR=#800000][B]Nothing[/B][/COLOR]
      hexString [COLOR=#808030]=[/COLOR] [COLOR=#800000][B]Hex[/B][/COLOR][COLOR=#808030]([/COLOR]decValue[COLOR=#808030])[/COLOR]

      Comment


        #4
        I am not sure this is what the OP was asking for but if you need to convert numbers and you are on windows just use the calculator (or google).
        Attached Files

        Comment


          #5
          I thought he meant programmatically as his third party software is expecting hex and assuming he doesn't want to constantly use the calculator?

          Comment


            #6
            Thanks guys. I was wondering what you would recommend then to process the decimal to hex conversion? Should it be a script or expression/script command that outputs the hex to a new virtual device? If I set the control of the virtual device to a color control, could I still store Hex with it?

            Comment


              #7
              Originally posted by George View Post
              I thought he meant programmatically as his third party software is expecting hex and assuming he doesn't want to constantly use the calculator?
              Correct. I would like to have thehomeremote be able to control HomeSeer color control, but in order to do so, I need the value that is read in the color control in HomeSeer to be HEX, but then translate to decimal so HomeSeer can change the value (something like that)

              Comment


                #8
                Got it. So if you are creating an event you could use a script (which I don't like) and do something like what George suggested in post #3. Or you could use the EasyTrigger plugin and do some calculation like (v>>20)*256 + (v>>16)&0xFF + ((v>>12)&0xFF)*256 + (v>>8)&0xFF + ((v>>4)&0xFF)*256) + v&0xFF or something like that. This will result in a decimal VALUE (not string). I am not sure what the device expects. Maybe a string. It's kind of strange that anyone would expect decimal values for colors, though.

                Comment


                  #9
                  Originally posted by mulu View Post
                  Got it. So if you are creating an event you could use a script (which I don't like) and do something like what George suggested in post #3. Or you could use the EasyTrigger plugin and do some calculation like (v>>20)*256 + (v>>16)&0xFF + ((v>>12)&0xFF)*256 + (v>>8)&0xFF + ((v>>4)&0xFF)*256) + v&0xFF or something like that. This will result in a decimal VALUE (not string). I am not sure what the device expects. Maybe a string. It's kind of strange that anyone would expect decimal values for colors, though.
                  Thanks mulu . From what I can see in HomeSeer when trying to set a custom color value for a color control, the result is saved as a decimal. My guess is that since it is stored in the "value" field for the device it has to be a number of some sort, so that's why it is probably being stored as a decimal. The Home Remote on the other hand controls color devices by sending HEX values. Here lies the problem. I need to take the HEX value coming into HomeSeer from The Home Remote, translate it into decimal and send it to the custom color/color control LED light strip device. I have to see if I create a virtual device in HomeSeer that has a color control, if I connect it with Home Remote, will Home Remote understand it enough to send the HEX value and maybe store it in the status? If so, then I can probably take your expression and then write the result to the LED light strip device value field. Hope that makes sense.

                  Comment

                  Working...
                  X