Skip to content

Commit

Permalink
add number of batteries to Home Assistant device
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrossbach committed Aug 3, 2024
1 parent 936cea7 commit dab6023
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/homeassistant/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
IconSolarPower Icon = "mdi:solar-power"
IconBatteryPlus Icon = "mdi:battery-plus"
IconBatteryMinus Icon = "mdi:battery-minus"
IconCarBattery Icon = "mdi:car-battery"
)

type Sensor struct {
Expand Down
9 changes: 9 additions & 0 deletions internal/homeassistant/service_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,14 @@ func (s *Service) GenerateSensorDiscoveryPayload(deviceName string, serialNumber
UniqueId: fmt.Sprintf("%s_%s", serialNumber, "soc"),
Device: device,
},
{
Name: "Number Of Batteries",
StateClass: StateClassMeasurement,
StateTopic: stateTopic,
Icon: IconCarBattery,
ValueTemplate: "{{ value_json.battery_num }}",
UniqueId: fmt.Sprintf("%s_%s", serialNumber, "battery_num"),
Device: device,
},
}
}

0 comments on commit dab6023

Please sign in to comment.