environment

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 26 Imported by: 0

README

PMAAS Environment Plugin

A plugin that wraps lower-level environmental sensors and controllers and provides additional functionality and a user interface.

The idea is to re-use the same interface for multiple sensors.

Notes

  • Tracks daily highs and lows.
  • Provides a single entity type over multiple lower-level types.

Groups

The plugin's card for a thermometer or thermostat has more on it than the source plugin's own (the Bluetooth plugin's, the Nest plugin's), so an assembly that organises entities into groups (the groups plugin) can hold this plugin's entity instead of the source's. Of takes what the source plugin's config gave back and says which entity of this plugin shows it:

environmentConfig := environment.NewPluginConfig()
...
cougar.Group("Master Bedroom").Add(environmentConfig.Of(masterBedroomThermometer))

The entity has a view that covers the source's, so a page that lists everything, such as the groups plugin's root, shows this plugin's card and not both. Entities from a peer (net discovery) have no view.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IWirelessThermometerType = reflect.TypeFor[environmental.IWirelessThermometer]()

Functions

This section is empty.

Types

type EntitySnapshot added in v0.0.4

type EntitySnapshot struct {
	RawId string
	Kind  string
	Name  string
	State any
	AsOf  time.Time
}

EntitySnapshot is one of this node's own entities, in the plugin-agnostic shape netDiscovery needs to build an outgoing Announce - decoupled from both the wire format (discovery.EntityAnnouncement) and the plugin's own concrete thermometer/thermostat types, so netDiscovery never needs to import either.

type NetDiscoveryConfig added in v0.0.2

type NetDiscoveryConfig struct {
	// EnableAnnounce broadcasts this node's known entities to the local network - e.g. so an
	// environment plugin instance running elsewhere (a Mac dev machine that can't run the
	// Linux-only bluetooth plugin, for example) can discover and mirror them.
	EnableAnnounce bool

	// EnableDiscover listens for other nodes' announcements and queries for them on startup.
	// Independent of EnableAnnounce - a node can discover without ever announcing itself, or
	// announce without ever creating shadow entities from what it hears.
	EnableDiscover bool

	// GroupAddress is the multicast group and port used for discovery traffic, e.g.
	// "239.192.42.1:9999" - must be in the administratively-scoped range
	// 239.0.0.0/8-239.255.255.255. Required whenever EnableAnnounce or EnableDiscover is set.
	GroupAddress string

	// InterfaceName pins discovery traffic to one network interface (e.g. "en0"). Strongly
	// recommended on any multi-homed host - see discovery.Config.InterfaceName.
	InterfaceName string

	// TTL is the IP hop count on announced/sent packets. Left at its zero value, discovery
	// traffic never leaves the local network segment - see discovery.Config.TTL for why that's
	// the safe default, and what has to be true on the network (real multicast routing or an
	// IGMP-proxy feature bridging the relevant subnets, not just IGMP snooping/querier) before
	// raising this to let it cross a router onto another subnet/VLAN.
	TTL int
}

NetDiscoveryConfig controls this plugin's optional multicast peer discovery: broadcasting the entities this instance knows about to the local network, and/or listening for other instances doing the same. See netdiscovery.go. Its zero value (both flags false) leaves net discovery fully disabled, matching every existing PluginConfig's zero-value default.

type Plugin

type Plugin interface {
	spi.IPMAASPlugin
}

func NewPlugin

func NewPlugin(config PluginConfig) Plugin

type PluginConfig

type PluginConfig struct {
	NetDiscovery NetDiscoveryConfig
	// contains filtered or unexported fields
}

func NewPluginConfig

func NewPluginConfig() PluginConfig

func (PluginConfig) Of added in v0.0.9

func (c PluginConfig) Of(source entity.Ref) entity.Ref

Of is the entity of this plugin that shows the source: a thermometer or thermostat another plugin registered, which is what a plugin's config gave back for it (a bluetooth.ThermometerHandle, a nest ThermostatHandle). This plugin's card for it has more on it than the source's own, so a group holds this when it should show that. Use it with NewPluginConfig's result.

type RemoteEntityRef added in v0.0.4

type RemoteEntityRef struct {
	Sender discovery.InstanceID
	RawId  string
}

RemoteEntityRef identifies one entity mirrored in from a peer, by the peer's persisted identity and the raw id it announced that entity under.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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