add set mode option
Build and Publish / container-images (push) Has been skipped
Build and Publish / check-chart (push) Successful in 15s
Build and Publish / go-binaries (push) Has been skipped
Build and Publish / helm-release (push) Has been skipped

This commit is contained in:
2026-07-16 15:35:12 -04:00
parent 8e0e59db16
commit 52ed5a7e3a
10 changed files with 731 additions and 25 deletions
+27
View File
@@ -26,6 +26,11 @@ type Device struct {
Running bool // true when actively heating (decoded from @RUNNING over REST)
RunningState string // normalized @RUNNING label: "compressor-running" | "element-running" | "idle" | ...
// modeEnumText is the raw @MODE enum label list; the slice index is the
// integer value published to change the mode. Empty for units without a
// settable @MODE (mode changes are unsupported for those).
modeEnumText []string
Setpoint int
SetpointMin int
SetpointMax int
@@ -62,9 +67,31 @@ func newDevice(info map[string]json.RawMessage, now time.Time) *Device {
d.FriendlyName = friendlyName(info, d.DeviceID)
d.Setpoint, d.SetpointMin, d.SetpointMax = setpoint(info["@SETPOINT"])
d.Running, d.RunningState = running(info)
d.modeEnumText = modeLabels(info)
return d
}
// SupportedModes returns the normalized mode slugs this device can be set to,
// in publish-index order. Empty for units without a settable @MODE.
func (d *Device) SupportedModes() []string {
out := make([]string, 0, len(d.modeEnumText))
for _, label := range d.modeEnumText {
out = append(out, modeFromEnumText(label))
}
return out
}
// modeIndex maps a normalized mode slug to the integer value the EcoNet cloud
// expects in a @MODE publish, matching pyeconet's enumText-position lookup.
func (d *Device) modeIndex(slug string) (int, bool) {
for i, label := range d.modeEnumText {
if modeFromEnumText(label) == slug {
return i, true
}
}
return 0, false
}
// --- field decoders ------------------------------------------------------
func connected(info map[string]json.RawMessage) bool {