Documentation ¶
Overview ¶
Package hmlib is a library for interfacing with the HomeMatic XML API
Index ¶
- Constants
- Variables
- func GetChannelOfDatapoint(id string) (channelID string, err error)
- func GetDeviceOfChannel(id string) (deviceID string, err error)
- func GetHTTPClient() *resty.Client
- func GetHmToken() string
- func GetHmURL() string
- func GetSysvarList(text bool) (err error)
- func QueryAPI(endpoint string, result interface{}, parameter map[string]string) (err error)
- func SetDebug(debugFlag bool)
- func SetHTTPClient(c *resty.Client)
- func SetHmToken(token string)
- func SetHmURL(url string)
- type ChangeResult
- type Datapoint
- type DeviceChannel
- type DeviceListEntry
- type DeviceListResponse
- type DeviceTypeEntry
- type DeviceTypeForm
- type DeviceTypeListResponse
- type IDMapEntry
- type MasterValueDevice
- type MasterValueEntry
- type MasterValues
- type Notification
- type NotificationDetail
- type Room
- type RoomChannel
- type RoomListResponse
- type RssiDevice
- type RssiListResponse
- type StateChangeResponse
- type StateChannel
- type StateDatapointResponse
- type StateDevice
- type StateDeviceResponse
- type StateListResponse
- type SysVarEntry
- type SystemNotificationResponse
- type SysvarListResponse
Constants ¶
const DeviceListEndpoint = "/addons/xmlapi/devicelist.cgi"
DeviceListEndpoint is the endpoint for the device list
const DeviceTypeListEndpoint = "/addons/xmlapi/devicetypelist.cgi"
DeviceTypeListEndpoint is the endpoint for the device type list
const MasterValueChangeEndpoint = "/addons/xmlapi/mastervaluechange.cgi"
MasterValueChangeEndpoint is the endpoint for changing master value for a device
const MasterValueEndpoint = "/addons/xmlapi/mastervalue.cgi"
MasterValueEndpoint is the endpoint for retrieving master value for a device
const NotificationsEndpoint = "/config/xmlapi/systemNotification.cgi"
NotificationsEndpoint is the endpoint for the notification list
const RoomListEndpoint = "/addons/xmlapi/roomlist.cgi"
RoomListEndpoint is the endpoint for the device list
const RssiEndpoint = "/addons/xmlapi/rssilist.cgi"
RssiEndpoint is the endpoint for the device list
const StateChangeEndpoint = "/addons/xmlapi/statechange.cgi"
StateChangeEndpoint is the endpoint to change a state value
const StateEndpoint = "/addons/xmlapi/state.cgi"
StateEndpoint is the endpoint to retrieve the state for a given list of devices
const StateListEndpoint = "/addons/xmlapi/statelist.cgi"
StateListEndpoint is the endpoint to retrieve the state for all devices
const SysVarEndpoint = "/addons/xmlapi/sysvar.cgi"
SysVarEndpoint is the endpoint for a given system variable
const SysVarListEndpoint = "/addons/xmlapi/sysvarlist.cgi"
SysVarListEndpoint is the endpoint for the system variables list
Variables ¶
var AllIDs = map[string]IDMapEntry{}
AllIDs is a map of all iseIDs to IDMapEntry
var DeviceAddressMap = map[string]DeviceListEntry{}
DeviceAddressMap is a list of devices by name
var DeviceIDMap = map[string]DeviceListEntry{}
DeviceIDMap is a list of devices by id
var DeviceTypes = map[string]DeviceTypeEntry{}
DeviceTypes is a list of device types per name
var NameIDMap = map[string]string{}
NameIDMap is a map of all names to iseIDs
var RoomMap = make(map[string]Room)
RoomMap is a list of rooms by name
var RssiDeviceMap = make(map[string]RssiDevice)
RssiDeviceMap is a list of rssi devices by name
var StateList = StateListResponse{}
StateList is the result of a statelist.cgi call
var SysVarIDMap = map[string]SysVarEntry{}
SysVarIDMap is a map of system variables by ID
Functions ¶
func GetChannelOfDatapoint ¶ added in v1.11.1
GetChannelOfDatapoint returns the channel id of the given datapoint
func GetDeviceOfChannel ¶ added in v1.11.1
GetDeviceOfChannel returns the device id of the given channel
func GetHTTPClient ¶
func GetHTTPClient() *resty.Client
GetHTTPClient returns the http client for the next QueryAPI call
func GetSysvarList ¶
GetSysvarList returns the list of system variables
func SetDebug ¶ added in v1.14.1
func SetDebug(debugFlag bool)
SetDebug sets the Logging Level and activates RESTY Debug
func SetHTTPClient ¶
func SetHTTPClient(c *resty.Client)
SetHTTPClient sets the http client for the next QueryAPI call
func SetHmToken ¶
func SetHmToken(token string)
SetHmToken sets the token for the next QueryAPI call
Types ¶
type ChangeResult ¶
type ChangeResult struct { XMLName xml.Name `xml:"changed"` IseID string `xml:"id,attr"` NewValue string `xml:"new_value,attr"` Success bool `xml:"success,attr"` }
ChangeResult is the result of a single change
func (ChangeResult) String ¶
func (e ChangeResult) String() string
String returns a string representation of a ChangeResult
type Datapoint ¶
type Datapoint struct { XMLName xml.Name `xml:"datapoint"` Name string `xml:"name,attr"` IseID string `xml:"ise_id,attr"` Value string `xml:"value,attr"` ValueType string `xml:"valuetype,attr"` ValueUnit string `xml:"valueunit,attr"` Timestamp string `xml:"timestamp,attr"` LastTimestamp string `xml:"lasttimestamp,attr"` ChannelID string }
Datapoint returns the state of a single datapoint
type DeviceChannel ¶
type DeviceChannel struct { XMLName xml.Name `xml:"channel"` Name string `xml:"name,attr"` Type string `xml:"type,attr"` Address string `xml:"address,attr"` IseID string `xml:"ise_id,attr"` ParentDevice string `xml:"parent_device,attr"` Index string `xml:"index,attr"` Direction string `xml:"direction,attr"` GroupPartner string `xml:"group_partner,attr"` AesAvailable string `xml:"aes_available,attr"` TransmissionMode string `xml:"transmission_mode,attr"` Visible string `xml:"visible,attr"` ReadyConfig string `xml:"ready_config,attr"` Operate string `xml:"operate,attr"` }
DeviceChannel is a single channel of a device
func (DeviceChannel) String ¶
func (e DeviceChannel) String() string
String returns a string representation of a channel
type DeviceListEntry ¶
type DeviceListEntry struct { XMLName xml.Name `xml:"device"` Name string `xml:"name,attr"` Type string `xml:"device_type,attr"` Address string `xml:"address,attr"` Interface string `xml:"interface,attr"` IseID string `xml:"ise_id,attr"` ReadyConfig string `xml:"ready_config,attr"` Channels []DeviceChannel `xml:"channel"` }
DeviceListEntry is a single device
func (DeviceListEntry) String ¶
func (e DeviceListEntry) String() string
String returns a string representation of a device
type DeviceListResponse ¶
type DeviceListResponse struct { XMLName xml.Name `xml:"deviceList"` DeviceListEntries []DeviceListEntry `xml:"device"` }
DeviceListResponse is a list of devices returned by API
func GetDeviceList ¶
func GetDeviceList(deviceIDs string, internal bool) (result DeviceListResponse, err error)
GetDeviceList returns the list of devices
func (DeviceListResponse) String ¶
func (e DeviceListResponse) String() string
String returns a string representation of a device list
type DeviceTypeEntry ¶
type DeviceTypeEntry struct { XMLName xml.Name `xml:"deviceType"` Name string `xml:"name,attr"` Description string `xml:"description,attr"` ThumbnailPath string `xml:"thumbnailPath,attr"` ImagePath string `xml:"imagePath,attr"` Forms []DeviceTypeForm `xml:"form"` }
DeviceTypeEntry is a single device type
func (DeviceTypeEntry) String ¶
func (e DeviceTypeEntry) String() string
String returns a string representation of a device type
type DeviceTypeForm ¶
type DeviceTypeForm struct { XMLName xml.Name `xml:"form"` Name string `xml:"name,attr"` Type string `xml:"type,attr"` }
DeviceTypeForm is a single form of a device type
func (DeviceTypeForm) String ¶
func (e DeviceTypeForm) String() string
String returns a string representation of a device type form
type DeviceTypeListResponse ¶
type DeviceTypeListResponse struct { XMLName xml.Name `xml:"deviceTypeList"` DeviceTypeListEntries []DeviceTypeEntry `xml:"deviceType"` }
DeviceTypeListResponse is a list of device types returned by API
func GetDeviceTypeList ¶
func GetDeviceTypeList() (result DeviceTypeListResponse, err error)
GetDeviceTypeList returns the list of device types
func (DeviceTypeListResponse) String ¶
func (e DeviceTypeListResponse) String() string
String returns a string representation of a device type list
type IDMapEntry ¶
IDMapEntry contains the objects for any ID
type MasterValueDevice ¶
type MasterValueDevice struct { XMLName xml.Name `xml:"device"` Name string `xml:"name,attr"` IseID string `xml:"ise_id,attr"` DeviceType string `xml:"device_type,attr"` MasterValue []MasterValueEntry `xml:"mastervalue"` Error string `xml:"error"` Content string `xml:",chardata"` }
MasterValueDevice is a single device with its master values
func (MasterValueDevice) String ¶
func (e MasterValueDevice) String() string
String returns a string representation of a MasterValueDevice
type MasterValueEntry ¶
type MasterValueEntry struct { XMLName xml.Name `xml:"mastervalue"` Name string `xml:"name,attr"` Value string `xml:"value,attr"` }
MasterValueEntry is a single entry of a master value
func (MasterValueEntry) String ¶
func (e MasterValueEntry) String() string
String returns a string representation of a MasterValueEntry
type MasterValues ¶
type MasterValues struct { XMLName xml.Name `xml:"mastervalue"` MasterValueDevices []MasterValueDevice `xml:"device"` }
MasterValues is a list of devices with their master values
func ChangeMasterValues ¶
func ChangeMasterValues(deviceIDs string, names string, values string) (result MasterValues, err error)
ChangeMasterValues changes the master values of the given devices
func GetMasterValues ¶
func GetMasterValues(deviceIDs string, requestedNames string) (result MasterValues, err error)
GetMasterValues returns the master values of the given devices
func (MasterValues) String ¶
func (e MasterValues) String() string
String returns a string representation of a MasterValues
type Notification ¶
type Notification struct { XMLName xml.Name `xml:"notification"` Name string `xml:"name,attr"` Type string `xml:"type,attr"` Timestamp string `xml:"timestamp,attr"` IseID string `xml:"ise_id,attr"` }
Notification is a single notification
func (Notification) String ¶
func (e Notification) String() string
String returns a string representation of the notification
type NotificationDetail ¶
type NotificationDetail struct { System string Address string Type string Since time.Time Name string }
NotificationDetail is a aggregated single notification
type Room ¶
type Room struct { XMLName xml.Name `xml:"room"` Name string `xml:"name,attr"` IseID string `xml:"ise_id,attr"` Channels []RoomChannel `xml:"channel"` }
Room is a single room in RoomListResponse
type RoomChannel ¶
RoomChannel is a single channel in Room
type RoomListResponse ¶
RoomListResponse is a list of devices returned by API
func GetRoomList ¶
func GetRoomList() (result RoomListResponse, err error)
GetRoomList returns the list of rooms
func (RoomListResponse) String ¶
func (e RoomListResponse) String() string
String returns a string representation of the device list
type RssiDevice ¶
type RssiDevice struct { XMLName xml.Name `xml:"rssi"` Device string `xml:"device,attr"` Rx string `xml:"rx,attr"` Tx string `xml:"tx,attr"` }
RssiDevice returns Rssi values for a single device
func (RssiDevice) String ¶
func (e RssiDevice) String() string
String returns a string representation of the device list
type RssiListResponse ¶
type RssiListResponse struct { XMLName xml.Name `xml:"rssiList"` RssiDevices []RssiDevice `xml:"rssi"` }
RssiListResponse is a list of devices returned by API
func GetRssiList ¶
func GetRssiList() (result RssiListResponse, err error)
GetRssiList returns the rssi list of hm devices
func (RssiListResponse) String ¶
func (e RssiListResponse) String() string
String returns a string representation of the device list
type StateChangeResponse ¶
type StateChangeResponse struct { XMLName xml.Name `xml:"result"` NotFound []bool `xml:"not_found"` Changes []ChangeResult `xml:"changed"` }
StateChangeResponse is the result of a statechange.cgi call
func ChangeState ¶
func ChangeState(ids string, values string) (result StateChangeResponse, err error)
ChangeState changes the state of the given id
func (StateChangeResponse) String ¶
func (e StateChangeResponse) String() string
type StateChannel ¶
type StateChannel struct { XMLName xml.Name `xml:"channel"` Name string `xml:"name,attr"` IseID string `xml:"ise_id,attr"` LastDPActionTime string `xml:"lastdpactiontime,attr"` Datapoints []Datapoint `xml:"datapoint"` DeviceID string }
StateChannel returns the state of a single channel
func (StateChannel) String ¶
func (e StateChannel) String() string
String returns a string representation of a StateChannel
type StateDatapointResponse ¶
type StateDatapointResponse struct { XMLName xml.Name `xml:"state"` StateDatapoints []Datapoint `xml:"datapoint"` }
StateDatapointResponse is a list of datapoints returned by API
func GetStateByDataPointID ¶
func GetStateByDataPointID(ids string) (result StateDatapointResponse, err error)
GetStateByDataPointID returns the state of the given datapoints
func (StateDatapointResponse) String ¶
func (e StateDatapointResponse) String() string
String returns a string representation of a StateDatapointResponse
type StateDevice ¶
type StateDevice struct { XMLName xml.Name `xml:"device"` Name string `xml:"name,attr"` IseID string `xml:"ise_id,attr"` Unreach string `xml:"unreach,attr"` ConfigPending string `xml:"config_pending,attr"` Channels []StateChannel `xml:"channel"` }
StateDevice returns the state of a single device
func (StateDevice) String ¶
func (e StateDevice) String() string
String returns a string representation of a StateListResponse
type StateDeviceResponse ¶
type StateDeviceResponse struct { XMLName xml.Name `xml:"state"` StateDevices []StateDevice `xml:"device"` }
StateDeviceResponse is a list of devices returned by API
func GetStateByChannelID ¶
func GetStateByChannelID(ids string) (result StateDeviceResponse, err error)
GetStateByChannelID returns the state of the given channels
func GetStateByDeviceID ¶
func GetStateByDeviceID(ids string) (result StateDeviceResponse, err error)
GetStateByDeviceID returns the state of the given devices
func (StateDeviceResponse) String ¶
func (e StateDeviceResponse) String() string
String returns a string representation of a StateDeviceResponse
type StateListResponse ¶
type StateListResponse struct { XMLName xml.Name `xml:"stateList"` StateDevices []StateDevice `xml:"device"` }
StateListResponse is a list of devices returned by API
func GetStateList ¶
func GetStateList() (stateList StateListResponse, err error)
GetStateList returns the state of all devices
type SysVarEntry ¶
type SysVarEntry struct { XMLName xml.Name `xml:"systemVariable"` Name string `xml:"name,attr"` Variable string `xml:"variable,attr"` Value string `xml:"value,attr"` ValueList string `xml:"value_list,attr"` ValueText string `xml:"value_text,attr"` IseID string `xml:"ise_id,attr"` Min string `xml:"min,attr"` Max string `xml:"max,attr"` Unit string `xml:"unit,attr"` Type string `xml:"type,attr"` Subtype string `xml:"subtype,attr"` Timestamp string `xml:"timestamp,attr"` ValueName0 string `xml:"value_name_0,attr"` ValueName1 string `xml:"value_name_1,attr"` Info string `xml:"info,attr"` }
SysVarEntry is a single system variable in SysvarListResponse
func (SysVarEntry) GetValue ¶ added in v1.11.4
func (e SysVarEntry) GetValue() string
GetValue returns the value of the system variable depending on the type
func (SysVarEntry) String ¶
func (e SysVarEntry) String() string
String returns a string representation of the system variable list
type SystemNotificationResponse ¶
type SystemNotificationResponse struct { XMLName xml.Name `xml:"systemNotification"` Notifications []Notification `xml:"notification"` }
SystemNotificationResponse is a list of notifications returned by API
func GetNotifications ¶
func GetNotifications() (result SystemNotificationResponse, err error)
GetNotifications returns the list of notifications
type SysvarListResponse ¶
type SysvarListResponse struct { XMLName xml.Name `xml:"systemVariables"` SysvarEntry []SysVarEntry `xml:"systemVariable"` }
SysvarListResponse is a list of system variables returned by API