fahapi

package module
v0.0.0-...-f5324a1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const ApiPathPrefix string = "/fhapi/v1"
View Source
const WebSocketPath string = "/fhapi/v1/api/ws"

Variables

View Source
var FreeDevices map[string]*Device
View Source
var UnitMap map[string]Unit

Functions

func ConfigureApi

func ConfigureApi(
	host string,
	username string,
	password string,
	callbackUnit WebsocketUpdateUnitCallbackFunc,
	callbackMessage WebsocketUpdateMessageCallbackFunc,
	loggerParam *log.Logger,
	logLevelParam int,
)

func GetDatapoint

func GetDatapoint(sysap string, deviceId string, channelId string, datapointId string) (string, error)

func GetFloorRoom

func GetFloorRoom(device *Device, channel *Channel) (string, string)

func PrtAllUnits

func PrtAllUnits()

func PutDatapoint

func PutDatapoint(sysap string, deviceId string, channelId string, datapointId string, value string) (bool, error)

func PutVirtualDevice

func PutVirtualDevice(sysap, serial string, message *VirtualDevice) (virtualSerial string, err error)

func ReadAndHydradteAllDevices

func ReadAndHydradteAllDevices()

func StartWebSocketLoop

func StartWebSocketLoop(refreshTime int) error

Types

type ApiRestConfigurationGet200ApplicationJsonResponse

type ApiRestConfigurationGet200ApplicationJsonResponse struct {
	ZeroSysAp *SysAP `json:"00000000-0000-0000-0000-000000000000"`
}

type ApiRestDatapointSysapSerialGet200ApplicationJsonResponse

type ApiRestDatapointSysapSerialGet200ApplicationJsonResponse struct {
	ZeroSysAp struct {
		Values []string `json:"values,omitempty"`
	} `json:"00000000-0000-0000-0000-000000000000"`
}

type ApiRestDatapointSysapSerialPut200TextPlainResponse

type ApiRestDatapointSysapSerialPut200TextPlainResponse map[string]struct{ Result string }

type ApiRestDeviceSysapDeviceGet200ApplicationJsonResponse

type ApiRestDeviceSysapDeviceGet200ApplicationJsonResponse struct {
	ZeroSysAp *Devices `json:"00000000-0000-0000-0000-000000000000"`
}

type ByFloorAndRoom

type ByFloorAndRoom []Unit

Sort

func (ByFloorAndRoom) Len

func (u ByFloorAndRoom) Len() int

func (ByFloorAndRoom) Less

func (u ByFloorAndRoom) Less(i, j int) bool

func (ByFloorAndRoom) Swap

func (u ByFloorAndRoom) Swap(i, j int)

type Channel

type Channel struct {
	DisplayName *string              `json:"displayName,omitempty"`
	Type        *string              `json:"type,omitempty"`
	FunctionID  *string              `json:"functionID,omitempty"` // FunctionIdType
	Inputs      map[string]*InOutPut `json:"inputs,omitempty"`
	Outputs     map[string]*InOutPut `json:"outputs,omitempty"`
	Floor       *string              `json:"floor,omitempty"`
	Room        *string              `json:"room,omitempty"`
}

Channel defines model for Channel.

type Device

type Device struct {
	DisplayName  *string             `json:"displayName,omitempty"`
	Floor        *string             `json:"floor,omitempty"`
	Room         *string             `json:"room,omitempty"`
	Interface    *string             `json:"interface,omitempty"`
	NativeId     *string             `json:"nativeId,omitempty"`
	Unresponsive *bool               `json:"unresponsive,omitempty"`
	Channels     map[string]*Channel `json:"channels,omitempty"`
}

func GetDevice

func GetDevice(sysap string, deviceId string) (*Device, error)

type Devicelist

type Devicelist struct {
	AdditionalProperties []string `json:"00000000-0000-0000-0000-000000000000"`
}

func GetDeviceList

func GetDeviceList() (*Devicelist, error)

type Devices

type Devices struct {
	Devices map[string]*Device
}

type DimmingActuatorUnit

type DimmingActuatorUnit struct {
	UnitData
	On              bool
	OnSet           bool
	DimmingValue    int
	DimmingValueSet bool
	Force           bool
	ForceSet        bool
}

func CastDAU

func CastDAU(u Unit) *DimmingActuatorUnit

func (*DimmingActuatorUnit) String

func (dau *DimmingActuatorUnit) String() string

type DimmingSensorUnit

type DimmingSensorUnit struct {
	UnitData
	On    bool
	OnSet bool
}

func CastDSU

func CastDSU(u Unit) *DimmingSensorUnit

func (*DimmingSensorUnit) String

func (dsu *DimmingSensorUnit) String() string

type Error

type Error struct {
	Code   *string `json:"code,omitempty"`
	Detail *string `json:"detail,omitempty"`
	Title  *string `json:"title,omitempty"`
}

Error defines model for Error.

type Floors

type Floors struct {
	Name  *string           `json:"name,omitempty"`
	Rooms map[string]*Rooms `json:"rooms,omitempty"`
}

