22 lines
492 B
Go
22 lines
492 B
Go
package robot
|
|
|
|
// Derive maps retained facts to the single HA state string using the §10.2
|
|
// precedence: error latch, then docked, returning, paused, cleaning, idle.
|
|
func Derive(f Facts) string {
|
|
switch {
|
|
case f.ErrorLatched:
|
|
return "error"
|
|
case f.Charge == "SlotCharging":
|
|
return "docked"
|
|
case f.Charge == "going":
|
|
return "returning"
|
|
case f.Paused:
|
|
return "paused"
|
|
}
|
|
switch f.CleanType {
|
|
case "auto", "border", "spot", "singleRoom":
|
|
return "cleaning"
|
|
}
|
|
return "idle"
|
|
}
|