generated from rmcguire/go-server-with-otel
remove rheemcloud pkg, implement against rest api only
This commit is contained in:
+11
-10
@@ -12,9 +12,9 @@ import (
|
||||
"gitea.libretechconsulting.com/rmcguire/go-app/pkg/config"
|
||||
)
|
||||
|
||||
// DefaultUsageInterval is used when UsageInterval is unset. Rheem's
|
||||
// energy/water history only updates hourly, so polling faster is wasteful.
|
||||
const DefaultUsageInterval = 5 * time.Minute
|
||||
// DefaultPollInterval is used when PollInterval is unset. Each tick re-fetches
|
||||
// device state and daily energy/water usage over REST.
|
||||
const DefaultPollInterval = 1 * time.Minute
|
||||
|
||||
type ServiceConfig struct {
|
||||
// Rheem EcoNet cloud credentials. Prefer supplying the password via
|
||||
@@ -30,8 +30,9 @@ type ServiceConfig struct {
|
||||
// metric from kWh energy usage.
|
||||
CostPerKWH float64 `yaml:"costPerKWH" json:"costPerKWH,omitempty" env:"ECONET_COST_PER_KWH" default:"0.19"`
|
||||
|
||||
// UsageInterval controls how often energy/water usage history is polled.
|
||||
UsageInterval time.Duration `yaml:"usageInterval" json:"usageInterval,omitempty" env:"ECONET_USAGE_INTERVAL"`
|
||||
// PollInterval controls how often device state and daily energy/water
|
||||
// usage are re-fetched over REST.
|
||||
PollInterval time.Duration `yaml:"pollInterval" json:"pollInterval,omitempty" env:"ECONET_POLL_INTERVAL"`
|
||||
|
||||
// Embeds go-app config, used by go-app to
|
||||
// merge custom config into go-app config, and to produce
|
||||
@@ -50,10 +51,10 @@ func (c *ServiceConfig) LoadEnv() error {
|
||||
return env.Parse(c)
|
||||
}
|
||||
|
||||
// GetUsageInterval returns the configured usage poll interval or the default.
|
||||
func (c *ServiceConfig) GetUsageInterval() time.Duration {
|
||||
if c.UsageInterval <= 0 {
|
||||
return DefaultUsageInterval
|
||||
// GetPollInterval returns the configured poll interval or the default.
|
||||
func (c *ServiceConfig) GetPollInterval() time.Duration {
|
||||
if c.PollInterval <= 0 {
|
||||
return DefaultPollInterval
|
||||
}
|
||||
return c.UsageInterval
|
||||
return c.PollInterval
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user