type FunctionIdType

type FunctionIdType string

see https://developer.eu.mybuildings.abb.com/fah_local/reference/functionids/

const (
	FID_SWITCH_SENSOR                                  FunctionIdType = "0"
	FID_DIMMING_SENSOR                                 FunctionIdType = "1"
	FID_SWITCH_ACTUATOR                                FunctionIdType = "7"
	FID_DIMMING_ACTUATOR                               FunctionIdType = "12"
	FID_WINDOW_DOOR_SENSOR                             FunctionIdType = "f"
	FID_ROOM_TEMPERATURE_CONTROLLER_MASTER_WITHOUT_FAN FunctionIdType = "23"
	FID_BRIGHTNESS_SENSOR                              FunctionIdType = "41"
	FID_RAIN_SENSOR                                    FunctionIdType = "42"
	FID_TEMPERATURE_SENSOR                             FunctionIdType = "43"
	FID_WIND_SENSOR                                    FunctionIdType = "44"
)

type InOutPut

type InOutPut struct {
	PairingID *int    `json:"pairingID,omitempty"`
	Value     *string `json:"value,omitempty"`
}

InOutPut defines model for InOutPut.

type RoomTemperatureControllerUnit

type RoomTemperatureControllerUnit struct {
	UnitData
	ActualDegree    float64
	TargetDegree    float64
	Active          int
	Capacity        int
	ActualDegreeSet bool
	TargetDegreeSet bool
	ActiveSet       bool
	CapacitySet     bool
}

func (*RoomTemperatureControllerUnit) String

func (rtc *RoomTemperatureControllerUnit) String() string

type Rooms

type Rooms struct {
	Name *string `json:"name,omitempty"`
}

type SwitchActuatorUnit

type SwitchActuatorUnit struct {
	UnitData
	On       bool
	OnSet    bool
	Force    bool
	ForceSet bool
}

func CastSAU

func CastSAU(u Unit) *SwitchActuatorUnit

func (*SwitchActuatorUnit) String

func (sau *SwitchActuatorUnit) String() string

type SwitchSensorUnit

type SwitchSensorUnit struct {
	UnitData
	On    bool
	OnSet bool
}

func CastSSU

func CastSSU(u Unit) *SwitchSensorUnit

func (*SwitchSensorUnit) String

func (ssu *SwitchSensorUnit) String() string

type SysAP

type SysAP struct {
	Devices   map[string]*Device `json:"devices,omitempty"`
	Error     *Error             `json:"error"`
	Floorplan struct {
		Floors map[string]*Floors `json:"floors,omitempty"`
	} `json:"floorplan,omitempty"`
	SysapName *string `json:"sysapName,omitempty"`
	Users     *Users  `json:"users,omitempty"`
}
var SysAPConfiguration *SysAP

func GetConfiguration

func GetConfiguration() (*SysAP, error)

type Unit

type Unit interface {
	GetChannel() *Channel
	GetUnitData() *UnitData
	String() string
	// contains filtered or unexported methods
}

type UnitData

type UnitData struct {
	SerialNumber string
	NativeId     *string
	ChannelId    string
	Type         UnitTypeConst
	Device       *Device
	Floor        string
	Room         string
	LastUpdate   time.Time
}

hydrated data structures

func (*UnitData) GetChannel

func (u *UnitData) GetChannel() *Channel

func (*UnitData) GetUnitData

func (u *UnitData) GetUnitData() *UnitData

type UnitTypeConst

type UnitTypeConst string
const UntTypeDimmingActuator UnitTypeConst = "AcDimmin"
const UntTypeDimmingSensor UnitTypeConst = "SeDimmin"
const UntTypeRoomTemperatureController UnitTypeConst = "CoRoTemp"
const UntTypeSwitchActuator UnitTypeConst = "AcSwitch"
const UntTypeSwitchSensor UnitTypeConst = "SeSwitch"
const UntTypeWeatherStationBrightness UnitTypeConst = "SeWBrig"
const UntTypeWeatherStationRain UnitTypeConst = "SeWRain"
const UntTypeWeatherStationTemperature UnitTypeConst = "SeWTemp"
const UntTypeWeatherStationWind UnitTypeConst = "SeWWind"
const UntTypeWindowDoorSensor UnitTypeConst = "SeWindow"

type Users

type Users struct {
	AdditionalProperties map[string]struct {
		Enabled              *bool     `json:"enabled,omitempty"`
		Flags                *[]string `json:"flags,omitempty"`
		GrantedPermissions   *[]string `json:"grantedPermissions,omitempty"`
		Jid                  *string   `json:"jid,omitempty"`
		Name                 *string   `json:"name,omitempty"`
		RequestedPermissions *[]string `json:"requestedPermissions,omitempty"`
		Role                 *string   `json:"role,omitempty"`
	} `json:"-"`
}

Users defines model for Users.

type VirtualDevice

type VirtualDevice struct {
	Properties VirtualDeviceProperties `json:"properties,omitempty"`
	Type       VirtualDeviceType       `json:"type,omitempty"`
}

