Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two thermostats #111

Open
dtolone opened this issue Jan 14, 2020 · 8 comments
Open

Two thermostats #111

dtolone opened this issue Jan 14, 2020 · 8 comments
Labels

Comments

@dtolone
Copy link

dtolone commented Jan 14, 2020

I have two thermostats attached to my account. How can I select which one I want to read from?

Thank you

@gboudreau
Copy link
Owner

You can use the $nest->getDevices() method to get a list of devices.
Then, each getter or setting method can take an optional serial number in parameter, to work with a specific device. eg. $next-> getDeviceInfo($serial_number)

@cagivacode
Copy link

I have been running multiple thermostats for 3+ years....and yesterday at 7pm the sort order of returned devices ($nest->getDevices()) changed????

So I had to go back into my code and explicitly set the serial_numbers.....instead of using $devices_serials[0] / $devices_serials[1].

not a big deal.....but a very odd random change

@bauzer714
Copy link
Contributor

@cagivacode - there is no sorting applied to the getDevices method. Not sure what your code looks like but if you can provide it I could give you some code that might be a bit more versatile. Alternatively, I could probably write a function that sorts it by their "where" location.

 foreach ($this->last_status->user->{$this->userid}->structures as $structure) {
            list(, $structure_id) = explode('.', $structure);
            foreach ($this->last_status->structure->{$structure_id}->devices as $device) {
                list(, $device_serial) = explode('.', $device);
                $devices_serials[] = $device_serial;
            }
        }

@cagivacode
Copy link

I have it sorted just fine now.....but my original code just used $devices_serials[0] / $devices_serials[1] / $devices_serials[3].

I have 3 zones in one structure.

and they always came back in the same order (for 3+ years).....then last night they came back in a completely different order.

I was just pointing out that not explicitly managing the serials (one way or another) is no longer dependable in a multi thermostat setup.

@SpaceMag
Copy link

Hey all,
I also have 2 Devices connected with my google account.
When I list the devices using: $nest->getDevices() I can only get the values of my first Thermostat. The second is not shown. Online on "https://home.nest.com/" both thermostats are shown.

Any Idea? hmmm

@bauzer714
Copy link
Contributor

Sounds like this is an error in your implementation rather than the library. Assuming they are at the same structure you can use the below to confirm both are being returned.

var_dump($nest->getDevices());

@SpaceMag
Copy link

Okay, with this command I get a list of my two devices. So they exist! Great, thanks!
Now I need to find out how the get the values from the second Devices in my request :-)

But thanks already, this helped!

@bauzer714
Copy link
Contributor

When you have more than one device, include
the serial number you see in getDevices to the function you're using. Look at the function definition and it will tell you more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants