smartthings

package module
v0.0.0-...-3eaf8a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 6 Imported by: 1

README

smartthings

This class is an example of how to use the API provided by Samsung Smartthings for controlling your Smartthngs hub. Done in Go

None of this would be possible without all the documentation provided here:

https://developer.smartthings.com/docs/api/public/#section/Overview
https://developer.smartthings.com/docs/getting-started/welcome/
https://account.smartthings.com/tokens

Requirements

Samsung Smartthings account

Smartthings compatible hub

Personal Access Token -> https://account.smartthings.com/tokens

demo

cmds

Example tools in the cmds folder.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SmartThings

type SmartThings struct {
	// contains filtered or unexported fields
}

func New

func New() *SmartThings

func (*SmartThings) DeviceSwitchOnOff

func (pST *SmartThings) DeviceSwitchOnOff(sDeviceName string, bOn bool) bool

func (*SmartThings) Dump

func (pST *SmartThings) Dump()

func (*SmartThings) FindDevice

func (pST *SmartThings) FindDevice(sDeviceName string) int

func (*SmartThings) FindScene

func (pST *SmartThings) FindScene(sName string) int

func (*SmartThings) GetDeviceList

func (pST *SmartThings) GetDeviceList() bool

func (*SmartThings) GetDeviceSwitchStatus

func (pST *SmartThings) GetDeviceSwitchStatus(sDeviceName string) (err bool, status StDeviceStatus)

func (*SmartThings) GetSceneList

func (pST *SmartThings) GetSceneList() bool

func (*SmartThings) GetStructDevices

func (pST *SmartThings) GetStructDevices() bool

func (*SmartThings) GetStructScenes

func (pST *SmartThings) GetStructScenes() bool

func (*SmartThings) GetStructs

func (pST *SmartThings) GetStructs() bool

func (*SmartThings) PrintDeviceList

func (pST *SmartThings) PrintDeviceList() bool

func (*SmartThings) PrintSceneList

func (pST *SmartThings) PrintSceneList() bool

func (*SmartThings) RunScene

func (pST *SmartThings) RunScene(sSceneName string) bool

func (*SmartThings) SetToken

func (pST *SmartThings) SetToken(sToken string) bool

func (*SmartThings) ValidateDevice

func (pST *SmartThings) ValidateDevice(sDeviceName string) bool

func (*SmartThings) ValidateScene

func (pST *SmartThings) ValidateScene(sName string) bool

type StDeviceStatus

type StDeviceStatus struct {
	Switch struct {
		Timestamp time.Time `json:"timestamp"`
		Value     string    `json:"value"`
	} `json:"switch"`
}

type StDevices

type StDevices struct {
	Links struct{} `json:"_links"`
	Items []struct {
		Allowed      []interface{} `json:"allowed"`
		ChildDevices []struct {
			Allowed  interface{} `json:"allowed"`
			DeviceID string      `json:"deviceId"`
			Profile  struct{}    `json:"profile"`
		} `json:"childDevices,omitempty"`
		Components []struct {
			Capabilities []struct {
				ID      string  `json:"id"`
				Version float64 `json:"version"`
			} `json:"capabilities"`
			Categories []struct {
				CategoryType string `json:"categoryType"`
				Name         string `json:"name"`
			} `json:"categories"`
			ID    string `json:"id"`
			Label string `json:"label"`
		} `json:"components"`
		CreateTime             time.Time `json:"createTime"`
		DeviceID               string    `json:"deviceId"`
		DeviceManufacturerCode string    `json:"deviceManufacturerCode,omitempty"`
		DeviceNetworkType      string    `json:"deviceNetworkType,omitempty"`
		DeviceTypeID           string    `json:"deviceTypeId,omitempty"`
		DeviceTypeName         string    `json:"deviceTypeName,omitempty"`
		Dth                    *struct {
			CompletedSetup       bool   `json:"completedSetup"`
			DeviceNetworkType    string `json:"deviceNetworkType"`
			DeviceTypeID         string `json:"deviceTypeId"`
			DeviceTypeName       string `json:"deviceTypeName"`
			ExecutingLocally     bool   `json:"executingLocally"`
			HubID                string `json:"hubId,omitempty"`
			InstalledGroovyAppID string `json:"installedGroovyAppId,omitempty"`
			NetworkSecurityLevel string `json:"networkSecurityLevel"`
		} `json:"dth,omitempty"`
		Label            string `json:"label"`
		LocationID       string `json:"locationId"`
		ManufacturerName string `json:"manufacturerName"`
		Name             string `json:"name"`
		Ocf              *struct {
			FirmwareVersion           string    `json:"firmwareVersion"`
			HwVersion                 string    `json:"hwVersion"`
			LastSignupTime            time.Time `json:"lastSignupTime"`
			Locale                    string    `json:"locale"`
			ManufacturerName          string    `json:"manufacturerName"`
			ModelNumber               string    `json:"modelNumber"`
			Name                      string    `json:"name"`
			OcfDeviceType             string    `json:"ocfDeviceType"`
			PlatformOS                string    `json:"platformOS"`
			PlatformVersion           string    `json:"platformVersion"`
			SpecVersion               string    `json:"specVersion"`
			VendorID                  string    `json:"vendorId"`
			VerticalDomainSpecVersion string    `json:"verticalDomainSpecVersion"`
		} `json:"ocf,omitempty"`
		OwnerID        string `json:"ownerId,omitempty"`
		ParentDeviceID string `json:"parentDeviceId,omitempty"`
		PresentationID string `json:"presentationId"`
		Profile        *struct {
			ID string `json:"id"`
		} `json:"profile,omitempty"`
		RestrictionTier float64 `json:"restrictionTier"`
		RoomID          string  `json:"roomId,omitempty"`
		Type            string  `json:"type"`
		Viper           *struct {
			HwVersion        string `json:"hwVersion,omitempty"`
			ManufacturerName string `json:"manufacturerName"`
			ModelName        string `json:"modelName"`
			SwVersion        string `json:"swVersion,omitempty"`
			UniqueIdentifier string `json:"uniqueIdentifier,omitempty"`
		} `json:"viper,omitempty"`
		Zwave *struct {
			DriverID             string `json:"driverId"`
			ExecutingLocally     bool   `json:"executingLocally"`
			HubID                string `json:"hubId"`
			NetworkID            string `json:"networkId"`
			NetworkSecurityLevel string `json:"networkSecurityLevel"`
			ProvisioningState    string `json:"provisioningState"`
		} `json:"zwave,omitempty"`
	} `json:"items"`
}

type StScenes

type StScenes struct {
	Links struct {
		Next     interface{} `json:"next"`
		Previous interface{} `json:"previous"`
	} `json:"_links"`
	Items []struct {
		APIVersion       string      `json:"apiVersion"`
		CreatedBy        string      `json:"createdBy"`
		CreatedDate      float64     `json:"createdDate"`
		Editable         bool        `json:"editable"`
		LastExecutedDate float64     `json:"lastExecutedDate"`
		LastUpdatedDate  float64     `json:"lastUpdatedDate"`
		LocationID       string      `json:"locationId"`
		SceneColor       interface{} `json:"sceneColor"`
		SceneIcon        *string     `json:"sceneIcon"`
		SceneID          string      `json:"sceneId"`
		SceneName        string      `json:"sceneName"`
	} `json:"items"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL