VIRTUAL DAN

VIRTUAL DAN

Notes from my travels around the internet

VIRTUAL DAN
  • My Pacific Northwest Solar
  • About
Monthly Archives: December 2019

My Hue Lighting Experiment

A while ago, I bought a Hue light and bridge to experiment with. Hue Lights are a smart home light that can be automatically turned on and off via a timer or event trigger. I decided to start experimenting with Hue, because they have a pretty easy API to use that allows fully flexible integration with other sorts of devices or data.

I could of gone the simple route and just used IFTTT.com to integrate my hue lights with other devices. For a few years now I have been using IFTTT.com, and for the most part I could handle all my geeky smarthome needs using IFTTT. However, I don’t find it as flexible as just coding it myself. IFTTT does have the ability to use its custom language platform, but after looking at it I decided I didn’t have the energy to learn another proprietary language/structure, so I have decided to do more with building my own custom logic in C# and using Microsoft Azure. I will still use IFTTT for most the simple things, but my goal is to start integrating everything into my own custom platform to manage devices.

So my first ‘Hello World‘ application using the Hue API and Microsoft Azure platform was to turn a light on every morning, varying the color of the light by the weather forecast for the day. So if it is supposed to rain the light will be blue, if it is to be sunny the light will be yellow.

There were numerous hurdles to doing this, primarily because I was trying so many new things. Learning the base Hue API for internal access was by far the easiest, I was able to run commands from my local network in under an hour. After that, I tackled the logic to call the weather API, which also turned out to be pretty easy. It turns out the National Weather Service has an API that you can call to get the days weather –
https://www.weather.gov/documentation/services-web-api. Pretty simple authentication, and once I got past that I found the endpoint to call and in an hour or so I had logic built to pull the days forecast. Thinking I was close to achieving my goal, I was feeling 90% done with my project. Of course, as with most programming projects, it turns out the last 10% of the project consumes 90% of the time. Here is where it got complicated:

  1. Hue remote API access.I want this program to run out at Microsoft Azure, so that I don’t have to have my PC have to wake up at 6AM to run the job. So I had to configure my Hue bridge to take requests from outside my home network. Hue uses OAUTH to communicate security credentials, and my understanding of OATH flow was not that current (I am an old username / password guy..) so I had to first re-conceptualize the whole authentication / refresh token flow and figure out how to support it. Once I figured all that out I had to figure out how I wanted to store my tokens, so I had to build a subsystem to manage that whole process. I made this work more complicated than I needed to of course, because I made it flexible to handle future APIs that use Oauth. So I burned several hours getting an understanding of the workflow, and building out all that. But now I think I have a platform ready that will make my next Ouath integration easier.
  2. Azure Functions and .NetCore.  This is a great example of how software projects go way over deadline. Because I am in charge of the scope for my little experiment, I decided to expand it a bit. I wanted to set up a new Azure function to handle all my future IOT needs. Microsoft’s Visual Studio now comes with a nice template to build Azure Functions for Azure, so I decided to use it. I also decided to build it using .Net Core, which is the newest and most efficient .net framework. .Net Core allows to run .net on Linux machines, so in the future if I want to run these or other programs locally on a Raspberry Pi, that sets me up to do that in the future. It turns out I seriously underestimated the time it would take to build this out using .Net Core. The biggest hurdle was all my utility class libraries are built in .net Framework 4.7, which is not compatible with .Net Core. So I had to reinvision my future architecture for my class libraries. I experimented with .Net Standard (a compatibility standard), and threw that out. I ended up just standing up parallel utilities in .Net Core, which at this point I will use for all my IOT projects. I think it was the right thing to do, but this probably tripled the time I had budgeted for this project. Once I got all this build out and plugged into the new Azure functions project. I was easily able to publish this project to Azure, and my project was live! Each day at 6AM the program wakes up at Azure, and turns the light on in my house.

My first few days of testing happened to be rainy, so the light was always blue. I got tired of that pretty quick, so I decided to add logic to vary the color of the light by ‘raininess’. Using this code, I now can vary the light color by approximately the forecast for the day:

string shortforecast = p.shortForecast.ToLower();
int rainScore = 100;
rainScore += (shortforecast.IndexOf("rain likely") >= 0) ? 155 : 0;
rainScore += (shortforecast.IndexOf("chance of rain") >= 0) ? 100 : 0;
rainScore += (shortforecast.IndexOf("occasional showers") >= 0
|| shortforecast.IndexOf("slight chance rain showers") >= 0
|| shortforecast.IndexOf("light rain") >= 0
) ? 50 : 0;
if (rainScore == 100 && shortforecast.IndexOf("rain") >= 0)
{
rainScore += 25;
}
int sunScore = 100;
sunScore += (shortforecast.IndexOf("sunny") >= 0) ? 155 : 0;
sunScore += (shortforecast.IndexOf("sunbreak") >= 0) ? 100 : 0;
sunScore += (shortforecast.IndexOf("partly cloudy") >= 0) ? 50 : 0;
if (sunScore == 0 && shortforecast.IndexOf(" sun ") >= 0)
{
sunScore += 25;
}

I then build the color for the hue light of the rain and sun intensity. Note that I am using one of these ridiculously expensive color hue lights (around $50), which gives me the flexibility of using a vast array of colors.

So for now my experiment is complete, and I am enjoying a quick glance at the light to see the days weather forecast. This has been an interesting (though over budget) experiment, leading me to even more ideas for the future. Please don’t think I am an idiot for spending $50 for a light that changes color based on the weather – I consider this is an experiment and the first step in building out a fully integrated smarthome.

December 15, 2019 Dan Leave a comment

