NC_2024_08_18
This episode explores smart lighting with Philips Hue, covering automation, terminal commands, cable management tips, and a review of the Espanso text tool, along with advanced color manipulation techniques for enhanced setups.
Automatic Shownotes
Chapters
Long Summary
In this episode of NoCillaCast, I delve deep into my experiences with smart lighting and its impact on my home office setup. After several disappointing encounters with unreliable smart bulbs, I turned to Philips Hue based on community recommendations. The episode reflects on my journey transitioning from budget bulbs to the reliability and versatility of Hue lights, highlighting features like HomeKit compatibility and automation capabilities.
I share the rationale behind needing smart lighting, specifically to create the perfect dim ambiance when I’m on call for work. Once I installed Philips Hue bulbs, I was thrilled by the seamless integration with my existing systems and began experimenting with custom automations. The evolution of my setup included enhancing my lighting experience through various tools and methods, including using a terminal to communicate with the Hue bridge via the API.
The technical aspect of controlling these lights through terminal commands is explored in detail. I outline the prerequisites for initiating commands, identifying the bridge's IP address, and the necessary curl commands to manipulate the lights’ functions. I describe various commands in simple terms, ensuring clarity on what each step entails, whether it's adjusting brightness, color temperature, or generating specific color effects. I emphasize the importance of utilizing JSON data and delve into parsing this effectively to access light properties and manipulate them appropriately.
Beyond the commands, I share insights into setting up more complex automations and personalizing the lighting experience to suit various moods or activities. I experiment with crafting scripts that integrate the light control functionality into my daily routine more efficiently. This includes setting the stage for watching movies or creating a productivity-enhancing environment without manual intervention.
In addition, I shift focus to a handy organizational tip for my cable management woes. I share my process for utilizing reusable cable ties to neatly categorize and label the diverse array of cables in my collection. This efficient organization method makes identifying the correct cables easier and reduces the time spent sorting through a tangled mess.
The discussion transitions to a product review segment featuring a new text expansion tool called Espanso, presented by Ed Tobias. Espanso stands out as an effective open-source alternative to popular options, promoting ease of use while allowing for customization. Ed details the installation process and demonstrates how to harness the full potential of Espanso through YAML files, making it a fit for tech enthusiasts willing to dive deeper into its functionalities.
I conclude the episode by returning to further explorations with the Philips Hue lights. I unveil advanced techniques for color manipulation, which deepen my understanding of the color space used by Hue bulbs. Technical details on converting RGB values into a format compatible with the Hue API are shared, alongside a discussion on automating these settings through scripts. This segment inspires listeners to think creatively about how to leverage technology for personal enjoyment and improved quality of life.
This episode encapsulates a blend of personal experience, technical insight, and practical advice, catering to both casual listeners interested in smart home setups and die-hard tech enthusiasts looking for deeper understanding and engagement with their devices. By sharing my journey and discoveries, I hope to empower others to enhance their own smart living experiences.
I share the rationale behind needing smart lighting, specifically to create the perfect dim ambiance when I’m on call for work. Once I installed Philips Hue bulbs, I was thrilled by the seamless integration with my existing systems and began experimenting with custom automations. The evolution of my setup included enhancing my lighting experience through various tools and methods, including using a terminal to communicate with the Hue bridge via the API.
The technical aspect of controlling these lights through terminal commands is explored in detail. I outline the prerequisites for initiating commands, identifying the bridge's IP address, and the necessary curl commands to manipulate the lights’ functions. I describe various commands in simple terms, ensuring clarity on what each step entails, whether it's adjusting brightness, color temperature, or generating specific color effects. I emphasize the importance of utilizing JSON data and delve into parsing this effectively to access light properties and manipulate them appropriately.
Beyond the commands, I share insights into setting up more complex automations and personalizing the lighting experience to suit various moods or activities. I experiment with crafting scripts that integrate the light control functionality into my daily routine more efficiently. This includes setting the stage for watching movies or creating a productivity-enhancing environment without manual intervention.
In addition, I shift focus to a handy organizational tip for my cable management woes. I share my process for utilizing reusable cable ties to neatly categorize and label the diverse array of cables in my collection. This efficient organization method makes identifying the correct cables easier and reduces the time spent sorting through a tangled mess.
The discussion transitions to a product review segment featuring a new text expansion tool called Espanso, presented by Ed Tobias. Espanso stands out as an effective open-source alternative to popular options, promoting ease of use while allowing for customization. Ed details the installation process and demonstrates how to harness the full potential of Espanso through YAML files, making it a fit for tech enthusiasts willing to dive deeper into its functionalities.
I conclude the episode by returning to further explorations with the Philips Hue lights. I unveil advanced techniques for color manipulation, which deepen my understanding of the color space used by Hue bulbs. Technical details on converting RGB values into a format compatible with the Hue API are shared, alongside a discussion on automating these settings through scripts. This segment inspires listeners to think creatively about how to leverage technology for personal enjoyment and improved quality of life.
This episode encapsulates a blend of personal experience, technical insight, and practical advice, catering to both casual listeners interested in smart home setups and die-hard tech enthusiasts looking for deeper understanding and engagement with their devices. By sharing my journey and discoveries, I hope to empower others to enhance their own smart living experiences.
Brief Summary
In this episode of NoCillaCast, I explore my journey into smart lighting, detailing my switch to Philips Hue after struggles with unreliable bulbs. I discuss the necessity for adaptable lighting in my home office and highlight the integration and automation features that enhance my setup. Listeners will gain insights into using terminal commands to control Hue lights, including executing curl commands to adjust settings and parse JSON data for light manipulation. I also share tips on creating custom automations for different activities and offer an effective cable management solution using reusable ties. Additionally, I review the text expansion tool Espanso with Ed Tobias, showcasing its user-friendly customization capabilities. The episode wraps up with advanced color manipulation techniques for Hue lights, aimed at inspiring creative tech solutions for an improved quality of life.
Tags
NoCillaCast
smart lighting
Philips Hue
adaptable lighting
home office
automation features
terminal commands
JSON data
custom automations
cable management
text expansion tool
Espanso
color manipulation
creative tech solutions
quality of life
Transcript
[0:00]Hi, this is Alistair Jenks of the NoCillaCast Apple Podcast, hosted at podfeet.com, a technology geek podcast with an ever so slight Apple bias. Today is, arguably, Sunday, August 18th, 2024, and this is show number 1006. Still can't get over how big that number is now. Now, Alison is off on safari, but it will take more than rhinoceroses, elephants or lions to stop the nocillicast. I'm here to keep the lights on this week. And speaking of lights,
[0:37]
Philips Hue Programming (Part 1 of 3)
[0:36]a few years ago, I decided I needed to get some smart light bulbs. I need to be able to set very dim light in my study for the nights I am on call for my job. After trying some cheap no-name bulbs, I discovered the Nanoleaf Essentials range. These were affordable and also came with HomeKit compatibility.
[0:58]Recently, I had one fail, and it was the last straw, at least for use in my study. It was, if I recall correctly, the fourth such failure in a few years. I put out the call in the Podfeet Slack, and in a couple of other places, for a reliable brand of bulbs. There was an overwhelming majority in favour of the Philips Hue bulbs. I had originally complained these were expensive and I didn't like the idea of needing a hub, the NanoLeft bulbs do not need one. Alison explained the hub actually improved the reliability and speed of operation, so I tentatively moved that aspect into the plus column. But they are still expensive, especially given the inclusion of a hub. Events conspired to get me over that hurdle too, as I managed to score a starter kit at well less than half price. In my study I have four bulb sockets, three spotlights which got the starter pack bulbs, plus a dome light near the door. Because of the tiny dark room I had also had a couple of nanoleaf light strips, one along the back of my desk as a backlight and one at the top of the wall behind my chair as a fill light. As I got to know the features of the Hue app I began to crave that all of the lights in my room would be controllable by it. I've now bought an additional bulb for the doorway and have just replaced the backlight strip with a Hue white and color ambience light strip.
[2:27]While playing around with the very cool Music Sync feature, seriously, I have an Apple Music playlist called Lightshow now, I got to wondering what bespoke automations I might be able to create with Hue Lights. Back in January of 2023, I contributed a three-part series to the podcast called Stream Deck Down the Rabbit Hole. In that, I mentioned I had looked for ways to directly control my Nanoleaf lights for automations. I had settled on an app called Home Control, which provides an interface to HomeKit via a URL scheme. This had worked okay for me, but does seem to fall foul of HomeKit reliability problems. I wondered whether Philips Hue gave me any new opportunities. Oh boy howdy does it what.
[3:14]It took me a little digging around to find out what was needed to start controlling my Hue lights, but I'm happy to report anyone can do it without needing to sign up to anything. It does help to create a free developer account with Philips, but that is just about getting access to detailed information. With just what I will talk about, you can control your lights to suit most automation needs. Everything I cover will be done from a terminal. I've been using the standard macOS terminal with zsh, but anywhere you can access the kill command and be on the same network as your hue bridge, you should be okay. Before we move on that is one prerequisite. While Hue bulbs can work without a bridge, the Hue API is an API to the bridge. The first thing we need to do is to find out what IP address the bridge is on. One way to do this is from the Hue app for iPhone or Android. In the settings tap my Hue system, then the info button for the Hue bridge you wish to control. The IP IP address will be listed in the top section.
[4:17]Alternatively, you may be able to look up the address from your router's GUI. If you go this way, you might like to reserve an IP address for the bridge so you can always use the same address for your automations. Every action we do will be running a curl command to talk to the bridge. We will either ask for information or provide information or sometimes both. For listeners, I'm going to describe the important parts of the commands in somewhat plain English. If you want to follow along, you'll be best served by following the blog post at podfeet.com. There I will highlight every part of the command which you may need to change to suit your own setup.
[4:56]The first command will provide the user profile we can use going forward. Curl space dash dash request space post that's in capitals space dash dash data space single quote open curly bracket double quote device type you get the idea there's a long command which you will find in the blog post. The guts of it are we're doing a post request and the data is device type, app name, hash instance name, generate client key, true.
[5:30]At the end of the curl command is the address to which we are sending this information, and that is https colon double slash, and then the IP address that you found out earlier of your bridge slash API. But you'll get an error back, which tells you the extra step you missed. Link button not pressed. Press the button on your bridge, then run the command again, and you'll get a more useful response. Success, username and a big glop of letters, client key and a big glop of hexadecimal numbers. Record both the username and client key in your password manager. For what I cover, you will only use the username.
[6:14]Now let's list out all the devices your bridge knows about. Out so that's the curl command request get header hue application key and then we put that value that we got back for the username followed by the url and from here on in when i talk about the url i'm just going to describe what comes after the ip address the hue application key you put on this command is the username you got back from the previous one the url is the ip address of your bridge followed by slash clip slash v2 slash resource slash device but hang on the curl command returns an error ssl certificate problem unable to get local issuer certificate if we were writing an app that many people would use with their own bridges we'd need to deal with validating the certificate because we're just playing with our own bridge we need to tell curl not to worry about that by adding an extra flag to the command dash k. Running it again with this we get a huge glop of data back. It's JSON so if you have the jq utility installed you can format it. To learn about jq check out Programming by Stealth episode 155 onwards.
[7:29]The formatted JSON takes many more lines but you can probably make sense of it then. It contains an error array, hopefully empty, and a data array which contains lots of data about each of your devices. There are several interesting things to see in a device. I'll concentrate on one of my lights. The ID key specifies the overall ID of the device, though we can get more specific. The Product Data object is comprised of lots of information about what the device actually is, along with its software version. The Metadata object contains the name you have given the device in the Hue app, as well as the archetype. In this case, I have described my light as being a round ceiling light. Lastly, the Services object gives us information about each of the roles the device can play. It's one of the RID keys in here that we're interested in, the one that relates to an R type of light. We're going to use that to check on and control the light, so note it down.
[8:32]Next let's get some information about the light service for this device. Once again we will pass the output to JQ for formatting. The command is the same as the previous one except the URL we specify has more to it. Slash clip slash v2 slash resource slash light slash and then the ID that we got from the previous step. At the top of the output we get back some of the same information we already had but then it gets interesting. The on object details whether the bulb is currently on or not. The dimming object shows the current dimming level. The color temperature object shows the current white temperature, more on this in a bit. The color object seems to contain a lot of information to define a color, more on this later too.
[9:21]There is plenty more after this section which mostly relates to advanced functions but here we have the basics of this color capable bulb. Let's see how we can turn the light on or off. From here on in we'll use a fairly standard curl command with differences in just one of the values. This is very similar to the previous command we used but with two important differences. The request type is now put and we are supplying some data. Note that the data value is single quoted to allow for double quotes in the value. That value is a snippet of JSON which should be quite familiar. When we query the light's current state it returned its power state amongst other data as open squarely bracket quote on close quote colon open squarely bracket this is JSON folks it goes like this quote on quote again colon false and then close both the brackets. And that is exactly the form of value we supplied to change it. After running the command you will get a small snippet of JSON in response. It contains the ID of the service we targeted and, once again, an errors array which is hopefully empty. And, of course, the light should have acted on your instruction.
[10:39]You can probably imagine we can set some of the other values the same way, and you'd be right. Let's try color temperature. From here on I'm just going to describe the data values as the rest of the command is always the same, at least for this light.
[10:53]Data, color temperature, MIREC 500.
[10:59]What's a MIREC? More commonly called a MIRED, it's short for Reciprocal Mega Kelvin. The MIREC value is based on a colour temperature scale you're possibly more familiar with, degrees Kelvin. Let's say you want to set the colour temperature to 6500 degrees Kelvin. To calculate the equivalent MIREC value, you divide 1 million degrees Kelvin by the number of degrees kelvin you want. So 1 million divided by 6500 is about 153.85.
[11:32]If you were paying attention to the JSON we received earlier you may have seen the number 153. When we queried the light service as well as the current Marek value we were also given Marek minimum and Marek maximum values of 153 and 500 respectively. If we divide 1 million by 500 we of course get 2000 so the light has a temperature range of 2000 to 6500 degrees kelvin. With my previous command I set my bulb to a very warm color temperature basically orange. I can set it back to its Brightest white by changing the MIREC value to 153. The next thing we can try is setting multiple attributes at once. Let's set the color temperature and the brightness. So data, color temperature, MIREC 312, dimming, brightness 50.0. Brightness is an easy one. It's just a number from 0.1 to 100.0 from dimmest to brightest.
[12:37]Specifying multiple attributes is as simple as putting one after the other separated by a comma. What about setting a color for color capable bulbs? It's easily executed though figuring out what numbers you need for a specific color can be a challenge. You might be used to specifying color with three components red green and blue or RGB. It's not going to be that easy for your hue lights. lights, instead we supply only two numbers which are X and Y in a CIE colour space. Basically they are coordinates on a chromaticity diagram. If like me you can think in an RGB colour space, then there is a way to convert between that and the CIE colour space, but it's not straight forward at all. Instead I recommend a resource like this page from dumb switches, link in the show notes that I found, which gives you values for a whole bunch of colors. There is also a link to a Python library that can do the calculations if you are keen. Anyway, here are the data values to pass for each of red, green, and blue. So red is x 0.675, y 0.322. Green is x 0.4091, and y is 0.518. Eight you're getting the pattern here and finally blue x is 0.167 and y is 0.04 yeah.
[14:03]There are many many more things you can do using the hue api like grouping lights reading sensors streaming entertainment data to lights and more but i'll leave it here for now if you wish to To explore more, sign up for a free developer account at developers.meethue.com. In a future segment, I'll tell you how I worked around needing to look up those giant light IDs with a little bit of command line magic. But just before I go, here's a data value to try that's pretty nifty. Data, effects, effect, prism.
[14:39]
Tiny Tip – Re-usable Cable Ties
[14:40]Music.
[14:48]The problem to be solved was a bewildering array of cables in a very large box. Step one, separate boxes for each basic type, network cables, power cables, audio cables, and USB cables. The next problem to be solved was a bewildering array of USB cables in a large box. If we count USB-A, USB-A for USB 3, USB-B, USB-B for USB 3, USB Mini-B, USB Micro-B, the other microbee, USB-C and lightning, there are 50 or more possible cable types, and probably only one that will do the task you need it for right now. I would search through the box looking for one end of a cable of the correct type, then have to find the other end, only to realise it was not the cable I needed. If I could just see both ends of each cable at the same time, easily, the task would be simpler. I tried rubber bands, I tried putting each cable in a clear plastic bag, neither were great solutions. Then I hit upon the perfect solution, cable ties.
[15:54]Now it would be a pretty poor solution to use regular plastic cable ties as they'd have to be cut off and thrown out any time I wanted to use one of the cables, and a new one used when putting one back in the box, so I searched for reusable cable ties. The ones I originally chose were all black and I recently needed to get some more. This time I went for colours. I bought the Inval reusable fastening cable ties 60 pieces adjustable self-adhesive cord cable straps for headphones, phone, electronics, PC, wire, cable tidy, management cord organiser strap 6 colours from Amazon. It is essentially a velcro like strap, about 12mm wide and functionally 150mm long. It's not real velcro, there is a soft fuzzy side which grips onto the textured plastic side. They can comfortably wrap around a 50mm diameter. With most cables I wrap them into a flat loop and then cinch the middle with the cable tie so the cable becomes somewhat like a bow. For more delicate cables I do a circular loop and apply a cable tie near the plugs, and possibly one on the opposite side depending on how the cable behaves. By ensuring the two plugs are next to each other when tying, it makes finding the right cable a much easier task, or indeed, finding that despite having 30 cables, none of them is the right sort.
[17:19]Next we have a review of a very interesting sounding productivity tool from Ed Tobias, also known as Mr Ed.
[17:28]
Command Line Text Expansion with Espanso by Ed Tobias
[17:29]Hey folks, this is Ed Tobias, a.k.a. Mr. Ed. I'd like to tell you about an open-source text expansion app called Espanzo. Espanzo works a lot like TextExpander. You know, Allison's second favorite app after Excel. It was created by Federico Terzi, a talented software engineer from Bologna, Italy. The app is free, but I did toss a few bucks Federico's way for all of his hard work. The app has a lot of features that distinguish it from TextExpander, but you have to be willing to tap into your nerdy side to take advantage of them. Just like TextExpander, it replaces trigger text with snippets of text that you define. The difference is that Expanso does not use a GUI like TextExpander to define your snippets. Instead, it uses a separate text file written in YAML. I know most of you already are experts at writing in YAML since you follow Bart's PBS series, So I'm sure this chance to put it to practice is really making you giddy. Before you get started, we need to install it first. It runs on Mac OS, Windows and Linux. Unfortunately there is no current iOS version. If you are a homebrew user, it is simple to install. Just type brew install espanso into your terminal window. If you don't use brew, you can download the app bundle from espanso.org.
[18:55]Once installed, it will create an espanso folder in your documents directory. Inside the espanso folder are two other folders, config and match. Inside the match folder is a base.yml file where you store your snippets. You can edit that file with any app that works with plain text files. I use VS Code myself, but you can use BBEdit or simply TextEdit. You can add additional files to the match folder and Espanza will read them in automatically.
[19:27]This way, you can organize your snippets by putting email snippets in an email.yml file or coding snippets in a code.yml file. As long as they are all in the match folder, they will be loaded. To add additional functionality, you can proceed the file with an underscore. For example, underscore code.yml. This prevents the Sponzo from loading the snippets in that file automatically. Would you want to do that, you ask? That is where the config folder comes in. You can add a file in the config folder, say vs code.yml, and and place a specific config yaml in the file. For example, filter underscore exec colon visual studio code dot app, followed by extra underscore includes colon, and then the path to the underscore code dot yml file. What this does is load all the snippets from the code dot yml file, but only when using the VS Code app. This way you don't have to worry about typing away in an email and suddenly plopping down a glop of code in the middle of your message.
[20:40]You can also add a file in the config folder to disable a Sponzo completely from any app that you specify. For example, if you don't want a Sponzo to run while using the terminal app, you can place the file terminal.yml in the config folder and have it contain the yaml filter underscore exec colon terminal enable colon false. This makes sure that a Sponzo does not run while using the terminal app. By the way, the name of the file could be anything, like fred.yml, as long as it has the proper YAML inside.
[21:15]In addition to writing your own snippets, you can install packages contributed by other users of Esponso that have specific snippets inside. These packages can be found at the Esponso Hub at hub.esponso.org. Some of these packages take advantage of more advanced features of Esponso, like creating variables in the snippets, or using shell commands and getting the standard output as a snippet. You can write snippets that pull off or pull down menus to select your replacement text, or you can get the current date and time and embed that in the text. The depth of the tool is really amazing if you're not afraid to get a little nerdy. What are you waiting for? Reread Bart's tutorial on YAML and get Get started with Espanso.
[22:05]Thanks for that review, Ed. Espanso sounds very powerful. As a former minor user of TextExpander, I may have to check this out. I do get text expansion from the Alfred app, but this sounds both more powerful and more simple to manage. And now, back into the madness with the Philips Hue lights.
[22:26]
Philips Hue Programming, Evolved (Part 2 of 3)
[22:25]In my previous installment I explained how to use the curl command to control Philips Hue lights. Part of the exercise involved dumping out a huge glop of JSON data and finding a long gobbledygook of random alphanumeric characters that were the ID of a light we would control. I wanted to go a step further by actually parsing that JSON in a way that was more meaningful to me, the dumb human who likes pretty colors.
[22:55]If you're a fan of the Programming by Stealth podcast, then you'll know where I'm going with this. Yes, the wonderfully powerful JQ tool. If you'd like to learn about JQ in great detail, I will direct you to PBS episode 155 and onward. For this exercise, I will be putting just a little of what I learned from PBS to work. There's a little bit of learning from the Bash episodes too.
[23:20]My goal was to provide the name I set in the Hue app and get back the service ID for controlling the light. For this I wrote what turned out to be a fairly short script, which you can find in the show notes. The first line is the usual shebang line, I defined my script as zsh because that's my default shell in which I tested all of the pieces. The next line defines a variable which will hold a jq filter string. Filtering. It's a three part filter to get down to the value we need. The first part simply selects the data array at the top level. All of the light information is contained in this. The second part does the hard work of finding the light service we asked for. It selects the object whose metadata.name key matches the parameter we've passed in. The last part then returns what we're after, the ID of the selected object. If you are following along very closely, and you also studied the previous installment, you might be wondering how I got the ID of the light source, without having to dive into the surfaces object, I'll explain why in just a moment.
[24:32]With my filter string defined in the variable, I then use a special shell construct to get the result of a curl command into another variable. My command will return the ID value, so by wrapping it in the $ I can fetch it straight into my $dev underscore id variable. The command in question is very similar to the one I used in the previous installment to fetch all of the device details but with one important difference. I am still performing a GET request, still providing the application key and still addressing the bridge. However the later part of the URL is different. It's now slash clip slash v2 slash resource slash light. In using this I am asking only for information about light services from any devices on the network. This is why the top level ID is the one we want, it's the only one present. One other minor difference is, in addition to the "-k flag which ignores certificate errors, I also added the "-s flag to tell curl not to write out progress information, while fetching the contents of the URL.
[25:50]The results of the curl command are piped to jq to apply its filter, as previously defined. I specify the "-r flag here to get the raw output. I don't want a JSON representation of the ID, I just want the value as a string. "-r does this for me. The final line of my script simply echoes out the device ID so you can see it has worked. For real automation tasks, you'd use the ID to build URLs which you would then ask curl to action as in the previous installment. Next up is colour. I said in the first instalment that colour was difficult because Philips have chosen to represent colours in a CIE colour space which is not trivial to convert to and from. But I figured it out. First it should be said that colour science is a very broad and very complicated subject. As soon as I say convert RGB to CIE I have already grossly oversimplified things. What follows is a method for converting sRGB colors to a CIE color space that, to my eyes at least, gets us in the ballpark for hue bulbs.
[27:06]Maybe not everyone is geeky enough to think like I do in RGB colors. If you say yellow, I immediately know that's red plus green. This understanding came from my early life where computers could only usefully display primary and secondary colors, and they were represented in binary. Each of red, green and blue was either on or off. All off was black, all on was white, red and green was yellow etc. In later years more control was available and I learned that having red full-on and green half-on gives us orange. If you are like me what follows will make sense at least in terms of the inputs. If you're not then at least you'll be able to find RGB values for colors all over the internet and in many different bits of software. So how do we convert from RGB GB to CIE? It's complicated. First, it is complicated by the fact that CIE has three components, X, Y, and Z. But Philips only require X and Y to set a color. Hmm. As best I can understand things, X and Y define a color and Z defines a brightness. When I found the conversion version equations I thought I might simply be able to plug the Z value into the hue brightness setting but it doesn't seem to work like that.
[28:31]Suffice to say I don't understand what I'm missing here but it turns out if we just ignore Z, we get in the ballpark. I have included the full script in the show notes. It expects three values which are between 0 and 1 for each of red, green and blue. As before, the shebang line defines the script to be run in the ZSH shell. Next I created three variables to hold the past parameters with more meaningful names. These are called r underscore sRGB, g underscore sRGB, and b underscore sRGB. These values first need to be converted from sRGB to a form called linearRGB. Next, there are three identical blocks, one each for red, green, and blue. The if statement uses the bc command to perform a floating point compare. If the value supplied is less than 0.0405, then one calculation is used, else a different one. Bc is required because none of the shells can cope with floating point arithmetic in comparisons.
[29:39]The calculations performed use another tool, ORC. This can perform floating point arithmetic too. Why didn't I use BC for this? Well, because BC can't raise a number to a floating point exponent. And, I hear you ask, why didn't I use ORC for the comparison? Well, because it was more complicated in that context. Hey, I worked it out so you don't have to. In asking ORC to perform the calculations, we cannot directly use our shell variables. By echoing the variables we need first and then piping that to ORC, we can then use the values in the calculations. When I echo $R underscore S-R-G-B, the value of that becomes available to ORC as $1. Note this is not what the shell considers $1 to be. Once the calculations are performed, we now have a linear RGB triplet. We can convert these into the XYZ components of the CIE color space. The next section does this conversion. I've made the calculation for Z even though we won't use it. One day I might figure out how to. Each component is the result of a matrix multiplication. For instance, x equals red times 0.4124 plus green times 0.3576 plus blue times 0.1805.
[31:05]Where did I get those matrix multipliers from? You might be sorry you asked. Check out the Wikipedia page on the sRGB color space. There you can read about all the generalizations I have made and how to correct them. Please be my guest.
[31:21]Again each conversion is performed using awk. This time I am passing the three linear values previously calculated which are then referred to in the expression as $1, $2 and $3. The BC command would have been able to cope with these simpler expressions but for consistency I stuck to awk. Finally I use the calculated x and y values to build up a JSON string that we can directly pass to the Hue API in the way we learned from the last installment. I have simply echoed this to stand it out for you to copy. I don't think it needs much imagination to see how these two scripts could be combined to create a single one that takes the name of a light and the desired color and makes it happen. Furthermore, the calculation for color temperature would be easily handled in the same way as those in the latter script, and of course, brightness is straightforward. In the third and final installment, I'll take this to the next level.
[32:20]
Tiny Tip – Cable Tags
[32:21]Music.
[32:28]The instructions said, use only the cable that came with the product. I said, well then make it distinctive and not look like every other USB cable in my cable box. I don't know whether I believe my Manta sleep mask needs that exact USB cable to charge, but I do know that my Epson scanner has real troubles with most generic cables. In the latter case, there are large noise suppression blobs on the cable that make it obvious. In the former case, it looks like any other USB-A to USB-C cable. I have some other products with these types of admonitions, plus there are some cables that only work to charge and others that transfer data faster or slower, so I decided I needed to find a solution to identifying the right cables.
[33:16]I have a brother label printer, so I wondered if there was something I could do to create a kind of flag. I've seen commercial cablers use such things, and some commercial products come with them attached. Hair dryers usually have one telling you not to use them in the bath. I could find no such solution. Somewhere in my searching, I came across the idea of cable ties with a rectangular tag on the end. There were a few products on Amazon, but I settled on the Nice Purchase 250 pieces 6 inch wire zip ties self-locking plastic nylon cable ties multi-colour network wire plastic strips label mark tag. They're about 14 US dollars. If you didn't get the idea from the Amazon product name, these are just like regular plastic zip ties, but on the end with the hole there is a flat panel about 25 by 15 millimetres. The pack comes with 250 stick-on labels you can write on, or you can write directly on the tags with permanent marker. I chose to use my label printer because my handwriting is terrible. The colours are red, green, blue, yellow, orange, black and the usual translucent white. That's 7 different colours and they seem to be in roughly equal numbers. The ties are long enough to go around something of 30mm diameter, so they'll certainly do to label all of your household cables. You can even bunch and label multiple cables in one go if desired.
[34:40]
Manta Sleep Masks
[34:40]I have lived in my current home for over 20 years. In that time I have often complained, usually to friends and family but also to the local council, about the insufficient number of streetlights on our street. Late last year we finally saw the installation of some additional lights. It has been a great improvement except for two things. First, there are still a couple of dark patches, thanks to the large trees that line the street. Second, one of the new lights is about 10 metres from our bedroom window. I guess you need to be careful what you wish for.
[35:18]That new light adds to one on the other side of the street in throwing light into the bedroom. It is established science that a dark room aids sleep, so this is less than ideal. deal. I considered blackout curtains but my wife prefers some light in the room anyway so I went in a different direction. In a sense I got blackout curtains just for my eyes. It's a rare occasion when an online advertisement grabs my attention but the one for Mantasleep did. The company sells a range of sleep masks and various accessories for them. Their mission statement begins, skins. Empower light sleepers to sleep better so they can do more. They have a modest product range covering different values in some specific use cases. For everyday use there's the classic Mantis Sleep Mask. It offers complete blackout without any pressure on your eyes and it's priced at $35 US. They also offer a silk version for added comfort priced at $69. If you prefer something thing with advanced materials and designed for side sleepers, the Manta Pro Sleep Mask might be your choice at $79.
[36:31]You might be interested in the Mantis Sound Sleep Mask. It features built-in Bluetooth speakers so you can listen to soothing sounds while falling asleep. This model costs $143. For kids, they have the Manta Kids Sleep Mask, specially designed for young ones, priced at $29. Looking for therapeutic options? The Manta Weighted Sleep Mask is designed to relieve insomnia and stress with gentle weights in the front, priced at $49. If you need relief from puffy eyes and headaches, consider the Manta Cool Sleep Mask. It contains cooling beads that can be chilled in the freezer before use. Available for $45. On the other hand, the Manta Steam Sleep Mask provides warmth and steam to soothe dry eyes, sinus pressure and eye strain. Simply microwave the eye cups for warmth. This model is also $45. You can also customize your mask with different eye cups. Basic eye cups start at $23 while the pro eye cups are available for $47 and the basic mask band itself costs $23. Every Manta mask includes a pocket full Manta Aroma Dots infused with lavender, eucalyptus or bergamot oils. Each pack of 10 dots gives you at least 4 nights of soothing aroma and it's $33 for 3 packs. Now back to my situation.
[37:52]I had previously tried sleep phones, which I reviewed back in 2019, to listen to soothing sounds when I was falling asleep. These sounded great and were comfortable, but were too hot for summer use, and while it was possible to wear them in such a way to block light from your eyes, they were not designed for that. I wanted to regain that ability to fall asleep to sounds. I have previously reviewed the apps Pizzizz in 2019 and Portal in 2023. Both of these apps are ideal for this task. My favourite sound is rain, and Portal's rain in the Julian Alps in Slovenia really hits the spot for me. So I purchased the Manta Sound Mask.
[38:35]My mask shipped from Atlanta, but only a few weeks after I received it, Manta opened an Australian shop. In the box was the fully assembled mask, USB-A to USB-C charging cable, an optional overhead strap, a carry wash bag, and a small booklet which guides you through setup. The mask has infinitely adjustable fit in two ways. First, the band fastens at the back with a system like Velcro, so you can get a perfect fit for your head size. The second adjustability is the eye cups. These attach to the inside of the band, also with the Velcro-like system. The booklet explains a process for adjusting these for the perfect fit. On first setup, I sat in a brightly lit room as I adjusted and tested, adjusted and tested. I can confirm that properly adjusted, the mask blocks 100% of light.
[39:29]The one issue that comes with fit adjustment is if you choose to have a fairly loose fit, then lying your head on a pillow will allow the mask to deform and this can let some light in. In my experience it is never enough light to be distracting with my eyes closed but if I open them it becomes obvious if the room has significant light. Properly adjusted and with a snug but comfortable fit this is not really a problem.
[39:55]A couple of times recently I have woken up in the morning and lifted the mask to be surprised by how much light is in the room. As I only started using my mask well past the autumnal equinox down here in the southern hemisphere, I expect I will like this aspect a lot more in the middle of summer. What I have described so far is true for all of the mask types. Unique to the Pro and Sound masks are the C-shaped eye cups. Imagine a donut shape with a membrane on one side of the hole. The standard eye cups are like this though oval shaped. The pro eye cups have their outer edge open like the donut has been pinched flat on that side. This might seem counterintuitive in terms of blocking light but I assure you they still can. This absent outer edge is what makes it comfortable to sleep with the side of your head on the pillow. Unique to the sound mask is the extra outer layer this again attaches using the velcro-like system it can be removed to wash the rest of the mask or if you don't want to listen to sounds and want a lighter mask.
[41:03]When attached, the outer layer extends back behind your ears but not all the way around the strap. This leaves the strap easily accessible for fit adjustment. On each side there is a fairly long horizontal slot and in each slot there is a small tab designed to easily grasp which is attached to one of the razor thin bluetooth speakers. It's very easy to slide these to the perfect spot over your ears while wearing the mask, yet they don't move around much when left alone. On the front of the outer layer are three buttons. The center button is the main action button used for pairing, connecting and stopping and starting audio. Either side of these are volume buttons. These make sense, to western cultures at least, in that the left one turns the volume down and the right one up as viewed from the wearer's perspective. The buttons require a deliberate press to activate so you won't do so by accident. You'll also know when you've activated it as there is a solid click. This sounds quite loud too which is a slight downside in my view. The buttons are positioned at the base of my forehead making them easy to press.
[42:12]Pairing is straightforward and subsequently you just need to hold the center button down for three seconds to reconnect. You can also disconnect in this way, however the unit will automatically shut itself down when no audio has been transmitted for 30 minutes. When I use Portal I use its built-in timer function to play the sound for one hour. Therefore the Manta will only be alive for 90 minutes per night. Given the 20 hour battery life that's nearly two weeks of use on a single charge so I've gotten to the habit of charging it once a week. The sound quality from the speakers is excellent. I'm sure they won't win any audiophile awards but the high quality recordings from Portal total, sounds superb. I can hear the texture of the rain. If you lie on your side, you will inevitably get louder sound in the ear on your pillow, but I've found after a minute or so my brain adapts to this and I just hear the rain. For the first week or so, I found the masks to be somewhat bulky on my face, but I've gotten used to it. I can say that once I've fallen asleep, I am not waking up on account of the mask, quite the opposite. it. By glancing at my Apple Health sleep tracking data, I can tell you I still sleep for around the same amount of time as before, but I wake up less times during the night on average. I've recently had multiple nights in a row with no waking, which simply never happened before.
[43:36]I would go so far as to say the mask usually feels more comfortable in the morning than it did the night before. I think this may be due to the materials having warmed up to my body temperature and therefore being that little bit more malleable. The only time I have found I want to take the mask off is if I have a headache as any pressure on my temple feels uncomfortable.
[43:58]On the whole, I'm very happy with my purchase. I'm looking forward to increased utility in the summer months. I recently had a short trip away from home and used it in the hotel, where we always leave some kind of light on so we don't end up walking into walls or furniture in unexpected places. It worked brilliantly.
[44:17]One other use Manta recommend for their masks is napping. In fact, I left out one thing from the list of box contents. A couple of stickers, one with the Manta Sleep logo and one that proclaims, Proudly Pro Nap. That gets to the heart of Manta's mission. It's not to help you sleep, but to give you the energy to live your best life. In pursuit of this, the Manta website is full of useful information on how to use their products, how to promote better sleep in other ways, and why you should forgo coffee and instead take a nap at work. They also send regular emails, if given permission, that include tips and tricks and often special offers. Speaking of special offers, I will close this review with a tip of my own. If you are wanting to buy, navigate to one of the product pages at mantasleep.com or use one of the many links I have provided in the blog post and just leave it sitting there for a little while. I think it takes a couple of minutes. You will get a pop-up that offers you a nice 10% discount on your order. In my case, that more than covered the shipping from Atlanta to New Zealand.
[45:29]Well, that's going to wind this up for this week. Did you know you can email Alison at alisonatpodfeet.com any time you like? If you have a question or a suggestion, just send it on over. Remember, everything good starts with podfeet.com. You can follow her on Mastodon at podfeet.com slash Mastodon. If you want to listen to the podcasts on YouTube, you can go to podfeet.com slash YouTube. If you want to join the conversation, you can join our Slack community at podfeet.com slash Slack, where you can talk to me and all of the other lovely Nocella castaways. You can support the show at podfeet.com slash Patreon or with a one-time donation at podfeet.com slash PayPal. And if you want to join in the fun of the live show, you'll have to wait until Sunday, September 8th to head over to podfeet.com slash live on Sunday nights at 5pm Pacific time and join the friendly and enthusiastic Nosilla Castaways. Thanks for listening and stay subscribed.
[46:34]Music.