<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason Hee</title>
    <description>The latest articles on DEV Community by Jason Hee (@jasonheecs).</description>
    <link>https://dev.to/jasonheecs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F633450%2F2c8ea3bb-96d6-4e6c-b3ae-ca70b8f51b68.png</url>
      <title>DEV Community: Jason Hee</title>
      <link>https://dev.to/jasonheecs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jasonheecs"/>
    <language>en</language>
    <item>
      <title>Automating the Elgato Key Light</title>
      <dc:creator>Jason Hee</dc:creator>
      <pubDate>Wed, 26 May 2021 10:42:24 +0000</pubDate>
      <link>https://dev.to/jasonheecs/automating-the-elgato-key-light-2242</link>
      <guid>https://dev.to/jasonheecs/automating-the-elgato-key-light-2242</guid>
      <description>&lt;p&gt;As video conference calls are now part of my daily life, I decided to investigate how I can look better in front of my webcam. After some research, I bought an Elgato Key Light Air to help illuminate my face better.&lt;/p&gt;

&lt;p&gt;So far, I'm delighted with the purchase. The key light has definitely improved how I look on video calls. But having to turn it on every time I have a video call and then turn it off when the call ends is a pain.&lt;/p&gt;

&lt;p&gt;I considered leaving the light on throughout the work day, but the light can be quite searing to my eyes when it's shining at me for an extended period of time.&lt;/p&gt;

&lt;p&gt;I then put on my software engineering hat and wondered, "Can I automate this inconvenience away?". As it turns out, I can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Elgato Key Light REST API
&lt;/h2&gt;

&lt;p&gt;The Elgato Key Light and Key Light Air devices actually have a web server (listening on port 9123) built in. The web server exposes a REST API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /elgato/lights
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This endpoint returns the status of the key light.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample Response&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "numberOfLights": 1,
    "lights": [
        {
            "on": 1,
            "brightness": 9,
            "temperature": 262
        }
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For updating the key light, there's a PUT action endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PUT /elgato/lights

Content-Type: 'application/json'
--data-raw '{
  "Lights": [
    {
      "Temperature": 344,
      "Brightness": 100,
      "On": 1
    }
  ]
}'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This endpoint allows you to set the attributes of the key light. You can set the brightness and temperature, including turning it on or off.&lt;/p&gt;

&lt;p&gt;This means that I can turn the Elgato Key Light off and on by interfacing with its REST API endpoints.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Node.js script
&lt;/h2&gt;

&lt;p&gt;I created  &lt;a href="https://github.com/jasonheecs/elgato-key-light-automator"&gt;a Node.js script that toggles on and off the Elgato Key Light&lt;/a&gt;. I then bound the execution of the script to a keyboard macro. So now, I can tap a key to turn the Key Light on and off. :D&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;It is relatively easy for one to interface with an Elgato Key Light or Key Light Air using its built-in REST API. You can even integrate it into your smart home via something like  &lt;a href="https://github.com/homebridge/homebridge"&gt;Homebridge&lt;/a&gt; .&lt;/p&gt;

</description>
      <category>node</category>
      <category>automation</category>
      <category>smarthome</category>
      <category>api</category>
    </item>
    <item>
      <title>How to use YAML Aliases</title>
      <dc:creator>Jason Hee</dc:creator>
      <pubDate>Tue, 18 May 2021 13:07:06 +0000</pubDate>
      <link>https://dev.to/jasonheecs/how-to-use-yaml-aliases-3kig</link>
      <guid>https://dev.to/jasonheecs/how-to-use-yaml-aliases-3kig</guid>
      <description>&lt;p&gt;Have you ever had to copy and paste duplicate content in a YAML file and wondered if it is possible to DRY that up? As it turns out, YAML allows you to repeat nodes via aliases.&lt;/p&gt;

&lt;p&gt;YAML Aliases allow you to assign a name to a value or block of data and recall the assigned data by its name in the YAML file. Aliases should work for any file written in YAML.&lt;/p&gt;

&lt;h1&gt;
  
  
  Simple Example
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;hello&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;hello'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*hello&lt;/span&gt;  &lt;span class="c1"&gt;#greeting.hello has the string value of 'hello'&lt;/span&gt;
&lt;span class="na"&gt;new_greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;room'&lt;/span&gt;
  &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*hello&lt;/span&gt;  &lt;span class="c1"&gt;#new_greeting.hello has the string value of 'hello'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Aliasing blocks of data
&lt;/h1&gt;

&lt;p&gt;Besides string or number values, you can alias a block of data as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;foo&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
    &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;  &lt;span class="c1"&gt;#greeting.bar has the same values as foo.bar.&lt;/span&gt;
             &lt;span class="c1"&gt;#So greeting.bar.baz is 'bazbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Modifying a section of an alias
&lt;/h1&gt;

&lt;p&gt;You can copy an alias and modify a section of it by using the merge key (&amp;lt;&amp;lt;:):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
  &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
  &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;       &lt;span class="c1"&gt;# greeting.bar.qux is 'quxqux'&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;notbaz'&lt;/span&gt;  &lt;span class="c1"&gt;# greeting.bar.baz is 'notbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Defining aliases from modified aliases
&lt;/h1&gt;

&lt;p&gt;You can even modify a section of an alias and define that as a new alias:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;bar&lt;/span&gt;
  &lt;span class="na"&gt;qux&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;quxqux'&lt;/span&gt;
  &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;bazbaz'&lt;/span&gt;
&lt;span class="na"&gt;greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;world'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nl"&gt;&amp;amp;newalias&lt;/span&gt;
    &lt;span class="s"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*bar&lt;/span&gt;
    &lt;span class="na"&gt;baz&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;notbaz'&lt;/span&gt;
&lt;span class="na"&gt;new_greeting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;audience&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;room'&lt;/span&gt;
  &lt;span class="na"&gt;bar&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="nv"&gt;*newalias&lt;/span&gt;  &lt;span class="c1"&gt;#new_greeting.bar.baz is 'notbaz'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  YAML specification
&lt;/h1&gt;

&lt;p&gt;Alias nodes are described in the YAML specification &lt;a href="https://yaml.org/spec/1.2/spec.html#id2786196"&gt;here&lt;/a&gt; &lt;/p&gt;

</description>
      <category>yaml</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
