fhome

package module
v0.0.0-...-4fef847 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package fhome provides functionality to interact with smart home devices connected to F&Home system.

Index

Constants

View Source
const (
	ActionOpenClientSession          = "open_client_session"
	ActionGetMyData                  = "get_my_data"
	ActionGetMyResources             = "get_my_resources"
	ActionOpenClienToResourceSession = "open_client_to_resource_session"
	ActionTouches                    = "touches"
	ActionGetUserConfig              = "get_user_config"
	ActionXEvent                     = "xevent"
)

Variables

View Source
var (
	ValueToggle = "0x4001"
	Value0      = "0x6000"
	Value20     = "0x6014"
	Value40     = "0x6028"
	Value60     = "0x603C"
	Value80     = "0x6050"
	Value100    = "0x6064"
)

Functions

func MapToValue

func MapToValue(v int) string

Types

type Action

type Action struct {
	ActionName   string `json:"action_name"`
	Login        string `json:"login"`
	PasswordHash string `json:"password"`
	RequestToken string `json:"request_token"`
}

type Cell

type Cell struct {
	ObjectID        int               `json:"objectId"`
	Icon            string            `json:"icon"`
	Name            string            `json:"name"`
	PositionInPanel []PositionInPanel `json:"positionInPanel"`
}

type Client

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

func NewClient

func NewClient() (*Client, error)

NewClient creates a new client and automatically starts connecting to websockets.

func (*Client) Close

func (c *Client) Close() error

func (*Client) GetMyResources

func (c *Client) GetMyResources() (*GetMyResourcesResponse, error)

GetMyResources gets resources assigned to the user.

Most of the time, there will be just one resource. Currently we handle only this case and assign its unique ID on the client.

func (*Client) GetUserConfig

func (c *Client) GetUserConfig() (*File, error)

func (*Client) OpenClientSession

func (c *Client) OpenClientSession(email, password string) error

func (*Client) OpenClientToResourceSession

func (c *Client) OpenClientToResourceSession(resourcePassword string) error

OpenClientToResourceSession connects to the user's resource.

Currently, it assumes that a user has only one resource.

func (*Client) XEvent

func (c *Client) XEvent(resourceID int, value string) error

type File

type File struct {
	Cells  []Cell  `json:"cells"`
	Panels []Panel `json:"panels"`
	Server Server  `json:"server"`
}

type GetMyResources

type GetMyResources struct {
	ActionName   string `json:"action_name"`
	Email        string `json:"email"`
	RequestToken string `json:"request_token"`
}

type GetMyResourcesResponse

type GetMyResourcesResponse struct {
	ActionName    string `json:"action_name"`
	RequestToken  string `json:"request_token"`
	Status        string `json:"status"`
	Source        string `json:"source"`
	AvatarID0     string `json:"avatar_id_0"`
	FriendlyName0 string `json:"friendly_name_0"`
	ResourceType0 string `json:"resource_type_0"`
	UniqueID0     string `json:"unique_id_0"`
}

type MobileDisplayCell

type MobileDisplayCell struct {
	// Cell description
	Cd string `json:"CD"`
	// Object ID
	Oi string `json:"OI"`
	// Type number. Known values: 706, 707, 708, 709, 710, 711, 717, 718, 719,
	// 722, 724, 760
	Tn string `json:"TN"`
	// Preset. Known values: 0, 1, 4
	P string `json:"P"`
	// Style
	Se  string `json:"Se"`
	Min string `json:"Min"`
	Max string `json:"Max"`
	// Step (aka current value).
	Sp string `json:"Sp"`
	// Display Type. Known values: BIT, BYTE, TEMP (Temperature), PROC
	// (Percentage), RGB (Light)
	Dt string `json:"DT"`
	// Cell permission. Known values: FC (Full Control), RO (Read Only)
	Cp string `json:"CP"`
}

MobileDisplayCell is a Cell, but returned from "touches" action.

type OpenClientSession

type OpenClientSession struct {
	ActionName   string `json:"action_name"`
	Email        string `json:"email"`
	Password     string `json:"password"`
	RequestToken string `json:"request_token"`
}

type OpenClientToResourceSession

type OpenClientToResourceSession struct {
	ActionName   string `json:"action_name"`
	Email        string `json:"email"`
	UniqueID     string `json:"unique_id"`
	RequestToken string `json:"request_token"`
}

type Panel

type Panel struct {
	ID                   string      `json:"id"`
	Name                 string      `json:"name"`
	X                    int         `json:"x"`
	Y                    int         `json:"y"`
	Icon                 interface{} `json:"icon"`
	ColumnCountPortrait  int         `json:"columnCountPortrait"`
	ColumnCountLandscape int         `json:"columnCountLandscape"`
}

type PositionInPanel

type PositionInPanel struct {
	Orientation string `json:"orientation"`
	PanelID     string `json:"panelId"`
	X           int    `json:"x"`
	Y           int    `json:"y"`
}

func (PositionInPanel) String

func (p PositionInPanel) String() string

type Response

type Response struct {
	ActionName   string `json:"action_name"`
	RequestToken string `json:"request_token"`
	Status       string `json:"status"`
	Source       string `json:"source"`

	// Non-nil for "disconnecting" action
	Details string `json:"details"`
	Reason  string `json:"reason"`

	// Non-nil for ActionGetUserConfig
	File string `json:"file"`
}

type Server

type Server struct {
	ProjectVersion string `json:"projectVersion"`
}

type TouchesResponse

type TouchesResponse struct {
	ActionName string `json:"action_name"`
	Response   struct {
		ProjectVersion          string `json:"ProjectVersion"`
		Status                  bool   `json:"Status"`
		StatusText              string `json:"StatusText"`
		MobileDisplayProperties struct {
			Cells []MobileDisplayCell `json:"Cells"`
		} `json:"MobileDisplayProperties"`
	} `json:"response"`
	Status       string `json:"status"`
	Source       string `json:"source"`
	RequestToken string `json:"request_token"`
}

type XEvent

type XEvent struct {
	ActionName   string `json:"action_name"`
	Login        string `json:"login"`
	PasswordHash string `json:"password"`
	RequestToken string `json:"request_token"`
	CellID       string `json:"cell_id"`
	Value        string `json:"value"`
	Type         string `json:"type"`
}

Jump to

Keyboard shortcuts

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