Skip to content
Closed
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 packages/modules/devices/tasmota/tasmota/bat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def update(self):
currents = [0.0, 0.0, 0.0]

power = float(response['StatusSNS']['ENERGY']['Power'])
currents[self.__phase-1] = (response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currents[self.__phase-1] = float(...), 0.0, 0.0 assigns a tuple into one entry of the currents list, so BatState ends up with something like [0.0, (I,0,0), 0.0]. Downstream code sums currents to validate the sign, which will raise a TypeError. Assign only the scalar current to the selected phase (the list already contains zeros for other phases).

Suggested change
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current'])

Copilot uses AI. Check for mistakes.
imported = float(response['StatusSNS']['ENERGY']['Total']*1000)
_, exported = self.sim_counter.sim_count(power)

Expand Down
2 changes: 1 addition & 1 deletion packages/modules/devices/tasmota/tasmota/inverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def update(self):
currents = [0.0, 0.0, 0.0]

power = float(response['StatusSNS']['ENERGY']['Power']) * -1
currents[self.__phase-1] = (response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currents[self.__phase-1] = float(...), 0.0, 0.0 assigns a 3-tuple into a single list element, producing a nested tuple inside currents. This will break InverterState's check_currents_power_sign() (it does sum(currents)) with a TypeError. Assign only the scalar current to the selected phase (the list is already initialized with zeros for the other phases).

Suggested change
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current']), 0.0, 0.0
currents[self.__phase-1] = float(response['StatusSNS']['ENERGY']['Current'])

Copilot uses AI. Check for mistakes.
_, exported = self.sim_counter.sim_count(power)

inverter_state = InverterState(
Expand Down