xovis

package
v0.2024.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package xovis contains a driver for camera-based occupancy sensors produced by Xovis. This package is intended to work with sensors running firmware version 5.x.

Xovis exposes data organised under Logics. Zone-based (occupancy) logics are exposed by this driver using the OccupancySensor trait. Line-based (person count in/out) logics are exposed by this driver using the EnterLeaveSensor trait.

A Xovis sensor can operate in single-sensor or multi-sensor modes. The data and operation available are similar between these two modes, but in the API they are accessed using separate endpoints.

For one-shot data access, the driver uses the Live Data API endpoints to fetch the most up-to-date info on the appropriate logic. This involves us performing an HTTP(S) request to the sensor's built-in server. For streaming data (e.g. PullXxx Smart Core APIs) data flows in the other direction using a webhook - we add a route to the area controller's HTTP server for receiving the data. A Data Push agent must be manually configured on the sensor as follows:

Data Push Agent:

  • Type: Logics push
  • Scheduler Type: Immediate
  • Resolution: As desired, 1 minute makes most sense
  • Format: JSON
  • Time Format: RFC 3339

Index

Constants

View Source
const DriverName = "xovis"

Variables

View Source
var Factory driver.Factory = factory{}

Functions

func ResetLiveLogic

func ResetLiveLogic(conn *Client, multiSensor bool, id int) error

Types

type APIError

type APIError struct {
	Code   int      `json:"code"`
	Info   string   `json:"info"`
	Detail []string `json:"detail,omitempty"`
}

func (APIError) Error

func (err APIError) Error() string

type Client

type Client struct {
	// BaseURL is the root of the API.
	// e.g. https://1.2.3.4/api/v5
	BaseURL  url.URL
	Client   *http.Client
	Username string
	Password string
}

func NewInsecureClient

func NewInsecureClient(host string, username string, password string) *Client

NewInsecureClient creates a Client that connects over HTTPS but does not verify the server certificate.

type Code

type Code int
const (
	CodeInvalidSettings          Code = 10010
	CodeInvalidContentType       Code = 11000
	CodeEmptyRequest             Code = 11001
	CodeContentLengthRequired    Code = 11002
	CodeInvalidJSON              Code = 11100
	CodeInvalidTimeFormat        Code = 11200
	CodeTimeInPast               Code = 11201
	CodeUpdateDowngrade          Code = 21000
	CodeUpdateUploading          Code = 21001
	CodeUpdateInstalling         Code = 21002
	CodeUpdateInvalid            Code = 21003
	CodeBackupIPSettingsChanged  Code = 21100
	CodeBackupNewerVersion       Code = 21101
	CodeDataPushIDModeError      Code = 31000
	CodeDataPushAgentTriggerBusy Code = 31001
)

type Count

type Count struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Value int    `json:"value"`
}

type DataPushConfig

type DataPushConfig struct {
	HTTPPort    int    `json:"httpPort,omitempty"`
	WebhookPath string `json:"webhookPath"`
}

type DeviceConfig

type DeviceConfig struct {
	Name       string           `json:"name"`
	Occupancy  *LogicConfig     `json:"occupancy"`  // an Occupancy logic
	EnterLeave *LogicConfig     `json:"enterLeave"` // an In/Out logic
	Metadata   *traits.Metadata `json:"metadata,omitempty"`
}

type DeviceInfo

type DeviceInfo struct {
	HWBomRev  string `json:"hw_bom_rev"`
	HWPcbRev  string `json:"hw_pcb_rev"`
	Serial    string `json:"serial"`
	FWVersion string `json:"fw_version"`
	ProdCode  string `json:"prod_code"`
	Type      string `json:"type"`
	Variant   string `json:"variant"`
	HWProdRev string `json:"hw_prod_rev"`
	HWID      string `json:"hw_id"`
}

func GetDeviceInfo

func GetDeviceInfo(conn *Client) (DeviceInfo, error)

type Driver

type Driver struct {
	*service.Service[DriverConfig]
	driver.Services
	// contains filtered or unexported fields
}

type DriverConfig

type DriverConfig struct {
	driver.BaseConfig
	MultiSensor  bool            `json:"multiSensor"`
	Host         string          `json:"host"`
	Username     string          `json:"username"`
	Password     string          `json:"password,omitempty"`
	PasswordFile string          `json:"passwordFile,omitempty"`
	DataPush     *DataPushConfig `json:"dataPush"`
	Devices      []DeviceConfig  `json:"devices,omitempty"`
}

func DefaultConfig

func DefaultConfig() DriverConfig

func ParseConfig

func ParseConfig(raw []byte) (DriverConfig, error)

func (DriverConfig) LoadPassword

func (c DriverConfig) LoadPassword() (string, error)

type Geometry

type Geometry struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
	Name string `json:"name"`
}

type LiveLogicData

type LiveLogicData struct {
	ID         int        `json:"id"`
	Name       string     `json:"name"`
	Info       string     `json:"info"`
	Geometries []Geometry `json:"geometries"`
	Counts     []Count    `json:"counts"`
}

type LiveLogicResponse

type LiveLogicResponse struct {
	Time  time.Time     `json:"time"`
	Logic LiveLogicData `json:"logic"`
}

func GetLiveLogic

func GetLiveLogic(conn *Client, multiSensor bool, id int) (res LiveLogicResponse, err error)

type LiveLogicsResponse

type LiveLogicsResponse struct {
	Time   time.Time       `json:"time"`
	Logics []LiveLogicData `json:"logics"`
}

func GetLiveLogics

func GetLiveLogics(conn *Client, multiSensor bool) (res LiveLogicsResponse, err error)

type Logic

type Logic struct {
	ID         int           `json:"id"`
	Name       string        `json:"name"`
	Info       string        `json:"info"`
	Geometries []Geometry    `json:"geometries"`
	Records    []LogicRecord `json:"records"`
}

type LogicConfig

type LogicConfig struct {
	ID int `json:"id"`
}

type LogicRecord

type LogicRecord struct {
	From            time.Time `json:"from"`
	To              time.Time `json:"to"`
	Samples         int       `json:"samples"`
	SamplesExpected int       `json:"samples_expected"`
	Counts          []Count   `json:"counts"`
}

type LogicsPushData

type LogicsPushData struct {
	PackageInfo *PackageInfo `json:"package_info,omitempty"`
	SensorInfo  *SensorInfo  `json:"sensor_info,omitempty"`
	Logics      []Logic      `json:"logics"`
}

type PackageInfo

type PackageInfo struct {
	Version   string    `json:"version"`
	ID        int       `json:"id"`
	From      time.Time `json:"from"`
	To        time.Time `json:"to"`
	AgentID   int       `json:"agent_id"`
	AgentName string    `json:"agent_name"`
	AgentType string    `json:"agent_type"`
}

type PushData

type PushData struct {
	LogicsData *LogicsPushData `json:"logics_data,omitempty"`
}

type SensorInfo

type SensorInfo struct {
	Type         string    `json:"type"`
	SerialNumber string    `json:"serial_number"`
	Name         string    `json:"name"`
	Group        string    `json:"group"`
	DeviceType   string    `json:"device_type"`
	HWVersion    string    `json:"hw_version"`
	SWVersion    string    `json:"sw_version"`
	Time         time.Time `json:"time"`
	Timezone     string    `json:"timezone"`
}

Jump to

Keyboard shortcuts

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