EV-03 round 2: a missing car power is unknown, and mode3 E/F has a state
- CarTracker.car_w returns None when the current reading carries no power (power entity unavailable or in a non-power unit); it can no longer raise into the control cycle, /status or the MQTT values. - mode3 E and F are the card state "fault" (EN and NL). - chargersim gains fault(). Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -72,6 +72,10 @@ class SimCharger:
|
||||
def set_phases(self, n):
|
||||
self.phases_allowed = 3 if n == 3 else 1
|
||||
|
||||
def fault(self, letter="E"):
|
||||
"""mode3 E or F: the charger's own error states."""
|
||||
self.state, self.power_w = letter, 0.0
|
||||
|
||||
def go_unavailable(self, on=True):
|
||||
self.unavailable = bool(on)
|
||||
|
||||
@@ -90,6 +94,9 @@ class SimCharger:
|
||||
|
||||
def tick(self, seconds=1.0):
|
||||
for _ in range(int(max(1, round(seconds)))):
|
||||
if self.state in ("E", "F"): # a fault: nothing flows, it stays
|
||||
self.power_w = 0.0
|
||||
continue
|
||||
if self.state != "A":
|
||||
self.state = "C" if self.target_w() > 0 else "B"
|
||||
tgt = self.target_w()
|
||||
@@ -125,7 +132,7 @@ class SimCharger:
|
||||
st(f"sensor.{x}_mode3_state_socket_1", f"STATE_{self.state}"),
|
||||
st(f"sensor.{x}_display_state_socket_1",
|
||||
{"A": "Available", "B": "EV Connected",
|
||||
"C": "Charging Normal"}[self.state]),
|
||||
"C": "Charging Normal"}.get(self.state, "Error")),
|
||||
st(f"sensor.{x}_active_power_total_socket_1",
|
||||
f"{self.power_w:.0f}", "W"),
|
||||
st(f"sensor.{x}_meter_reading_socket_1", f"{self.kwh:.2f}",
|
||||
|
||||
Reference in New Issue
Block a user