{"id":784,"date":"2020-06-22T22:48:33","date_gmt":"2020-06-23T04:48:33","guid":{"rendered":"https:\/\/blog.escarra.org\/?p=784"},"modified":"2020-06-30T14:21:34","modified_gmt":"2020-06-30T20:21:34","slug":"on-a-call-light-notification-for-the-new-covid-19-world","status":"publish","type":"post","link":"https:\/\/blog.escarra.org\/?p=784","title":{"rendered":"&#8220;On a Call&#8221; light notification for the new COVID-19 world"},"content":{"rendered":"\n<p>I am fortunate to have the opportunity to continue working from home during the pandemic. As myself and my family adapt to a new normal in a new working space at home, a way of notifying them when I&#8217;m on a call would prove useful.<\/p>\n\n\n\n<p>So if you own a Plantronics (now Poly) headset, and have a Philips Hue Bridge with a light, I&#8217;ll explain how to build a little one-line script and have it light up when on a call. I love Plantronics (umm&#8230; Poly) stuff!!!<\/p>\n\n\n\n<p>This works pretty much independent of the software you use to make calls or join meetings, because we&#8217;re pulling call state from the headset, not the apps. <strong>Teams, Zoom, WebEx, Jabber, Skype for Business<\/strong>, the script does not care. If the Hub Desktop supports it as communications platform (and they support quite a few) then it&#8217;ll work.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img data-attachment-id=\"790\" data-permalink=\"https:\/\/blog.escarra.org\/?attachment_id=790\" data-orig-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2.jpg\" data-orig-size=\"1144,1501\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Gonzalo Escarr\\u00e1&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1592868446&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2-229x300.jpg\" data-large-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2-780x1024.jpg\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2.jpg\" alt=\"\" class=\"wp-image-790\" width=\"362\" height=\"475\" srcset=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2.jpg 1144w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2-229x300.jpg 229w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2-780x1024.jpg 780w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2-768x1008.jpg 768w\" sizes=\"(max-width: 362px) 100vw, 362px\" \/><\/figure><\/div>\n\n\n\n<p>Here&#8217;s the summary of steps:<\/p>\n\n\n\n<ol><li><strong>Install the Hub Desktop software.<\/strong> This exposes a local API endpoint that you can query for when your headset is active.<\/li><li><strong>Create an authorized user on your Hue Bridge<\/strong> so you can send it commands via REST API.<\/li><li><strong>Find the Light ID<\/strong> of the bulb you&#8217;re trying to change state<\/li><li><strong>Set up a Scheduled Task <\/strong>to run PowerShell, query the Hub Desktop API and send commands to the Hue Bridge when call state changes.<\/li><\/ol>\n\n\n\n<p>Step 1: Pretty straightforward: go <a rel=\"noreferrer noopener\" href=\"https:\/\/www.poly.com\/us\/en\/support\/downloads-apps\/hub-desktop\" target=\"_blank\">here<\/a> and run the software. This will expose an API endpoint locally on port 32017 meant for third party app integrations. You can only access this via localhost\/127.0.0.1, it does not listen on other interfaces. The endpoint we are interested in is <a href=\"http:\/\/localhost:32017\/Spokes\/CallServices\/CallManagerState\">http:\/\/localhost:32017\/Spokes\/CallServices\/CallManagerState<\/a><\/p>\n\n\n\n<p>Step 2: Navigate to https:\/\/IPOFYOURHUB\/debug\/clip.html then use URL of <strong>\/api<\/strong>, Body of <strong>{&#8220;devicetype&#8221;:&#8221;PolyHue#LAPTOP&#8221;}<\/strong> (change the json value to whatever you want, but the example will work), then go to your Hue Bridge, press the big button and press <strong>POST<\/strong>. You&#8217;ll get a username value back in the json response. <strong>COPY IT<\/strong> somewhere, as this is your key to sending authenticated API commands to the Hue Bridge.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-attachment-id=\"788\" data-permalink=\"https:\/\/blog.escarra.org\/?attachment_id=788\" data-orig-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture.jpg\" data-orig-size=\"1096,483\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Gonzalo Escarr\\u00e1&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1592868066&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-300x132.jpg\" data-large-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-1024x451.jpg\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-1024x451.jpg\" alt=\"\" class=\"wp-image-788\" width=\"512\" height=\"226\" srcset=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-1024x451.jpg 1024w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-300x132.jpg 300w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture-768x338.jpg 768w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture.jpg 1096w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>Step 3: Before you close the API Debug tool from your Hue Bridge, change the URL to <strong>\/api\/USERNAME\/lights<\/strong>, using your new API username from Step 2, then press <strong>GET<\/strong>. Look at the json response and find the root number that matches the name of the light you&#8217;re using. They will be simple numbers, and in my case it&#8217;s &#8220;23&#8221;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-attachment-id=\"787\" data-permalink=\"https:\/\/blog.escarra.org\/?attachment_id=787\" data-orig-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3.jpg\" data-orig-size=\"1069,877\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Gonzalo Escarr\\u00e1&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1592868740&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture3\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-300x246.jpg\" data-large-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-1024x840.jpg\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-1024x840.jpg\" alt=\"\" class=\"wp-image-787\" width=\"512\" height=\"420\" srcset=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-1024x840.jpg 1024w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-300x246.jpg 300w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3-768x630.jpg 768w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture3.jpg 1069w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<p>Step 4: Set up a Scheduled Task to run At log on, and also set it to restart every 5 minutes for 999 times in case it quits because of a network disruption. Then have it run &#8220;powershell&#8221; with the following arguments pasted in and edited for your settings. Replace <strong>BRIDGEID<\/strong>, <strong>USERNAME <\/strong>and <strong>LIGHTID <\/strong>with your values.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-attachment-id=\"792\" data-permalink=\"https:\/\/blog.escarra.org\/?attachment_id=792\" data-orig-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5.jpg\" data-orig-size=\"1269,322\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Gonzalo Escarr\\u00e1&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1592869106&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Capture5\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-300x76.jpg\" data-large-file=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-1024x260.jpg\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-1024x260.jpg\" alt=\"\" class=\"wp-image-792\" width=\"512\" height=\"130\" srcset=\"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-1024x260.jpg 1024w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-300x76.jpg 300w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5-768x195.jpg 768w, https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture5.jpg 1269w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>-WindowStyle Hidden -Command &amp;{$callStatePoll=Invoke-RestMethod -Method GET -Uri http:\/\/localhost:32017\/Spokes\/CallServices\/CallManagerState;while($true){$oldCallState = $callStatePoll.Result.HasActiveCall;$callStatePoll = Invoke-RestMethod -Method GET -Uri http:\/\/localhost:32017\/Spokes\/CallServices\/CallManagerState;$newCallState = $callStatePoll.Result.HasActiveCall;If ($oldCallState -ne $newCallState){Switch ($newCallState){$false {$body = @{\"on\"=$false} | ConvertTo-Json;Invoke-RestMethod -Method PUT -Uri http:\/\/BRIDGEIP\/api\/USERNAME\/lights\/LIGHTID\/state -Body $body};$true {$body = @{\"on\"=$true} | ConvertTo-Json;Invoke-RestMethod -Method PUT -Uri http:\/\/BRIDGEIP\/api\/USERNAME\/lights\/LIGHTID\/state -Body $body}}};Start-Sleep -Seconds 5}}<\/code><\/pre>\n\n\n\n<p>Now to test it, turn on the light, set it to the desired brightness and color, then turn it off. The script will check every 5 seconds your call state, and if it changes, it will flip the light on if you have an active call, and off if you don&#8217;t.<\/p>\n\n\n\n<p>The main gotcha: This will only work when using a Plantronics\/Poly headset, as we rely on the API from Hub Desktop to give us call state. Jabra Direct software may work but couldn&#8217;t get the right API endpoints to query call state.<\/p>\n\n\n\n<p>Hope it helps someone out there, and stay safe!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am fortunate to have the opportunity to continue working from home during the pandemic. As myself and my family adapt to a new normal in a new working space at home, a way of notifying them when I&#8217;m on a call would prove useful. So if you own a Plantronics (now Poly) headset, and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":790,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false,"jetpack_publicize_message":"\"On a Call\" light notification for the new work-from-home COVID-19 world with #Plantronics \/ #Poly Hub Desktop software, #PhilipsHue Bridge API, and #MicrosoftTeams","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/blog.escarra.org\/wp-content\/uploads\/2020\/06\/Capture2.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/posts\/784"}],"collection":[{"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=784"}],"version-history":[{"count":13,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/posts\/784\/revisions"}],"predecessor-version":[{"id":803,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/posts\/784\/revisions\/803"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=\/wp\/v2\/media\/790"}],"wp:attachment":[{"href":"https:\/\/blog.escarra.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=784"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=784"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.escarra.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=784"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}