Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveAppPreferences ¶
SaveAppPreferences will save the given preferences for the given app to a file on disk. Any existing preferences will be preserved. If there are no existing preferences, a new preferences file will be created.
func SavePreferences ¶
SavePreferences writes the given preferences to disk under the specified path. If the path is "", the preferences are saved to the file specified by PreferencesFile under the location specified by ConfigBasePath.
Types ¶
type AppPref ¶
type AppPref func(*AppPreferences)
AppPref is a functional type for applying AppPreferences
func SetAppPreferences ¶
SetAppPreferences will assign the given preferences map to the AppPreferences struct.
type AppPreferences ¶
AppPreferences holds a given app's preferences as a generic map[string]any.
func DefaultAppPreferences ¶
func DefaultAppPreferences() *AppPreferences
DefaultAppPreferences returns an empty AppPreferences struct ready for use by apps.
func LoadAppPreferences ¶
func LoadAppPreferences(app string) (*AppPreferences, error)
LoadAppPreferences will load the given app preferences from file. If there are no existing preferences, it will return an os.IsNotExist error and a default (empty) AppPreferences.
type Pref ¶
type Pref func(*Preferences)
Pref is a functional type for applying a value to a particular preference.
func SetMQTTPassword ¶
SetMQTTPassword is the functional preference that sets the MQTT password preference to the specified value.
func SetMQTTServer ¶
SetMQTTServer is the functional preference that sets the MQTT server preference to the specified value.
func SetMQTTUser ¶
SetMQTTUser is the functional preference that sets the MQTT user preference to the specified value.
func SetTopicPrefix ¶
SetTopicPrefix is the functional preference that sets the topic prefix preference to the specified value.
type Preferences ¶
type Preferences struct { Server string `toml:"mqttserver"` User string `toml:"mqttuser,omitempty"` Password string `toml:"mqttpassword,omitempty"` TopicPrefix string `toml:"topicprefix"` }
Preferences is a struct containing the general preferences for either the agent or for any code that imports go-hass-anything as a package. Currently, these preferences are for MQTT connectivity selection.
func LoadPreferences ¶
func LoadPreferences() (*Preferences, error)
LoadPreferences retrives all Preferences from disk at the given path. If the path is "", the preferences are loaded from the file specified by PreferencesFile under the location specified by ConfigBasePath.
func (*Preferences) GetMQTTPassword ¶
func (p *Preferences) GetMQTTPassword() string
MQTTPassword returns any password set in the preferences.
func (*Preferences) GetMQTTServer ¶
func (p *Preferences) GetMQTTServer() string
MQTTServer returns the current server set in the preferences.
func (*Preferences) GetMQTTUser ¶
func (p *Preferences) GetMQTTUser() string
MQTTUser returns any username set in the preferences.
func (*Preferences) GetTopicPrefix ¶
func (p *Preferences) GetTopicPrefix() string
TopicPrefix returns the topic prefix set in the preferences.