hmlib

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: GPL-3.0 Imports: 10 Imported by: 1

Documentation

Overview

Package hmlib is a library for interfacing with the HomeMatic XML API

Index

Constants

View Source
const DeviceListEndpoint = "/addons/xmlapi/devicelist.cgi"

DeviceListEndpoint is the endpoint for the device list

View Source
const DeviceTypeListEndpoint = "/addons/xmlapi/devicetypelist.cgi"

DeviceTypeListEndpoint is the endpoint for the device type list

View Source
const MasterValueChangeEndpoint = "/addons/xmlapi/mastervaluechange.cgi"

MasterValueChangeEndpoint is the endpoint for changing master value for a device

View Source
const MasterValueEndpoint = "/addons/xmlapi/mastervalue.cgi"

MasterValueEndpoint is the endpoint for retrieving master value for a device

View Source
const NotificationsEndpoint = "/config/xmlapi/systemNotification.cgi"

NotificationsEndpoint is the endpoint for the notification list

View Source
const RoomListEndpoint = "/addons/xmlapi/roomlist.cgi"

RoomListEndpoint is the endpoint for the device list

View Source
const RssiEndpoint = "/addons/xmlapi/rssilist.cgi"

RssiEndpoint is the endpoint for the device list

View Source
const StateChangeEndpoint = "/addons/xmlapi/statechange.cgi"

StateChangeEndpoint is the endpoint to change a state value

View Source
const StateEndpoint = "/addons/xmlapi/state.cgi"

StateEndpoint is the endpoint to retrieve the state for a given list of devices

View Source
const StateListEndpoint = "/addons/xmlapi/statelist.cgi"

StateListEndpoint is the endpoint to retrieve the state for all devices

View Source
const SysVarEndpoint = "/addons/xmlapi/sysvar.cgi"

SysVarEndpoint is the endpoint for a given system variable

View Source
const SysVarListEndpoint = "/addons/xmlapi/sysvarlist.cgi"

SysVarListEndpoint is the endpoint for the system variables list

Variables

View Source
var AllIDs = map[string]IDMapEntry{}

AllIDs is a map of all iseIDs to IDMapEntry

View Source
var DeviceAddressMap = map[string]DeviceListEntry{}

DeviceAddressMap is a list of devices by name

View Source
var DeviceIDMap = map[string]DeviceListEntry{}

DeviceIDMap is a list of devices by id

View Source
var DeviceTypes = map[string]DeviceTypeEntry{}

DeviceTypes is a list of device types per name

View Source
var NameIDMap = map[string]string{}

NameIDMap is a map of all names to iseIDs

View Source
var RoomMap = make(map[string]Room)

RoomMap is a list of rooms by name

View Source
var RssiDeviceMap = make(map[string]RssiDevice)

RssiDeviceMap is a list of rssi devices by name

View Source
var StateList = StateListResponse{}

StateList is the result of a statelist.cgi call

View Source
var SysVarIDMap = map[string]SysVarEntry{}

SysVarIDMap is a map of system variables by ID

Functions

func GetChannelOfDatapoint added in v1.11.1

func GetChannelOfDatapoint(id string) (channelID string, err error)

GetChannelOfDatapoint returns the channel id of the given datapoint

func GetDeviceOfChannel added in v1.11.1

func GetDeviceOfChannel(id string) (deviceID string, err error)

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 GetHmToken

func GetHmToken() string

GetHmToken returns the token for the next QueryAPI call

func GetHmURL

func GetHmURL() string

GetHmURL returns the url for the next QueryAPI call

func GetSysvarList

func GetSysvarList(text bool) (err error)

GetSysvarList returns the list of system variables

func QueryAPI

func QueryAPI(endpoint string, result interface{}, parameter map[string]string) (err error)

QueryAPI function for retrieving via http hmurl/endpoint and return result as xml

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

func SetHmURL

func SetHmURL(url string)

SetHmURL sets the url 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

func (Datapoint) String

func (e Datapoint) String() string

String returns a string representation of a 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

type IDMapEntry struct {
	IseID     string
	Name      string
	EntryType string
	Entry     any
}

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

func (Room) String

func (e Room) String() string

String returns a string representation of the device list

type RoomChannel

type RoomChannel struct {
	XMLName xml.Name `xml:"channel"`
	IseID   string   `xml:"ise_id,attr"`
}

RoomChannel is a single channel in Room

type RoomListResponse

type RoomListResponse struct {
	XMLName xml.Name `xml:"roomList"`
	Rooms   []Room   `xml:"room"`
}

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

func GetSysvar

func GetSysvar(sysvarIDs string, text bool) (result SysvarListResponse, err error)

GetSysvar returns a single system variable

Jump to

Keyboard shortcuts

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