Thursday, May 10, 2018

Nest Account not connecting to Google Assistant / Google Home

So recently I bought a Google Home Mini and I added my Nest Account easily to it using the Google Assistant App so I could control my Nest Thermostat with voice commands.

Everything was working great, and then one day, it just stopped working. The Google Assistant (through the Google Home Mini) kept saying it couldn't perform the temperature changes.

So in an attempt to fix it, I unlinked my Nest account and tried to re-add it.

However, when I tried to re-add it, here's what happened.


  1. I went to device settings in my Google Assistant.
  2. I tried to add "Nest".
  3. It brought me to a webpage confirming that the Google Assistant would be able to control aspects like temperature.
  4. I clicked "Apply".
  5. I was brought to a page that said "Accounts now linked".
  6. After a few seconds, the Google Assistant app said "Something went wrong. Please try again."


After many retry attempts, here's what finally worked.


  1. I went into the Nest app (but this can also be done at home.nest.com).
  2. I went into the thermostat, and then into the thermostat settings.
  3. Under the "About" section, I clicked on "Where" and then "Where" again.
  4. At the time, I had not assigned a room to the thermostat. So I assigned it a room. (remember, this is in the Nest Settings, NOT the Google Assistant Device settings).


After that, I tried re-linking, and everything worked!

So my suspicion, is that at some point, the Google Assistant linking process to Nest requires that the Nest device has a room assigned in the Nest settings. When the Nest device's room is not set, I guess the Google Assistant doesn't know what to do.

A couple of notes on this solution:

1. My Nest is the 1st gen Thermostat.
2. I'm using iOS, so I'm using the iOS Google Assistant and Google Home apps.
3. At some point between originally adding the Nest and successfully re-adding it, I did create and assign my other smart devices to rooms (ie. I assigned my Philips Hue bulbs to a room).
4. The room name that I picked for the Nest in the Nest settings, "Living Room", happened to be a room that I was already using for my Philips Hue bulbs. Not sure if that part matters, but it might.

Alright, that's it. Hope that helps some peeps.

Wednesday, December 16, 2015

Rails 4, Rspec not letting go of Gemfile.lock, can't Git Pull, can't checkout

Alright, this is going to be a super quick post but thought I'd let people know as this has come up a couple of times.

The environment is
  • Rails 4 or above
  • Git
  • Rspec for testing
So here's the issue. Every now and then, I try to do a Git Pull (say after a pull request has been merged) and Git won't let me because it seems my Gemfile.lock has some local changes that would be overwritten.

Easy enough, right? Just stash, or discard the changes. So I tried running 'git stash', or 'git checkout Gemfile.lock'. But then right after, I do a 'git status', and low and behold, the Gemfile.lock still has local changes. What the hell? Why isn't Git letting me stash the changes.

Well, it turns out, Git is letting me stash the changes, but very shortly after, something is changing the Gemfile.lock file right away. So right after I stash my changes, or discard, something comes right back and makes the changes again.

The culprit? Rpsec- well more specifically spring. So after running rspec, spring continues to run. As far as I understand, spring keeps your Rails environment running so you don't have to reload it on every rspec run (as far as I know, I could be way off). But the short of it is, the first time your run rspec, it fires up spring, and spring holds onto your Gemfile.lock.

So after you discard your changes, spring will apply the changes right again on Gemfile.lock (and perhaps other files).

How to solve it?

Simply stop spring by running "spring stop". At that point, you should have no issue discarding your changes using Git.

Worried about spring being stopped? Don't worry, it starts up again the next time you run rspec.

Alright, that's it for now. Hope that helps some peeps!

Monday, May 4, 2015

Ruby on Rails ActionMailer Configuration for Namecheap Private E-mail

Ever try setting up Ruby on Rails to use Namecheap's private e-mail to no avail. Me too. Finally figured out some settings that made things work.

First off, for your smtp settings:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => 'mail.privateemail.com',
  :port                 => 26,
  :user_name            => 'username@domain.com,
  :password             => 'yourpassword,
  :authentication       => :plain,
  :enable_starttls_auto => true  }

