Documentation ¶
Overview ¶
Package natureremo provides API Client of Nature Remo.
You can see overview of Nature Remo API on below URL. https://developer.nature.global/en/overview/
Index ¶
- Constants
- type APIError
- type AirCon
- type AirConRange
- type AirConRangeMode
- type AirConSettings
- type AirDirection
- type AirVolume
- type Appliance
- type ApplianceModel
- type ApplianceService
- type ApplianceType
- type Button
- type Client
- type DefaultButton
- type DetectedAirCon
- type Device
- type DeviceCore
- type DeviceService
- type IRSignal
- type Light
- type LightState
- type LocalClient
- type OperationMode
- type RateLimit
- type SensorType
- type SensorValue
- type Signal
- type SignalService
- type TV
- type TVInputType
- type TVState
- type TemperatureUnit
- type User
- type UserService
Constants ¶
const ( // AirVolumeAuto represents auto. AirVolumeAuto = "auto" // AirVolume1 represents volume 1. AirVolume1 = "1" // AirVolume2 represents volume 2. AirVolume2 = "2" // AirVolume3 represents volume 3. AirVolume3 = "3" // AirVolume4 represents volume 4. AirVolume4 = "4" // AirVolume5 represents volume 5. AirVolume5 = "5" // AirVolume6 represents volume 6. AirVolume6 = "6" // AirVolume7 represents volume 7. AirVolume7 = "7" // AirVolume8 represents volume 8. AirVolume8 = "8" // AirVolume9 represents volume 9. AirVolume9 = "9" // AirVolume10 represents volume 10. AirVolume10 = "10" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶ added in v0.2.0
type APIError struct { HTTPStatus int `json:"-"` Code int `json:"code"` Message string `json:"message"` }
APIError is an error from Nature Remo API.
type AirCon ¶
type AirCon struct { Range *AirConRange `json:"range"` TemperatureUnit TemperatureUnit `json:"tempUnit"` }
AirCon represents air conditioner.
type AirConRange ¶
type AirConRange struct { Modes map[OperationMode]*AirConRangeMode `json:"modes"` FixedButtons []Button `json:"fixedButtons"` }
AirConRange holds range of each setting and buttons of air conditioner.
type AirConRangeMode ¶
type AirConRangeMode struct { Temperature []string `json:"temp"` AirVolume []AirVolume `json:"vol"` AirDirection []AirDirection `json:"dir"` }
AirConRangeMode represetns ranges of settings of air conditioner.
type AirConSettings ¶
type AirConSettings struct { Temperature string `json:"temp"` OperationMode OperationMode `json:"mode"` AirVolume AirVolume `json:"vol"` AirDirection AirDirection `json:"dir"` Button Button `json:"button"` }
AirConSettings represents settings of air conditioner.
type AirDirection ¶
type AirDirection string
AirDirection represents direction of air.
const ( // AirDirectionAuto represents auto mode. AirDirectionAuto AirDirection = "" )
func (AirDirection) StringValue ¶
func (d AirDirection) StringValue() string
StringValue converts AirDirection to string.
type AirVolume ¶
type AirVolume string
AirVolume represents air volume of air conditioner.
func (AirVolume) StringValue ¶
StringValue converts AirVolume to string.
type Appliance ¶
type Appliance struct { ID string `json:"id"` Type ApplianceType `json:"type"` Device *DeviceCore `json:"device"` Model *ApplianceModel `json:"model"` Nickname string `json:"nickname"` Image string `json:"image"` Signals []*Signal `json:"signals"` AirConSettings *AirConSettings `json:"settings"` AirCon *AirCon `json:"aircon"` TV *TV `json:"tv"` Light *Light `json:"light"` }
Appliance represents controlable devices with Nature Remo such as air conditioners and TVs.
func (*Appliance) SignalByName ¶
SignalByName gets a signal by name from Signals. If there are not any signals which have specified name, SignalByName returns nil.
type ApplianceModel ¶
type ApplianceModel struct { ID string `json:"id"` // Not in swagger, but actually included in the response Country string `json:"country"` Manufacturer string `json:"manufacturer"` RemoteName string `json:"remote_name"` Name string `json:"name"` Image string `json:"image"` }
ApplianceModel is device information of appliance which is identified by Nature Remo API.
type ApplianceService ¶
type ApplianceService interface { // Detect detects air conditioners by an infrared ray signal. Detect(ctx context.Context, ir *IRSignal) ([]*DetectedAirCon, error) // GetAll gets all appliances. GetAll(ctx context.Context) ([]*Appliance, error) // New creates new appliance and links to specified device. New(ctx context.Context, device *Device, nickname, image string) (*Appliance, error) // NewWithModel creates new appliance with specified model. NewWithModel(ctx context.Context, device *Device, nickname, image string, model *ApplianceModel) (*Appliance, error) // ReOrder arranges appliances by given orders. ReOrder(ctx context.Context, appliances []*Appliance) error // Delete deletes specified appliance. Delete(ctx context.Context, appliance *Appliance) error // Update updates specified appliance. Update(ctx context.Context, appliance *Appliance) (*Appliance, error) // UpdateAirConSettings updates air conditioner settings of specified appliance. UpdateAirConSettings(ctx context.Context, appliance *Appliance, settings *AirConSettings) error // SendTVSignal sends TV infrared signal. SendTVSignal(ctx context.Context, appliance *Appliance, buttonName string) (*TVState, error) // SendLightSignal sends light infrared signal. SendLightSignal(ctx context.Context, appliance *Appliance, buttonName string) (*LightState, error) }
ApplianceService provides interface of Nature Remo APIs which are related to appliances.
type ApplianceType ¶
type ApplianceType string
ApplianceType represents type of appliance.
const ( // ApplianceTypeAirCon represents an air conditioner. ApplianceTypeAirCon ApplianceType = "AC" // ApplianceTypeTV represents an TV ApplianceTypeTV ApplianceType = "TV" // ApplianceTypeLight represents Light ApplianceTypeLight ApplianceType = "LIGHT" // ApplianceTypeIR represents a device which is controlled by infrared. ApplianceTypeIR ApplianceType = "IR" )
type Button ¶
type Button string
Button represents button of air conditioner such as power-off button and power-on button.
func (Button) StringValue ¶
StringValue converts Button to string.
type Client ¶
type Client struct { UserService UserService DeviceService DeviceService ApplianceService ApplianceService SignalService SignalService HTTPClient *http.Client AccessToken string BaseURL string UserAgent string LastRateLimit *RateLimit }
Client is an API client for Nature Remo Cloud API.
func NewClient ¶
NewClient creates new client with access token of Nature Remo API. You can get access token from https://home.nature.global/.
type DefaultButton ¶ added in v0.2.0
DefaultButton is defined by Nature.inc? or defined at IRDB?
type DetectedAirCon ¶
type DetectedAirCon struct { Model *ApplianceModel `json:"model"` Params *AirConSettings `json:"params"` }
DetectedAirCon represents information of an air conditioner which is detected by ApplianceService.Detected.
type Device ¶
type Device struct { DeviceCore // NewestEvents is newest sensor values such as temperature, humidity and illumination. NewestEvents map[SensorType]SensorValue `json:"newest_events"` }
Device represents a device such as Nature Remo and Nature Remo Mini.
type DeviceCore ¶
type DeviceCore struct { ID string `json:"id"` Name string `json:"name"` TemperatureOffset int64 `json:"temperature_offset"` HumidityOffset int64 `json:"humidity_offset"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` FirmwareVersion string `json:"firmware_version"` MacAddress string `json:"mac_address"` // Not in swagger, but actually included in the response BtMacAddress string `json:"bt_mac_address"` SerialNumber string `json:"serial_number"` // Not in swagger, but actually included in the response Users []User `json:"users"` }
DeviceCore represents core information of a device.
type DeviceService ¶
type DeviceService interface { // GetAll gets all information of devices which are related with user. GetAll(ctx context.Context) ([]*Device, error) // Update updates device information which exclude temperature offset and humidity offset. Update(ctx context.Context, device *Device) (*Device, error) // Delete deletes specified device. Delete(ctx context.Context, device *Device) error // UpdateTemperatureOffset updates temperature offset of specified device. UpdateTemperatureOffset(ctx context.Context, device *Device) (*Device, error) // UpdateHumidityOffset updates humidity offset of specified device. UpdateHumidityOffset(ctx context.Context, device *Device) (*Device, error) }
DeviceService provides interface of Nature Remo APIs which are related to devices.
type IRSignal ¶
type IRSignal struct { Freq int64 `json:"freq"` Data []int64 `json:"data"` Format string `json:"format"` }
IRSignal describes infrared ray signal.
type Light ¶ added in v0.2.0
type Light struct { State *LightState Buttons []DefaultButton }
type LightState ¶ added in v0.2.0
type LightState struct { Brightness string `json:"brightness"` Power string `json:"power"` LastButton string `json:"last_button"` }
LightState is Light state
type LocalClient ¶
func NewLocalClient ¶
func NewLocalClient(addr string) *LocalClient
type OperationMode ¶
type OperationMode string
OperationMode represents a operation mode of air conditioner such as warm and cool.
const ( // OperationModeAuto represents auto mode. OperationModeAuto OperationMode = "auto" // OperationModeCool represents cool mode. OperationModeCool OperationMode = "cool" // OperationModeWarm represents warm mode. OperationModeWarm OperationMode = "warm" // OperationModeDry represents dry mode. OperationModeDry OperationMode = "dry" // OperationModeBlow represents blow mode. OperationModeBlow OperationMode = "blow" )
func (OperationMode) StringValue ¶
func (om OperationMode) StringValue() string
StringValue converts OperationMode to string value.
type RateLimit ¶
type RateLimit struct { // Limit is a limit of request. Limit int64 // Remaining is remaining request count. Remaining int64 // Reset is time which a limit of request would be reseted. Reset time.Time }
RateLimit has values of X-Rate-Limit-* in the response header.
type SensorType ¶
type SensorType string
SensorType represents type of sensor.
const ( // SensorTypeTemperature represents a temperature sensor. SensorTypeTemperature SensorType = "te" // SensorTypeHumidity represents a humidity sensor. SensorTypeHumidity SensorType = "hu" // SensorTypeIllumination represents a illumination sensor. SensorTypeIllumination SensorType = "il" // SensorTypeMovement represents a movement sensor. SensorTypeMovement SensorType = "mo" )
type SensorValue ¶
SensorValue represents value of sensor.
type SignalService ¶
type SignalService interface { // GetAll gets all signals which related to specified appliance. GetAll(ctx context.Context, appliance *Appliance) ([]*Signal, error) // New creates new signal and links to specified appliance. New(ctx context.Context, appliance *Appliance, ir *IRSignal, name, image string) (*Signal, error) // ReOrder arranges signals by given orders. ReOrder(ctx context.Context, appliance *Appliance, signals []*Signal) error // Update updates specified signal. Update(ctx context.Context, signal *Signal) (*Signal, error) // Delete deletes specified signal. Delete(ctx context.Context, signal *Signal) error // Send sends specified signal. Send(ctx context.Context, signal *Signal) error }
SignalService provides interface of Nature Remo APIs which are related to signals.
type TV ¶ added in v0.2.0
type TV struct { State *TVState Buttons []DefaultButton }
type TVInputType ¶ added in v0.2.0
type TVInputType string
const ( TVInputTypeT TVInputType = "t" TVInputTypeBS TVInputType = "bs" TVInputTypeCS TVInputType = "cs" )
type TVState ¶ added in v0.2.0
type TVState struct {
Input TVInputType `json:"input"`
}
TVState is TV state
type TemperatureUnit ¶
type TemperatureUnit string
TemperatureUnit is unit of temperature.
const ( // TemperatureUnitAuto represents auto. TemperatureUnitAuto TemperatureUnit = "" // TemperatureUnitFahrenheit represents fahrenheit. TemperatureUnitFahrenheit TemperatureUnit = "f" // TemperatureUnitCelsius represents celsius. TemperatureUnitCelsius TemperatureUnit = "c" )