Documentation
¶
Index ¶
- Constants
- Variables
- func AdvertiseHA(r []Room, client MQTT.Client)
- func EncodeJPEG(img image.Image) ([]byte, error)
- func GetRandString(n int) string
- func InitTritonClient() error
- func LogInit(inlevel string)
- func MqttInit()
- func OnNewConfig()
- func RegisterMQTTConnectHook(name string, handler func(MQTT.Client))
- func RegisterMQTTSubscription(topic string, handler MQTT.MessageHandler)
- func RegisterNewConfigListener(new_listener func())
- func SetupConfig()
- type CamForwarder
- type CamForwarderCamera
- type HAAdvertisement
- type HAAvdvertisementAvailability
- type HADeviceSpec
- type Location
- type Model
- func (m *Model) BuildModel() error
- func (m Model) FindOccupancyTopicByRoom(room string) string
- func (m Model) FindRoomByTopic(topic string) string
- func (m Model) FindTopicType(topic string) int
- func (m Model) ModelStatus() *ModelStatus
- func (m *Model) RoomOccupancyPeriod(room string) int64
- func (m Model) SubscribeTopics() []string
- func (m *Model) UpdateRoomStatus(room string, item RoomStatus)
- type ModelStatus
- type MonitorServer
- type Person
- type Room
- type RoomStatus
- type TritonClient
- type TritonDetection
Constants ¶
View Source
const ( PIC = iota MOTION = iota OCCUPANCY = iota DOOR = iota )
View Source
const ( OCCUPIED = iota UNOCCUPIED = iota MOTION_START = iota MOTION_STOP = iota DOOR_OPEN = iota DOOR_CLOSED = iota )
View Source
const ENV_PREFIX = ""
Variables ¶
View Source
var Client MQTT.Client
View Source
var Config = viper.New()
View Source
var (
Logger zerolog.Logger
)
Functions ¶
func AdvertiseHA ¶
func EncodeJPEG ¶
EncodeJPEG encodes an image.Image to JPEG bytes (quality 85). Exposed so the occupancy layer can re-encode the letterboxed preview if needed.
func GetRandString ¶
func InitTritonClient ¶
func InitTritonClient() error
InitTritonClient creates the gRPC connection to the Triton server. Call this once at startup, and again whenever config changes.
func OnNewConfig ¶
func OnNewConfig()
func RegisterMQTTConnectHook ¶
func RegisterMQTTSubscription ¶
func RegisterMQTTSubscription(topic string, handler MQTT.MessageHandler)
func RegisterNewConfigListener ¶
func RegisterNewConfigListener(new_listener func())
func SetupConfig ¶
func SetupConfig()
Types ¶
type CamForwarder ¶
type CamForwarder struct {
Cameras []CamForwarderCamera `mapstructure:"cameras"`
Frequency int64 `mapstructure:"frequency"`
Workers int64 `mapstructure:"workers"`
Enabled bool `mapstructure:"enabled"`
}
func (*CamForwarder) MakeCamForwarder ¶
func (cf *CamForwarder) MakeCamForwarder()
func (*CamForwarder) Start ¶
func (forwarder *CamForwarder) Start()
type CamForwarderCamera ¶
type HAAdvertisement ¶
type HAAdvertisement struct {
HAAvdvertisementAvailability []HAAvdvertisementAvailability `json:"availability"`
Device HADeviceSpec `json:"device"` // Device info
UniqueID string `json:"uniq_id"` // "window_contact_sensor_1"
Name string `json:"name"` // : "Window Contact Sensor"
StateTopic string `json:"state_topic"` // : "home-assistant/window/contact"
PayloadOn string `json:"payload_on"` // : "ON"
PayloadOff string `json:"payload_off"`
DeviceClass string `json:"device_class"` // : "occupancy"
Platform string `json:"platform"` // "binary-sensor"
Qos int `json:"qos"`
}
func ConstructHAAdvertisement ¶
func ConstructHAAdvertisement(name, stateTopic string) HAAdvertisement
func (HAAdvertisement) ToJson ¶
func (ha HAAdvertisement) ToJson() string
type HADeviceSpec ¶
type Location ¶
type Location struct {
Name string `mapstructure:"name"`
Lat float64 `mapstructure:"latitude"`
Lon float64 `mapstructure:"longitude"`
}
func (Location) GetCoordinates ¶
type Model ¶
type Model struct {
Rooms []Room `mapstructure:"rooms"`
People []Person `mapstructure:"people"`
Location Location `mapstructure:"location"`
}
func (*Model) BuildModel ¶
func (Model) FindOccupancyTopicByRoom ¶
func (Model) FindRoomByTopic ¶
func (Model) FindTopicType ¶
func (Model) ModelStatus ¶
func (m Model) ModelStatus() *ModelStatus
func (*Model) RoomOccupancyPeriod ¶
func (Model) SubscribeTopics ¶
func (*Model) UpdateRoomStatus ¶
func (m *Model) UpdateRoomStatus(room string, item RoomStatus)
type ModelStatus ¶
type ModelStatus struct {
Room_status map[string]RoomStatus
}
type MonitorServer ¶
type MonitorServer struct {
// contains filtered or unexported fields
}
func NewMonitorServer ¶
func NewMonitorServer() *MonitorServer
func (*MonitorServer) AddHandler ¶
func (s *MonitorServer) AddHandler(path string, handler func(http.ResponseWriter, *http.Request))
func (*MonitorServer) AddRawHandler ¶
func (s *MonitorServer) AddRawHandler(path string, handler http.Handler)
func (*MonitorServer) Restart ¶
func (s *MonitorServer) Restart()
func (*MonitorServer) Start ¶
func (s *MonitorServer) Start() error
type Room ¶
type Room struct {
Name string `mapstructure:"name"`
Occupancy_topic string `mapstructure:"occupancy_topic"`
Motion_topics []string `mapstructure:"motion_topics"`
Pic_topics []string `mapstructure:"pic_topics"`
Door_topics []string `mapstructure:"door_dopics"`
Occupancy_period int64 `mapstructure:"occupancy_period"`
}
type RoomStatus ¶
type RoomStatus struct {
// contains filtered or unexported fields
}
func (*RoomStatus) GetLastOccupied ¶
func (m *RoomStatus) GetLastOccupied() int64
func (*RoomStatus) GetMotionState ¶
func (m *RoomStatus) GetMotionState() bool
func (*RoomStatus) Motion ¶
func (m *RoomStatus) Motion(state bool)
func (*RoomStatus) Occupied ¶
func (m *RoomStatus) Occupied()
func (*RoomStatus) Unoccupied ¶
func (m *RoomStatus) Unoccupied()
type TritonClient ¶
type TritonClient struct {
// contains filtered or unexported fields
}
TritonClient manages the gRPC connection to a Triton Inference Server.
type TritonDetection ¶
TritonDetection holds a single object detection result.
func DetectObjects ¶
func DetectObjects(jpegData []byte) ([]TritonDetection, error)
DetectObjects submits a JPEG image to the Triton Inference Server running YOLO11 and returns the detected objects above the configured confidence threshold. The caller is responsible for converting the raw JPEG bytes.
Click to show internal directories.
Click to hide internal directories.