Of course, you can throw everything into environment variables.

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => ENV['SMTP_SERVER'],
  :port                 => ENV['SMTP_PORT'],
  :user_name            => ENV['SMTP_USER'],
  :password             => ENV['SMTP_PASSWORD'],
  :authentication       => :plain,
  :enable_starttls_auto => true  }

But the key thing here, or at least the thing that's unusual is PORT 26!!! It's right there in Namecheap's documentation but they say if you're going to use starttls - you must use port 26. That was the main thing that I seemed to stumble on. The other settings are very similar to say GMail settings.

Also, I did set my "from" address in my Mailer class to match my domain which may or may not have helped - I was too lazy to do a controlled experiment on that.

Anyway, hope that helps some peeps.

Friday, October 10, 2014

Google Chrome 38 Bug with Multiple Select / Multi-select and off-page or wizard style Web UI

Hey All,

This may cover a very specific set of people and the solution is not elegant but it works.

Setup

The issue arose only in Chrome 38 (so very recently) and although it came up in my specific situation, it may apply to others as well.

The application I was dealing with had a wizard style UI that was all controlled in javascript and CSS. That is, I loaded all the wizard pages at once, and the "next page" and "previous page" functionality was just sliding the pages along - no reloads.

More specifically, it looked something like this:

<div class='wizard-pages-wrapper'>
  <div class='wizard-pages'>
    <div class='wizard-page'>...</div>
    <div class='wizard-page'>...</div>
    <div class='wizard-page'>...</div>
  </div>
</div>

The idea is that the .wizard-pages-wrapper had a overflow hidden and that the "next page" and "previous page" would slide along by just adjusting the "margin-left" of the .wizard-pages div. This isn't anything new - just google wizard style web UI and you'll understand.

Issue

So the issue was this. On page 2 of my wizard, I had a multi-select box:

<select multiple='multiple'>
  <option>...</option>
  <option>...</option>
  <option>...</option>
</select>

On page 1, I had 3 choices for the user to make. Once the user makes a selection, the first thing my javascript code does is clear the multi-select box so that the user starts with a clean form. It does this BEFORE actually sliding to the left to give the "next page" functionality.

$("select[multiple='multiple'] option:selected").each(function(){
  $(this).removeAttr("selected");
});

Now remember, at this point - the multi-select box that is being cleared is currently "off-screen" - well it's more in the overflow section of .wizard-pages-wrapper - which is hidden.

The issue is that in Chrome 38 - if you have a multi-select box that is in a overflow hidden area and you affect it's selected items - Chrome brings that multi-select box into view. When it brings it into view, it screwed up all my margins for the wizard pages - so it kind of looked like the wizard was in between switching pages.


Solution

Albeit not elegant, I did find a solution that worked. Apparently - this behaviour of affecting selected items of a multi-select box and Chrome bringing it into view if it's in a overflow hidden area doesn't happen if the multi-select box itself is not visible (display:none).

