Skip to content

Load balancer stops working on startup if P1IB sensor values (MQTT based) are unavailable #69

@Ventilgummi

Description

@Ventilgummi

When I reboot my server and all my containers (including home assistant and MQTT), the EVSE load balancer seems to expect immediate readings from the P1IB smart‑meter integration.
Because the P1IB only publishes telegrams every ~10 s and Mosquitto/HA may not be fully started yet, the entities used by the load balancer (e.g. sensor.p1ib_active_power_plus_l1) return unavailable at startup. The integration logs show warnings such as:

"Available current for phase 'l1' is None.Cannot proceed with balancing cycle."

Missing states for one of phase Phase.L1: consumption: None, production: None. Are the entities enabled?
Missing states for one of phase Phase.L2: consumption: None, production: None. Are the entities enabled?
Missing states for one of phase Phase.L3: consumption: None, production: None. Are the entities enabled?

Failed to parse state unavailable for entity sensor.p1ib_active_power_minus_l2: could not convert string to float: 'unavailable'
Failed to parse state unavailable for entity sensor.p1ib_voltage_l2: could not convert string to float: 'unavailable'
Failed to parse state unavailable for entity sensor.p1ib_active_power_plus_l3: could not convert string to float: 'unavailable'
Failed to parse state unavailable for entity sensor.p1ib_active_power_minus_l3: could not convert string to float: 'unavailable'
Failed to parse state unavailable for entity sensor.p1ib_voltage_l3: could not convert string to float: 'unavailable'
Traceback (most recent call last):
File "/config/custom_components/evse_load_balancer/meters/custom_meter.py", line 87, in _get_state
return float(state_value)
ValueError: could not convert string to float: 'unavailable'

These messages come from the CustomMeter implementation, which I believe returns None when the consumption or voltage sensor states are missing.

Expected behavior:
If the EVSE load balancer starts before the P1IB publishes its first reading, it should either use the last known reading or wait for valid sensor data before starting the balancing loop. The EVSE should not stop working because of a brief unavailable state.

Actual behavior:
On startup, the EVSE load balancer attempts to read the P1IB entities, finds them unavailable, logs multiple warnings about missing states, and then stops balancing until I manually reload the integration or restart HA. This happens consistently whenever HA or the container is restarted.

Huge thanks for the work on this load balancer, when it's working it's working great! In essence I guess it my fault that it's not working as intended since I reboot my server with crontab and automate updates via watchtower...

Let me know if you need any more debug logs etc!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions