Mqtt: publish vehicles on top level
This commit is contained in:
parent
8e7df670a8
commit
177fe88f2e
3 changed files with 10 additions and 6 deletions
|
|
@ -24,7 +24,7 @@ const (
|
|||
Statistics = "statistics"
|
||||
TariffCo2 = "tariffCo2"
|
||||
TariffCo2Home = "tariffCo2Home"
|
||||
TariffCo2Loadpoints = "tariffCo2Loadpoin"
|
||||
TariffCo2Loadpoints = "tariffCo2Loadpoints"
|
||||
TariffFeedIn = "tariffFeedIn"
|
||||
TariffGrid = "tariffGrid"
|
||||
TariffPriceHome = "tariffPriceHome"
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ func (site *Site) updateVehicles(op config.Operation, dev config.Device[api.Vehi
|
|||
site.coordinator.Delete(vehicle)
|
||||
}
|
||||
|
||||
// TODO remove vehicle from mqtt
|
||||
site.publishVehicles()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
var deprecatedTopics = []string{
|
||||
"activePhases", "range", "socCharge",
|
||||
"vehicleSoC", "batterySoC", "bufferSoC", "minSoC", "prioritySoC", "targetSoC", "vehicleTargetSoC",
|
||||
"vehicleSoC", "batterySoC", "bufferSoC", "minSoC", "prioritySoC", "targetSoC", "vehicleTargetSoC", "vehicles",
|
||||
"savingsAmount", "savingsEffectivePrice", "savingsGridCharged", "savingsSelfConsumptionCharged", "savingsSelfConsumptionPercent", "savingsTotalCharged",
|
||||
"stats/30d", "stats/365d", "stats/total",
|
||||
}
|
||||
|
|
@ -385,10 +385,14 @@ func (m *MQTT) Run(site site.API, in <-chan util.Param) {
|
|||
|
||||
// publish
|
||||
for p := range in {
|
||||
topic := fmt.Sprintf("%s/site", m.root)
|
||||
if p.Loadpoint != nil {
|
||||
switch {
|
||||
case p.Loadpoint != nil:
|
||||
id := *p.Loadpoint + 1
|
||||
topic = fmt.Sprintf("%s/loadpoints/%d", m.root, id)
|
||||
topic = fmt.Sprintf("%s/loadpoints/%d/%s", m.root, id, p.Key)
|
||||
case p.Key == "vehicles":
|
||||
topic = fmt.Sprintf("%s/vehicles", m.root)
|
||||
default:
|
||||
topic = fmt.Sprintf("%s/site/%s", m.root, p.Key)
|
||||
}
|
||||
|
||||
// alive indicator
|
||||
|
|
@ -398,7 +402,6 @@ func (m *MQTT) Run(site site.API, in <-chan util.Param) {
|
|||
}
|
||||
|
||||
// value
|
||||
topic += "/" + p.Key
|
||||
m.publish(topic, true, p.Val)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue