Skip to content

Commit

Permalink
feat: Add interface methods to Device and MobileDevice object
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzolino committed Mar 18, 2022
1 parent cdd2c69 commit 87787b5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gotado

import "context"

// GetTemperatureOffset returns the temperature offsets of the device
func (d *Device) GetTemperatureOffset(ctx context.Context) (*TemperatureOffset, error) {
temperatureOffset := &TemperatureOffset{}
if err := d.client.get(ctx, apiURL("devices/%s/temperatureOffset", d.SerialNo), &temperatureOffset); err != nil {
return nil, err
}
return temperatureOffset, nil
}
1 change: 1 addition & 0 deletions home.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (h *Home) GetMobileDevices(ctx context.Context) ([]*MobileDevice, error) {
}
for _, mobileDevice := range mobileDevices {
mobileDevice.client = h.client
mobileDevice.home = h
}
return mobileDevices, nil
}
Expand Down
13 changes: 13 additions & 0 deletions mobile_device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package gotado

import "context"

// SetMobileDeviceSettings updates the mobile device with the given settings
func (md *MobileDevice) SetSettings(ctx context.Context, settings MobileDeviceSettings) error {
return md.client.put(ctx, apiURL("homes/%d/mobileDevices/%d/settings", md.home.ID, md.ID), settings)
}

// DeleteMobileDevice deletes the mobile device
func (md *MobileDevice) Delete(ctx context.Context) error {
return md.client.delete(ctx, apiURL("homes/%d/mobileDevices/%d", md.home.ID, md.ID))
}
1 change: 1 addition & 0 deletions models.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ type Installation struct {
// MobileDevice represents a mobile device with the tado° app installed
type MobileDevice struct {
client *client
home *Home
Name string `json:"name"`
ID int32 `json:"id"`
Settings MobileDeviceSettings `json:"settings"`
Expand Down

0 comments on commit 87787b5

Please sign in to comment.