Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config UI: vehicle icons from yaml #18647

Merged
merged 4 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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