Documentation ¶
Index ¶
- Constants
- func GetLocalIP() string
- type AbortDriverSetupData
- type AbortDriverSetupEvent
- type AuthRequestData
- type AuthRequestMessage
- type AuthenticationResponse
- type AvailableEntityData
- type AvailableEntityFilter
- type AvailableEntityMessage
- type AvailableEntityMessageData
- type AvailableEntityMessageReq
- type AvailableEntityNoFilterData
- type AvailableEntityNoFilterMessage
- type ButtonMapping
- type Client
- func (c *Client) ClientLoop()
- func (c *Client) Connect()
- func (c *Client) Disconnect()
- func (c *Client) FinishIntegrationSetup()
- func (c *Client) HandleConnection(e *ConnectEvent)
- func (c *Client) HandleSetDriverUserDataFunction(userdata map[string]string, confirm bool)
- func (c *Client) HandleSetup(setup_data SetupData)
- func (c *Client) InitClient()
- func (c *Client) IntegrationSetupFinished() bool
- func (c *Client) SetDeviceState(state DState)
- type Command
- type CommonEvent
- type CommonReq
- type CommonResp
- type Config
- type ConfirmationPage
- type ConnectEvent
- type ConnectEventData
- type DState
- type Developer
- type DeviceId
- type DeviceState
- type DeviceStateEventMessage
- type DeviceStateMessageReq
- type DriverMetadata
- type DriverMetadataReponse
- type DriverMetadataReq
- type DriverRegistration
- type DriverSetupChangeData
- type DriverSetupChangeEvent
- type DriverSetupError
- type DriverSetupEventType
- type DriverSetupState
- type DriverVersionData
- type DriverVersionReq
- type EntityAvailableEvent
- type EntityChangeData
- type EntityChangeEvent
- type EntityCommandData
- type EntityCommandReq
- type EntityCommandResponse
- type EntityRemovedEvent
- type EntityRemovedEventData
- type EventMessage
- type GetEntityStatesMessage
- type GetEntityStatesMessageData
- type GetEntityStatesMessageReq
- type Integration
- func (i *Integration) AddEntity(e interface{}) error
- func (i *Integration) GetEntitiesByType(entityType entities.EntityType) []interface{}
- func (i *Integration) GetEntityById(id string) (interface{}, int, error)
- func (i *Integration) LoadSetupData()
- func (i *Integration) PersistSetupData()
- func (i *Integration) RemoveEntity(entity interface{}) error
- func (i *Integration) RemoveEntityByID(entity_id string) error
- func (i *Integration) Run() error
- func (i *Integration) SendAuthenticationResponse()
- func (i *Integration) SendEntityChangeEvent(e interface{}, a *map[string]interface{})
- func (i *Integration) SetDeviceState(state DState)
- func (i *Integration) SetDriverSetupState(event_Type DriverSetupEventType, state DriverSetupState, err DriverSetupError, ...)
- func (i *Integration) SetHandleConnectionFunction(f func(*ConnectEvent))
- func (i *Integration) SetHandleSetDriverUserDataFunction(f func(map[string]string, bool))
- func (i *Integration) SetHandleSetupFunction(f func(SetupData))
- func (i *Integration) SetMetadata(metadata *DriverMetadata)
- func (i *Integration) UpdateEntity(entity interface{}, newEntity interface{}) error
- type LanguageText
- type RequestMessage
- type RequireUserAction
- type ResponseMessage
- type SetDriverUserData
- type SetDriverUserDataRequest
- type SettigsPage
- type Setting
- type SettingTypeCheckbox
- type SettingTypeCheckboxDefinition
- type SettingTypeDropdowDefinition
- type SettingTypeDropdowItemsDefinition
- type SettingTypeDropdown
- type SettingTypeLabel
- type SettingTypeLabelDefinition
- type SettingTypeNumber
- type SettingTypeNumberDefinition
- type SettingTypePassword
- type SettingTypePasswordDefinition
- type SettingTypeText
- type SettingTypeTextArea
- type SettingTypeTextAreaDefinition
- type SettingTypeTextDefinition
- type SetupData
- type SetupDataSchema
- type SetupDataSchemaSettings
- type SetupDataValue
- type SetupDriverMessageReq
- type SubscribeEventMessage
- type SubscribeEventMessageData
- type SubscribeEventMessageReq
- type Token
- type UnubscribeEventMessage
- type UnubscribeEventMessageData
- type UnubscribeEventMessageReq
- type UserInterface
- type UserInterfaceItem
- type UserInterfacePage
- type Version
Constants ¶
const API_VERSION = "0.10.0"
Variables ¶
This section is empty.
Functions ¶
func GetLocalIP ¶
func GetLocalIP() string
GetLocalIP returns the non loopback local IP of the host TODO: make this more robust, what if more ifaces are available
Types ¶
type AbortDriverSetupData ¶
type AbortDriverSetupData struct {
Error DriverSetupError `json:"error"`
}
type AbortDriverSetupEvent ¶
type AbortDriverSetupEvent struct { CommonEvent MsgData AbortDriverSetupData `json:"msg_data"` }
type AuthRequestData ¶
type AuthRequestData struct {
Token string `json:"token"`
}
type AuthRequestMessage ¶
type AuthRequestMessage struct { CommonReq MsgData AuthRequestData `json:"msg_data"` }
type AuthenticationResponse ¶
type AuthenticationResponse struct { CommonResp MsgData DriverVersionData `json:"msg_data"` }
type AvailableEntityData ¶
type AvailableEntityData struct { Filter AvailableEntityFilter `json:"filter,omitempty"` AvailableEntities []interface{} `json:"available_entities"` }
type AvailableEntityFilter ¶
type AvailableEntityFilter struct { DeviceId entities.EntityType }
type AvailableEntityMessage ¶
type AvailableEntityMessage struct { CommonResp MsgData AvailableEntityData `json:"msg_data"` }
type AvailableEntityMessageData ¶
type AvailableEntityMessageData struct {
Filter AvailableEntityFilter `json:"filter,omitempty"`
}
type AvailableEntityMessageReq ¶
type AvailableEntityMessageReq struct { CommonReq MsgData AvailableEntityMessageData `json:"msg_data,omitempty"` }
type AvailableEntityNoFilterData ¶
type AvailableEntityNoFilterData struct {
AvailableEntities []interface{} `json:"available_entities"`
}
type AvailableEntityNoFilterMessage ¶
type AvailableEntityNoFilterMessage struct { CommonResp MsgData AvailableEntityNoFilterData `json:"msg_data"` }
type ButtonMapping ¶ added in v0.3.4
type Client ¶ added in v0.2.0
type Client struct { IntegrationDriver *Integration DeviceState DState Messages chan string // Client specific functions // Initialize the client // Here you can add entities if they are already known InitFunc func() // Called by RemoteTwo when the integration is added and setup started SetupFunc func(SetupData) // Handles connect/disconnect calls from RemoteTwo ClientLoopFunc func() SetDriverUserDataFunc func(map[string]string, bool) }
Generic client
func NewClient ¶ added in v0.2.0
func NewClient(i *Integration) *Client
func (*Client) ClientLoop ¶ added in v0.2.0
func (c *Client) ClientLoop()
func (*Client) Disconnect ¶ added in v0.2.0
func (c *Client) Disconnect()
func (*Client) FinishIntegrationSetup ¶ added in v0.3.1
func (c *Client) FinishIntegrationSetup()
func (*Client) HandleConnection ¶ added in v0.2.0
func (c *Client) HandleConnection(e *ConnectEvent)
func (*Client) HandleSetDriverUserDataFunction ¶ added in v0.2.0
User input result of a SettingsPage as key values. key: id of the field value: entered user value as string. This is either the entered text or number, selected checkbox state or the selected dropdown item id. ⚠️ Non native string values as numbers or booleans are represented as string values!
func (*Client) HandleSetup ¶ added in v0.2.0
Handle Setup called by Remote Two to setup this integration the SetupData are passed to this function
func (*Client) InitClient ¶ added in v0.2.0
func (c *Client) InitClient()
func (*Client) IntegrationSetupFinished ¶ added in v0.3.1
func (*Client) SetDeviceState ¶ added in v0.2.0
type CommonEvent ¶
type CommonResp ¶
type Config ¶
type Config struct { ListenPort int `mapstructure:"listenPort"` DisableMDNS bool `mapstructure:"disableMDNS"` EnableRegistration bool `mapstructure:"enableRegistration"` RegistrationUsername string `mapstructure:"registrationUsername"` RegistrationPin string `mapstructure:"registrationPin"` WebsocketPath string `mapstructure:"websocketPath"` ConfigHome string `mapstructure:"ucconfighome"` RemoteTwoHost string `mapstructure:"remoteTwoIP"` RemoteTwoPort int `mapstructure:"remoteTwoPort"` IgnoreEntitySubscription bool }
Generic string key/value config map to store configuration option
type ConfirmationPage ¶
type ConfirmationPage struct { Title LanguageText `json:"title"` Message1 interface{} `json:"message1,omitempty"` Image string `json:"image,omitempty"` Message2 interface{} `json:"message2,omitempty"` }
type ConnectEvent ¶
type ConnectEvent struct { CommonEvent MsgData ConnectEventData `json:"msg_data,omitempty"` }
type ConnectEventData ¶
type ConnectEventData struct {
DeviceId string `json:"device_id,omitempty"`
}
type DeviceState ¶
type DeviceStateEventMessage ¶
type DeviceStateEventMessage struct { CommonEvent MsgData DeviceState `json:"msg_data"` }
type DeviceStateMessageReq ¶
type DriverMetadata ¶
type DriverMetadata struct { DriverId string `json:"driver_id"` Name LanguageText `json:"name"` DriverUrl string `json:"driver_url,omitempty"` AuthMethod string `json:"auth_method,omitempty"` Version string `json:"version"` MinCoreAPI string `json:"min_core_api,omitempty"` Icon string `json:"icon,omitempty"` Description LanguageText `json:"description"` Developer Developer `json:"developer,omitempty"` HomePage string `json:"home_page,omitempty"` DeviceDiscovery bool `json:"device_discovery,omitempty"` SetupDataSchema SetupDataSchema `json:"setup_data_schema,omitempty"` ReleaseData string `json:"release_date,omitempty"` }
type DriverMetadataReponse ¶
type DriverMetadataReponse struct { CommonResp MsgData DriverMetadata `json:"msg_data"` }
type DriverMetadataReq ¶
type DriverMetadataReq struct {
CommonReq
}
type DriverRegistration ¶
type DriverRegistration struct { DriverId string `json:"driver_id,omitempty"` Name LanguageText `json:"name"` DriverURL string `json:"driver_url"` Version string `json:"version"` Icon string `json:"icon"` Enabled bool `json:"enabled"` Description LanguageText `json:"description"` DeviceDiscovery bool `json:"device_discovery"` SetupDataSchema SetupDataSchema `json:"setup_data_schema"` ReleaseDate string `json:"release_date,omitempty"` }
type DriverSetupChangeData ¶
type DriverSetupChangeData struct { EventType DriverSetupEventType `json:"event_type"` State DriverSetupState `json:"state"` Error DriverSetupError `json:"error,omitempty"` RequireUserAction interface{} `json:"require_user_action,omitempty"` }
type DriverSetupChangeEvent ¶
type DriverSetupChangeEvent struct { CommonEvent MsgData DriverSetupChangeData `json:"msg_data,omitempty"` }
type DriverSetupError ¶
type DriverSetupError string
const ( NoneError DriverSetupError = "NONE" NotFoundError DriverSetupError = "NOT_FOUND" ConnectionRefusedError DriverSetupError = "CONNECTION_REFUSED" AuthErrorError DriverSetupError = "AUTHORIZATION_ERROR" TimeoutError DriverSetupError = "TIMEOUT" OtherError DriverSetupError = "OTHER" )
type DriverSetupEventType ¶
type DriverSetupEventType string
const ( StartEvent DriverSetupEventType = "START" SetupEvent DriverSetupEventType = "SETUP" StopEvent DriverSetupEventType = "STOP" )
type DriverSetupState ¶
type DriverSetupState string
const ( SetupState DriverSetupState = "SETUP" WaitUserActionState DriverSetupState = "WAIT_USER_ACTION" OkState DriverSetupState = "OK" ErrorState DriverSetupState = "ERROR" )
type DriverVersionData ¶
type DriverVersionReq ¶
type DriverVersionReq struct {
CommonReq
}
type EntityAvailableEvent ¶
type EntityAvailableEvent struct { CommonEvent MsgData interface{} `json:"msg_data"` }
type EntityChangeData ¶
type EntityChangeEvent ¶
type EntityChangeEvent struct { CommonEvent MsgData EntityChangeData `json:"msg_data"` }
type EntityCommandData ¶
type EntityCommandReq ¶
type EntityCommandReq struct { CommonReq MsgData EntityCommandData `json:"msg_data,omitempty"` }
type EntityCommandResponse ¶
type EntityCommandResponse struct {
CommonResp
}
type EntityRemovedEvent ¶
type EntityRemovedEvent struct { CommonEvent MsgData EntityRemovedEventData `json:"msg_data"` }
type EntityRemovedEventData ¶
type EventMessage ¶
type EventMessage struct { CommonEvent MsgData interface{} `json:"msg_data"` }
type GetEntityStatesMessage ¶
type GetEntityStatesMessage struct { CommonResp MsgData []entities.EntityStateData `json:"msg_data,omitempty"` }
type GetEntityStatesMessageData ¶
type GetEntityStatesMessageData struct {
DeviceId string `json:"device_id"`
}
type GetEntityStatesMessageReq ¶
type GetEntityStatesMessageReq struct { CommonReq MsgData GetEntityStatesMessageData `json:"msg_data,omitempty"` }
type Integration ¶
type Integration struct { DeviceId string DriverId string Metadata *DriverMetadata Config Config Remote remote Entities []interface{} SubscribedEntities []string SetupState DriverSetupState SetupData SetupData // contains filtered or unexported fields }
func NewIntegration ¶
func NewIntegration(config Config) (*Integration, error)
func (*Integration) AddEntity ¶
func (i *Integration) AddEntity(e interface{}) error
Add a new Entity to the list of Entities (if not already added) Also make sure the EntityChange Function is set so Entity Change Events are emitted when a Entity Attribute changes Send Entity Available Event to RT
func (*Integration) GetEntitiesByType ¶
func (i *Integration) GetEntitiesByType(entityType entities.EntityType) []interface{}
Return all available entities of a given type
func (*Integration) GetEntityById ¶
func (i *Integration) GetEntityById(id string) (interface{}, int, error)
Return an Entity by its Name Also return the current index in the Entities Array (TODO: do we need this?) Error when Entity not found
func (*Integration) LoadSetupData ¶
func (i *Integration) LoadSetupData()
Load persist setupData File TODO: handle location via ENV's
func (*Integration) PersistSetupData ¶
func (i *Integration) PersistSetupData()
Persist File TODO: handle location via ENV's
func (*Integration) RemoveEntity ¶
func (i *Integration) RemoveEntity(entity interface{}) error
Remove an Entity from the Integration Send Entity Removed Event to RT
func (*Integration) RemoveEntityByID ¶
func (i *Integration) RemoveEntityByID(entity_id string) error
Remove an Entity from the Integration Send Entity Removed Event to RT
func (*Integration) Run ¶
func (i *Integration) Run() error
func (*Integration) SendAuthenticationResponse ¶
func (i *Integration) SendAuthenticationResponse()
Send a AuthenticationResponse Message
func (*Integration) SendEntityChangeEvent ¶
func (i *Integration) SendEntityChangeEvent(e interface{}, a *map[string]interface{})
Emitted when an attribute of an entity changes, e.g. is switched off. Either after an entity_command or if the entity is updated manually through a user or an external system. This keeps the Remote Two in sync with the real state of the entity without the need of constant polling.
func (*Integration) SetDeviceState ¶
func (i *Integration) SetDeviceState(state DState)
func (*Integration) SetDriverSetupState ¶
func (i *Integration) SetDriverSetupState(event_Type DriverSetupEventType, state DriverSetupState, err DriverSetupError, requireUserAction *RequireUserAction)
Set and then Send the Driver Setup State to Remote two
func (*Integration) SetHandleConnectionFunction ¶
func (i *Integration) SetHandleConnectionFunction(f func(*ConnectEvent))
Set the function which is called when the connect/disconnect request was sent by the remote
func (*Integration) SetHandleSetDriverUserDataFunction ¶
func (i *Integration) SetHandleSetDriverUserDataFunction(f func(map[string]string, bool))
Set the function which is called when the setDriverUsaerData request was sent by the remote
func (*Integration) SetHandleSetupFunction ¶
func (i *Integration) SetHandleSetupFunction(f func(SetupData))
Set the function which is called when the setup_driver request was sent by the remote
func (*Integration) SetMetadata ¶
func (i *Integration) SetMetadata(metadata *DriverMetadata)
func (*Integration) UpdateEntity ¶
func (i *Integration) UpdateEntity(entity interface{}, newEntity interface{}) error
Update an existing entity with a new entity
type LanguageText ¶
type RequestMessage ¶
type RequestMessage struct { CommonReq MsgData interface{} `json:"msg_data,omitempty"` }
Requests
type RequireUserAction ¶
type RequireUserAction struct { Input interface{} `json:"input,omitempty"` Confirmation interface{} `json:"confirmation,omitempty"` }
type ResponseMessage ¶
type ResponseMessage struct { CommonResp MsgData interface{} `json:"msg_data,omitempty"` }
type SetDriverUserData ¶
type SetDriverUserDataRequest ¶
type SetDriverUserDataRequest struct { CommonReq MsgData SetDriverUserData `json:"msg_data"` }
Set required data to configure the integration driver or continue the setup process.
type SettigsPage ¶
type SettigsPage struct { Title LanguageText `json:"title"` Settings []Setting `json:"settings"` }
type Setting ¶
type Setting struct { Id string `json:"id"` Label LanguageText `json:"label"` Field interface{} `json:"field"` }
type SettingTypeCheckbox ¶
type SettingTypeCheckbox struct {
Checkbox SettingTypeCheckboxDefinition `json:"checkbox"`
}
type SettingTypeCheckboxDefinition ¶
type SettingTypeCheckboxDefinition struct {
Value bool `json:"value"`
}
type SettingTypeDropdowDefinition ¶
type SettingTypeDropdowDefinition struct { Value string `json:"value"` Items []SettingTypeDropdowItemsDefinition `json:"items"` }
type SettingTypeDropdowItemsDefinition ¶
type SettingTypeDropdowItemsDefinition struct { Id string `json:"id"` Label LanguageText `json:"label"` }
type SettingTypeDropdown ¶
type SettingTypeDropdown struct {
Dropdown SettingTypeDropdowDefinition `json:"dropdown"`
}
type SettingTypeLabel ¶
type SettingTypeLabel struct {
Label SettingTypeLabelDefinition `json:"label"`
}
type SettingTypeLabelDefinition ¶
type SettingTypeLabelDefinition struct {
Value LanguageText `json:"value"`
}
type SettingTypeNumber ¶
type SettingTypeNumber struct {
Number SettingTypeNumberDefinition `json:"number"`
}
type SettingTypePassword ¶
type SettingTypePassword struct {
Password SettingTypePasswordDefinition `json:"password"`
}
type SettingTypeText ¶
type SettingTypeText struct {
Text SettingTypeTextDefinition `json:"text"`
}
type SettingTypeTextArea ¶
type SettingTypeTextArea struct {
TextArea SettingTypeTextAreaDefinition `json:"textarea"`
}
type SettingTypeTextAreaDefinition ¶
type SettingTypeTextAreaDefinition struct {
Value string `json:"value"`
}
type SetupDataSchema ¶
type SetupDataSchema struct { Title LanguageText `json:"title"` Settings []SetupDataSchemaSettings `json:"settings"` }
type SetupDataSchemaSettings ¶
type SetupDataSchemaSettings struct { Id string `json:"id"` Label LanguageText `json:"label"` Field interface{} `json:"field"` }
type SetupDataValue ¶
type SetupDriverMessageReq ¶
type SetupDriverMessageReq struct { CommonReq MsgData SetupDataValue `json:"msg_data"` }
type SubscribeEventMessage ¶
type SubscribeEventMessage struct {
CommonResp
}
type SubscribeEventMessageReq ¶
type SubscribeEventMessageReq struct { CommonReq MsgData SubscribeEventMessageData `json:"msg_data,omitempty"` }
type UnubscribeEventMessage ¶
type UnubscribeEventMessage struct {
CommonResp
}
type UnubscribeEventMessageReq ¶
type UnubscribeEventMessageReq struct { CommonReq MsgData SubscribeEventMessageData `json:"msg_data,omitempty"` }
type UserInterface ¶ added in v0.3.4
type UserInterface struct {
Pages []UserInterfacePage `json:"pages"`
}
type UserInterfaceItem ¶ added in v0.3.4
type UserInterfacePage ¶ added in v0.3.4
type UserInterfacePage struct { PageID string `json:"page_id"` Name string `json:"name,omitempty"` Grid struct { Width int `json:"width"` Height int `json:"height"` } `json:"grid"` Items []UserInterfaceItem `json:"items"` }