Expedia – After The Drop

In September I made an ill-timed move into Expedia stock, just in time to see the stock drop by 30% in November. The drop was primarily due to a bad earnings release – revenue number lower than expected and and EPS miss by $0.43 a share. In addition, the market is spooked by Google getting into the vacation rentals space in this already competitive environment.

So what to do now? Do I bail or buy on the dip? Arguably, its too late to bail on the stock:

6 month Expedia stock price

So I need to see if it makes sense to add to my position – because if I liked it at $132 I should love it at $94. Looking at the forward estimates does’t paint a great picture:

For the last year for Forward Twelve Month estimates (FTM) have been consistently dropping, at even after the drop the forward price earnings growth (PEG) metric is historically high. So that explains the nervousness about the stock.

However, if you believe the nervousness that Google will keep squeezing Expedia is overdone, and they can stabilize EPS growth, I think there is some opportunity here. Short term I think the drop is overdone. This is still a stock that is growing earnings at 50% per year, with a PE below market. Not that I am super bullish on this stock long term, I just think its OK to play for a bounce on this. So in my case, I added to my position in late November to get by cost basis break-even lower. I think this will be a short term (1-2 month) trade, with the assumption that I will lighten up on my Expedia holdings after a month or so, and take the short term tax loss on my initial purchase. My valuation and technical model is positive on this stock for the month of December, so I would guess the majority of the bounce will happen in the next 30 days. After that, I will have to wait and see because my model doesnt forecast past 30 days.

Long term, I am not sold that Expedia will dominate the travel world, but I think its worth a 30 day trade to assume that everybody who was going to sell has already sold.

December 1, 2019 Dan Leave a comment

Archives

  • February 2021 (1)
  • January 2021 (1)
  • December 2020 (2)
  • November 2020 (2)
  • October 2020 (2)
  • September 2020 (2)
  • August 2020 (2)
  • July 2020 (2)
  • June 2020 (2)
  • May 2020 (2)
  • April 2020 (2)
  • March 2020 (2)
  • February 2020 (2)
  • January 2020 (3)
  • December 2019 (2)
  • November 2019 (2)
  • October 2019 (2)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (2)
  • June 2019 (1)
  • May 2019 (3)
  • April 2019 (2)
  • March 2019 (2)
  • February 2019 (2)
  • January 2019 (3)
  • December 2018 (2)
  • November 2018 (2)
  • October 2018 (2)
  • September 2018 (2)
  • August 2018 (2)
  • July 2018 (2)
  • June 2018 (2)
  • May 2018 (2)
  • April 2018 (2)
  • March 2018 (2)
  • February 2018 (1)
  • January 2018 (3)
  • December 2017 (2)
  • November 2017 (2)
  • October 2017 (2)
  • September 2017 (2)
  • August 2017 (2)
  • July 2017 (2)
  • June 2017 (3)
  • May 2017 (2)
  • April 2017 (1)
  • March 2017 (3)
  • February 2017 (3)
  • January 2017 (2)
  • December 2016 (2)
  • November 2016 (3)
  • October 2016 (2)
  • September 2016 (2)
  • August 2016 (2)
  • July 2016 (2)
  • June 2016 (2)
  • May 2016 (2)
  • April 2016 (2)
  • March 2016 (2)
  • February 2016 (3)
  • January 2016 (4)
  • December 2015 (2)
  • November 2015 (2)
  • October 2015 (3)
  • September 2015 (3)
  • August 2015 (2)
  • July 2015 (4)
  • June 2015 (2)
  • May 2015 (4)
  • April 2015 (3)
  • March 2015 (4)
  • February 2015 (4)
  • January 2015 (4)
  • December 2014 (5)
  • November 2014 (3)
  • October 2014 (5)
  • September 2014 (3)
  • August 2014 (5)
  • July 2014 (4)
  • June 2014 (4)
  • May 2014 (3)
  • April 2014 (3)
  • March 2014 (5)
  • February 2014 (2)
  • January 2014 (5)
  • December 2013 (4)
  • November 2013 (6)
  • October 2013 (3)
  • September 2013 (3)
  • August 2013 (4)
  • July 2013 (3)
  • June 2013 (3)
  • May 2013 (5)
  • April 2013 (2)
  • March 2013 (6)
  • February 2013 (6)
  • January 2013 (5)
  • December 2012 (5)
  • November 2012 (4)
  • October 2012 (3)
  • September 2012 (4)
  • August 2012 (3)
  • July 2012 (3)
  • June 2012 (2)
  • May 2012 (3)
  • March 2012 (3)
  • February 2012 (2)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (3)
  • October 2011 (2)
  • September 2011 (2)
  • August 2011 (3)
  • July 2011 (4)
  • June 2011 (4)
  • May 2011 (3)
  • April 2011 (6)
  • March 2011 (8)
WEBSITE DISCLAIMER: The operator of this site (Vertical Financial Systems, Inc) are not registered investment advisers, broker/dealers, or research analysts/organizations. The content on this website is issued solely for information purposes and should not to be construed as an offer to buy, sell, or trade in any way, any security mentioned herein. All information presented on this website is believed to be reliable and written in good faith, but no representation or warranty, expressed or implied is made as to their accuracy, completeness or correctness. You are responsible for doing your own research before investing in any securities mentioned herein. Readers are urged to consult with their own independent financial advisors with respect to any investment. Neither Vertical Financial Systems, Inc, nor its officers or employees accept any liability whatsoever for any direct or consequential loss arising from any use of information on this website.
Full Disclosure: As an Amazon Associate I earn from qualifying purchases
Powered by WordPress | theme SG Simple