Skip to content

Commit

Permalink
feat: Add support for multiple VE.Bus inverter/charger devices
Browse files Browse the repository at this point in the history
  • Loading branch information
mman committed Jan 17, 2025
1 parent c83d7c0 commit 4ce2348
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useGeneratorRelay,
useInverters,
useVebus,
VebusInverters,
VebusDevices,
} from "@victronenergy/mfd-modules"
import Charger from "../Charger"
import Inverter from "../Inverter"
Expand All @@ -40,7 +40,7 @@ interface Props {

const DevicesOverview = ({ componentMode = "full", pageSelectorPropsSetter }: Props) => {
const { inverters } = useInverters()
const { instanceId: vebusInstanceId, vebusInverters } = useVebus()
const { instanceId, vebusInverters, vebusInverterChargers } = useVebus()
const { chargers } = useChargers()
const generatorConnectedGenset = useGeneratorConnectedGenset()
const generatorRelay = useGeneratorRelay()
Expand All @@ -50,7 +50,8 @@ const DevicesOverview = ({ componentMode = "full", pageSelectorPropsSetter }: Pr
chargers,
inverters,
vebusInverters,
vebusInstanceId,
vebusInverterChargers,
instanceId,
generatorConnectedGenset,
generatorRelay,
compactBoxSize,
Expand Down Expand Up @@ -100,7 +101,8 @@ const DevicesOverview = ({ componentMode = "full", pageSelectorPropsSetter }: Pr
const getAvailableDeviceBoxes = function (
chargers: ChargerInstanceId[],
inverters: InverterInstanceId[],
vebusInverters: VebusInverters,
vebusInverters: VebusDevices,
vebusInverterChargers: VebusDevices,
vebusInstanceId: InstanceId,
generatorConnectedGenset: GeneratorConnectedGensetProvider,
generatorRelay: GeneratorRelayProvider,
Expand Down Expand Up @@ -145,10 +147,18 @@ const getAvailableDeviceBoxes = function (
})
}

if (!!vebusInstanceId && !vebusInverters.includes(vebusInstanceId)) {
devices.push(
<InverterCharger key={vebusInstanceId} componentMode={componentMode} compactBoxSize={compactBoxSize} />
)
if (vebusInverterChargers.length) {
vebusInverterChargers.forEach((id) => {
devices.push(
<InverterCharger
key={id}
instanceId={id}
isMainVEBusDevice={id === vebusInstanceId}
componentMode={componentMode}
compactBoxSize={compactBoxSize}
/>
)
})
}

if (generatorConnectedGenset.gensetState.gensetType === ConnectedGensetType.ACGENSET) {
Expand Down

0 comments on commit 4ce2348

Please sign in to comment.