Skip to content

Commit

Permalink
Config UI: vehicle icons from yaml (#18647)
Browse files Browse the repository at this point in the history
  • Loading branch information
naltatis authored Feb 7, 2025
1 parent 229b7f1 commit 1633e72
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/js/components/Config/DeviceTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default {
case "chargedEnergy":
return this.fmtWh(value * 1e3);
case "soc":
case "socLimit":
case "vehicleLimitSoc":
return this.fmtPercentage(value, 1);
case "temp":
return this.fmtTemperature(value);
Expand Down
4 changes: 2 additions & 2 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ power = "Leistung"
powerRange = "Leistung"
range = "Reichweite"
singlePhase = "Einphasig"
soc = "SoC"
socLimit = "SoC Begrenzung"
soc = "Ladestand"
temp = "Temperatur"
topic = "Thema"
url = "URL"
vehicleLimitSoc = "Fahrzeuglimit"
yes = "Ja"

[config.deviceValueChargeStatus]
Expand Down
4 changes: 2 additions & 2 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ power = "Power"
powerRange = "Power"
range = "Range"
singlePhase = "Single phase"
soc = "SoC"
socLimit = "Limit"
soc = "Charge"
temp = "Temperature"
topic = "Topic"
url = "URL"
vehicleLimitSoc = "Vehicle limit"
yes = "yes"

[config.deviceValueChargeStatus]
Expand Down
10 changes: 8 additions & 2 deletions server/http_config_device_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ func deviceConfigMap[T any](class templates.Class, dev config.Device[T]) (map[st
dc["id"] = configurable.ID()
dc["config"] = params
} else if title := conf.Other["title"]; title != nil {
// from yaml- add title only
// from yaml
config := make(map[string]any)
if s, ok := title.(string); ok {
dc["config"] = map[string]any{"title": s}
config["title"] = s
}
// add icon if available
if icon, ok := conf.Other["icon"].(string); ok {
config["icon"] = icon
}
dc["config"] = config
}

return dc, nil
Expand Down
6 changes: 3 additions & 3 deletions server/http_config_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func testInstance(instance any) map[string]testResult {
res["phases1p3p"] = makeResult(true, nil)
}

if cc, ok := instance.(api.PhaseDescriber); ok {
res["singlePhase"] = makeResult(cc.Phases() == 1, nil)
if cc, ok := instance.(api.PhaseDescriber); ok && cc.Phases() == 1 {
res["singlePhase"] = makeResult(true, nil)
}

if dev, ok := instance.(api.VehicleRange); ok {
Expand All @@ -203,7 +203,7 @@ func testInstance(instance any) map[string]testResult {

if dev, ok := instance.(api.SocLimiter); ok {
val, err := dev.GetLimitSoc()
res["socLimit"] = makeResult(val, err)
res["vehicleLimitSoc"] = makeResult(val, err)
}

if dev, ok := instance.(api.Identifier); ok {
Expand Down

0 comments on commit 1633e72

Please sign in to comment.