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 RegisterApps ¶
RegisterApps is the functional preference that appends the list of given apps to the existing registered apps in the preferences.
func SetMQTTPassword ¶ added in v5.0.1
SetMQTTPassword is the functional preference that sets the SetMQTTPassword preference to the specified value.
func SetMQTTServer ¶ added in v5.0.1
SetMQTTServer is the functional preference that sets the SetMQTTServer preference to the specified value.
func SetMQTTUser ¶ added in v5.0.1
SetMQTTUser is the functional preference that sets the SetMQTTUser preference to the specified value.
func UnRegisterApps ¶
UnRegisterApps is the functional preference that will remove the list of given apps from the registered apps in the preferences.
type Preferences ¶
type Preferences struct { Server string `toml:"mqttserver"` User string `toml:"mqttuser,omitempty"` Password string `toml:"mqttpassword,omitempty"` RegisteredApps []string `toml:"registeredapps,omitempty"` }
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 ¶ added in v5.0.1
func (p *Preferences) GetMQTTPassword() string
MQTTPassword returns any password set in the preferences.
func (*Preferences) GetMQTTServer ¶ added in v5.0.1
func (p *Preferences) GetMQTTServer() string
MQTTServer returns the current server set in the preferences.
func (*Preferences) GetMQTTUser ¶ added in v5.0.1
func (p *Preferences) GetMQTTUser() string
MQTTUser returns any username set in the preferences.
func (*Preferences) IsRegistered ¶
func (p *Preferences) IsRegistered(app string) bool
IsRegistered will check whether the given app has been recorded as registered in the preferences.