So to fix this, this is what I changed my code to (note I'm selecting the multi-select box itself now, and not the options at the top level of my foreach loop):

$("select[multiple='multiple']").each(function(){
  $(this).hide();
  $(this).find("option:selected").(.removeAttr("selected");
  $(this).show();
});

Again, not necessarily elegant, but it worked.

Hope this helps out some peeps.

Friday, June 20, 2014

How Backbone plays nicely with Rails 4 (by skipping the authenticity token and by formatting params properly)

Alright, the blog post title is a little misleading because Backbone doesn't really do either of what I mentioned. Backbone does NOT skip the authenticity token nor does it format params properly for Rails. But it's what I google'd when me and my co-worker were looking for the answers. So I titled it this way to help some peeps.

Alright, so again, credit does not go fully to me on this - my co-worker and I had to figure this out.

How does Backbone 'Skip the authenticity token'

Alright, so I was just starting to learn backbone with a very simple setup: Rails Server with a Backbone app. I was following the tutorial on backbonetutorials.com. So I got to the part where the code calls a 'save' on the model:

user.save(userDetails)

and it all worked - much to my surprise. I thought for sure there was an issue in that there's no way Backbone knew about Rails' authenticity_token. Sure enough, when I went to the Rails log, there was no authenticity token being passed in the params (as there is when you submit a rails built form). Furthermore, looking at the request in Chrome's network tab - nope, no authenticity token in the request parameters.

Yet - somehow, the request was succeeding? Did Rails somehow know this is a Backbone request and ignore the authenticity token?

Turns out - this has nothing to do with Backbone - and everything to do with jquery-rails (the version of JQuery that ships as a gem as part of Rails standard releases these days).

So upon further inspection of the request in Chrome's network tab - indeed there was no authenticity token in the request parameters - BUT there was a X-CSRF-Token in the request headers!!!

Ahhhh - so Rails must check both places (request params AND/OR request headers) for a authenticity token.

The question is - who is appending this token to the request headers?

Turns out, it's JQuery-Rails. JQuery-Rails appends this header to all AJAX requests where the CSRF meta tags are present.

https://groups.google.com/forum/#!topic/rubyonrails-core/eyTb_WZXLcs

Very cool stuff. So Backbone doesn't skip the authenticity token - it just makes an AJAX request, which JQuery-Rails is smart enough to append a authenticity token to the header of that AJAX request.

How does Backbone format its params properly

As long as I've been using Rails, I've always understood the POST CREATE request to accept its parameters in a specific way. If you had a user that had a name and age, you would need to pass the parameters like this:

{ user : {name : "Casey", age : 31 } }

In other words, you would need to nest the values within a object that's named after the resource. However, looking at Backbone, backbone has its parameters like this:

{ name : "Casey", age : 31 }

Notice that it's not nested inside "user". What's really weird, is if I look at the Rails log for the request of a Backbone.model.save, here's what comes in as the parameters:

{ name : "Casey", age : 31, user : { name : "Casey", age : 31 } }

It turns out that Rails (in its infinite magic) uses a module called ParamsWrapper that I can only theorize analyzes what comes in, and if it's only one-level deep, massages the params so that there is an extra param that's formatted properly for Rails (two-levels deep). This way, you have access to the params the way you passed them in:

params[:name]
params[:age]

and you have access to them the way Rails needs it:

params[:user][:name]
params[:user][:age]

Pretty crazy stuff.

Hope this helps some peeps.

Wednesday, April 9, 2014

Ruby on Rails, Rest in Place with Authorization taken into Account

Hey all,

Just a quick one. Just started using Rest in Place in my Rails applications. If you don't know what it is - it seems to be the most popular In-place editing gem (according to Ruby Toolbox).

Anyway, the one thing that kind of got annoying, is that my view templates were getting pretty ugly with a lot of IF statements because I didn't want in-place editing to be active for people who weren't allowed to edit. I realize that Rest in Place still goes through the controller, so any authorization code you have on the controller side prevents true editing - but still, I wanted to prevent the UI in-place editing for people who weren't authorized to do so either.

So I created a simple helper to remedy this.

You can check out the Gist here.

Friday, March 7, 2014

After Effects Editing Mask Path (moving individual points)

Alright, this was frustrating the hell out of me - especially considering most posts and forum responses had the right idea but were missing one key element.

The issue is in Adobe After Effects and Masks.

Here's the setup


  • You have some layer (shape, picture, footage, whatever)
  • You add a layer Mask
  • You edit the Mask over time by setting keyframes on the Mask Path property

The issue

  • Anytime you try to move a single point on the Mask Path - the entire mask path moves - regardless of if you have the Pen Tool or Selection Tool selected

So yes - most posts ands forum responses I've seen talk about - "Make sure you have the Pen Tool" selected - so that way you're in path editing mode and then you should be able to move the individual points. I tried ad nausea and I couldn't get this to work.

Solution

  • It all had to do with what was selected in the timeline. I had the Mask selected (that is, the Mask property that shows up when you twirl down the layer itself) - which is wrong. This was the issue.
  • Once I selected the layer itself and NOT the mask, I could then select the Pen Tool and edit the points individually.
Kind of strange - but yeah - select the Layer and not its mask if you want to edit the Mask points individually. And yes - use the Pen Tool.

(note this is in Adobe After Effects CS6 - not sure about other versions).

Hope this helps out some peeps.