Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Piplodocus

macrumors 6502a
Original poster
Apr 2, 2008
553
568
I have a load of Thread switches around my house to control the lights. They mostly use shortcuts, because I want on/off toggle. So the most simple of these is usually:

If {lightX} is On
Turn {lightX} Off
Else
Turn {lightX} On
End If

Many of these are colour bulbs though. So I'd like to do a very similar thing on some buttons of "if it's white, go blue, else go white" or similar. So I can get the current "hue" of the bulb in the shortcut (which I presume is basically the colour) and use it as a variable. So if it's the colour it currently is is white, go blue, else go white. But I can only say if it's one hue, change the colour to an undefined colour hue I've chosen from a colour picker and have no idea what hue it is, else go to something hopefully near the original colour, but then won't be able to cycle it a second time if it's not exactly the same hue.

How on earth do I relate what the current colour is ("hue"), to anything on the numberless/hueless colour wheel or vice-versa!

Is there any chart, or way to get it to tell you?

I was wondering if I can set the shortcut to email me the current hue for now, work the numbers out, then remove that bit of the shortcut, but I can add an email address to the shortcut, but seemingly not send a message (I can do programming, but have little experience of Apple Shortcuts, and there seems little info on the more basic Home shortcuts, than the full range out there for say an iPhone). Could I make that work?

I have considered if I put a range in rather than a single value for the "if hue is" maybe I can get close enough to pull it off? But I haven't a clue if hues have some kinda universal colour numbering system, and if there is trying to google it didn't help.

Any ideas? (Other than re-program the switch so everytime I press a button it emails Apple telling Craig Federighi to put some bloody numbers in the colour picker! 😂)
 
Hue is just the color measurement in degrees. Hue alone will not tell you if it's white or not. You'd also need to take Saturation into account to see if it's white.

Play with the numbers on this site and you'll see how it works. Changing the hue will move the dot around the wheel in a circle; changing the saturation will move the dot from the edge to the center.

Your shortcut would have to look something like this:
If {Light} Saturation is less than 10 (this would be a white-ish color; don't care about hue)
{set light to blue}
Else
{set light to white}

If you want to check for certain colors, you'd have to do a range something like this:
If Saturation > 10 AND Hue > 180 AND Hue < 270 (this would be a blue-ish color)
I simplified it here, but this would be several nested If statements.

I was wondering if I can set the shortcut to email me the current hue for now, work the numbers out, then remove that bit of the shortcut, but I can add an email address to the shortcut, but seemingly not send a message (I can do programming, but have little experience of Apple Shortcuts, and there seems little info on the more basic Home shortcuts, than the full range out there for say an iPhone). Could I make that work?
You could just put the 'Show Result' or 'Quick Look' action into the shortcut to see the values as you're testing it out. If you play around with this some more, you'd probably figure out the exact hue and saturation of the colors to check for, instead of doing a range.
 
  • Like
Reactions: Piplodocus
I have a load of Thread switches around my house to control the lights. They mostly use shortcuts, because I want on/off toggle. So the most simple of these is usually:

If {lightX} is On
Turn {lightX} Off
Else
Turn {lightX} On
End If

Many of these are colour bulbs though. So I'd like to do a very similar thing on some buttons of "if it's white, go blue, else go white" or similar.

just curious what buttons/switches are these?
 
Hue is just the color measurement in degrees. Hue alone will not tell you if it's white or not. You'd also need to take Saturation into account to see if it's white.

Play with the numbers on this site and you'll see how it works. Changing the hue will move the dot around the wheel in a circle; changing the saturation will move the dot from the edge to the center.

Your shortcut would have to look something like this:
If {Light} Saturation is less than 10 (this would be a white-ish color; don't care about hue)
{set light to blue}
Else
{set light to white}

If you want to check for certain colors, you'd have to do a range something like this:
If Saturation > 10 AND Hue > 180 AND Hue < 270 (this would be a blue-ish color)
I simplified it here, but this would be several nested If statements.


You could just put the 'Show Result' or 'Quick Look' action into the shortcut to see the values as you're testing it out. If you play around with this some more, you'd probably figure out the exact hue and saturation of the colors to check for, instead of doing a range.
Cool. Great help. Just what I needed! And yeah, I guess using ranges is going to be the easy way, I'll just try get approx values off that site you gave. 👍

I guess I need to look into shortcuts further to find out what you mean by adding quick look or show result in a home automation shortcut.
 
Last edited:
just curious what buttons/switches are these?
They're the Onvis Thread/Matter 5-button ones https://www.amazon.co.uk/Onvis-Blue...-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

Mini review:
  • Yes, they do feel a little on the cheaper side compared to some.
  • But they seem quite cheap compared to others.
  • Seem pretty reliable - never had any issues
  • Are Thread & Matter compatible
  • Have 5 buttons, all with click + double click + long press functions (so often have 1 switch on the border between 2 or more rooms and have plenty of options for different scenes as well as just plain on/off)
  • Have had them a few months and the coin cell batteries still say 100%, so seem pretty good for battery life
The other thing I like is the switch magnetizes to the base. So I used a dremel to cut a square hole in the base that just fits over the levers of my regular light switches. I then use the double-sided tape to stick them over my normal wired light switches. That way the smart switch magnetizes over the top and I don't annoyingly turn the power off to the bulbs out of old habits and them lose the network. So they cover my existing switches, but if I do need to reset a bulb by toggling power to it or need to turn it off for any reason I just pull the smart switch away from the magnets and the real power switches are underneath.

Which begs the question, what does everyone else do with their existing switches? Have loads of redundant standard ones next to their smart ones? Cover them over, then not be able to actually cut power to the bulbs ever again without much ****wittery? It's always been a question I pondered as in most smart home photos the original switches seem to have ceased to exist in the idealised media representing a modern smart home.
 
As an Amazon Associate, MacRumors earns a commission from qualifying purchases made through links in this post.
Thinking about it, it was trying to have me say hue in degrees or radians or whatever, which I didn't get at all and seemed weird, but now makes perfect sense!

I'm guessing saturation is in % (so out of 100) like that linked site.

:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.