VirtualDevice defines model for VirtualDevice.

type VirtualDeviceProperties

type VirtualDeviceProperties struct {
	Displayname string `json:"displayname,omitempty"`
	Ttl         string `json:"ttl,omitempty"`
}

type VirtualDeviceType

type VirtualDeviceType string

VirtualDeviceType defines model for VirtualDeviceType.

const (
	VirtualDeviceType_BinarySensor              VirtualDeviceType = "BinarySensor"
	VirtualDeviceType_CODetector                VirtualDeviceType = "CODetector"
	VirtualDeviceType_CeilingFanActuator        VirtualDeviceType = "CeilingFanActuator"
	VirtualDeviceType_DimActuator               VirtualDeviceType = "DimActuator"
	VirtualDeviceType_FireDetector              VirtualDeviceType = "FireDetector"
	VirtualDeviceType_RTC                       VirtualDeviceType = "RTC"
	VirtualDeviceType_ShutterActuator           VirtualDeviceType = "ShutterActuator"
	VirtualDeviceType_SwitchingActuator         VirtualDeviceType = "SwitchingActuator"
	VirtualDeviceType_WeatherStation            VirtualDeviceType = "WeatherStation"
	VirtualDeviceType_Weather_BrightnessSensor  VirtualDeviceType = "Weather-BrightnessSensor"
	VirtualDeviceType_Weather_RainSensor        VirtualDeviceType = "Weather-RainSensor"
	VirtualDeviceType_Weather_TemperatureSensor VirtualDeviceType = "Weather-TemperatureSensor"
	VirtualDeviceType_Weather_WindSensor        VirtualDeviceType = "Weather-WindSensor"
	VirtualDeviceType_WindowActuator            VirtualDeviceType = "WindowActuator"
	VirtualDeviceType_WindowSensor              VirtualDeviceType = "WindowSensor"
)

List of VirtualDeviceType

type VirtualDevicesSuccess

type VirtualDevicesSuccess struct {
	ZeroSysAp struct {
		Devices map[string]struct {
			Serial string `json:"serial,omitempty"`
		} `json:"devices,omitempty"`
	} `json:"00000000-0000-0000-0000-000000000000"`
}

VirtualDevicesSuccess defines model for VirtualDevicesSuccess.

type VirtualDevicesSuccessXXX struct {
	AdditionalProperties map[string]struct {
		Devices *VirtualDevicesSuccess_Devices `json:"devices,omitempty"`
	} `json:"-"`
}

type WeatherStationBrightnessUnit

type WeatherStationBrightnessUnit struct {
	UnitData
	Luminance         float64
	LuminanceSet      bool
	LuminanceAlarm    bool
	LuminanceAlarmSet bool
}

func (*WeatherStationBrightnessUnit) String

func (ws *WeatherStationBrightnessUnit) String() string

type WeatherStationRainUnit

type WeatherStationRainUnit struct {
	UnitData
	RainAlarm         bool
	RainAlarmSet      bool
	RainPercentage    int
	RainPercentageSet bool
}

func CastWSR

func CastWSR(u Unit) *WeatherStationRainUnit

func (*WeatherStationRainUnit) String

func (ws *WeatherStationRainUnit) String() string

type WeatherStationTemperatureUnit

type WeatherStationTemperatureUnit struct {
	UnitData
	Temperature    float64
	TemperatureSet bool
	FreezeAlarm    bool
	FreezeAlarmSet bool
}

func (*WeatherStationTemperatureUnit) String

type WeatherStationWindUnit

type WeatherStationWindUnit struct {
	UnitData
	Wind         float64
	WindSet      bool
	WindAlarm    bool
	WindAlarmSet bool
	WindForce    float64
	WindForceSet bool
}

func CastWSW

func CastWSW(u Unit) *WeatherStationWindUnit

func (*WeatherStationWindUnit) String

func (ws *WeatherStationWindUnit) String() string

type WebsocketMessage

type WebsocketMessage struct {
	ZeroSysAp struct {
		Datapoints      map[string]string      `json:"datapoints"`
		Devices         map[string]*Devices    `json:"devices"`
		DevicesAdded    []string               `json:"devicesAdded"`
		DevicesRemoved  []string               `json:"devicesRemoved"`
		ScenesTriggered map[string]interface{} `json:"scenesTriggered"`
	} `json:"00000000-0000-0000-0000-000000000000"`
}

type WebsocketUpdateMessageCallbackFunc

type WebsocketUpdateMessageCallbackFunc func(message WebsocketMessage)

type WebsocketUpdateUnitCallbackFunc

type WebsocketUpdateUnitCallbackFunc func(unitKeys []string)

type WindowDoorSensorUnit

type WindowDoorSensorUnit struct {
	UnitData
	Open    bool
	OpenSet bool
}

func CastWDS

func CastWDS(u Unit) *WindowDoorSensorUnit

func (*WindowDoorSensorUnit) String

func (wds *WindowDoorSensorUnit) String() string

Jump to

Keyboard shortcuts

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