Skip to content

Commit

Permalink
devices.go - Functions for Devices struct
Browse files Browse the repository at this point in the history
Start with Devices.FindThermostat() a helper to find thermostats by their name
  • Loading branch information
chmorgan committed Sep 10, 2018
1 parent f7e4486 commit c9ac85d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions devices.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package nest

/**
* Helper function to find a Thermostat in the Devices struct by its name
* Returns nil if no Thermostat was found
*/
func (d *Devices) FindThermostat(name string) *Thermostat {
for _, t := range d.Thermostats {
if t.Name == name {
return t
}
}

return nil
}

0 comments on commit c9ac85d

Please sign in to comment.