j9brown / victron-hacs

Home Assistant plug-in for Victron Instant Readout compatible devices
16 stars 6 forks source link

SmartSolar MPPT stop giving updates and becomes unavailable #3

Closed huafu closed 1 month ago

huafu commented 3 months ago

Version of the custom_component

Version 0.1.13

Configuration / description

All configuration has been done in the UI, I have a SmartShunt and a BlueSolar (with Victron VE to BLE module) which are working great. Only my new SmartSolar added yesterday seems to report correctly, but after some time the sensors' values don't change anymore, and finally it becomes unavailable. Restarting HA will make them come back.

Checked on BLE with Victron, BLE gatt get went correctly. I can't see any log in homeassistant.log, I'll try to see if I can add some debug and update this bug in such case.

huafu commented 3 months ago

I had to change the SmartSolar for a 150/35 one, and I am facing the same issue and even worst since after some time running HA, the device remains unavailable. Here are the log lines around the last line related to the device causing problems:

2024-08-07 22:09:40.587 DEBUG (MainThread) [custom_components.victron_ble.device] Parsing Victron BLE advertisement data: {737: b'\x01\xc3\x10\xb6Q\x98`\x0b\x06\x00\x00\x00\xfa\xf2\xc9\x1f'}
2024-08-07 22:09:40.589 DEBUG (MainThread) [custom_components.victron_ble.sensor] IN 2here: PassiveBluetoothDataUpdate(devices={None: {'name': 'SmartSolar', 'manufacturer': 'Victron', 'model': 'SmartSolar MPPT 150|35'}}, entity_descriptions={PassiveBluetoothEntityKey(key='power', device_id=None): SensorEntityDescription(key='power_W', device_class=<SensorDeviceClass.POWER: 'power'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.POWER_WATT: 'W'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='voltage', device_id=None): SensorEntityDescription(key='voltage_V', device_class=<SensorDeviceClass.VOLTAGE: 'voltage'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ELECTRIC_POTENTIAL_VOLT: 'V'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='current', device_id=None): SensorEntityDescription(key='current_A', device_class=<SensorDeviceClass.CURRENT: 'current'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ELECTRIC_CURRENT_AMPERE: 'A'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.YIELD_TODAY: 'yield_today'>, device_id=None): SensorEntityDescription(key=<VictronSensor.YIELD_TODAY: 'yield_today'>, device_class=<SensorDeviceClass.ENERGY: 'energy'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ENERGY_WATT_HOUR: 'Wh'>, options=None, state_class=<SensorStateClass.TOTAL_INCREASING: 'total_increasing'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.OPERATION_MODE: 'operation_mode'>, device_id=None): SensorEntityDescription(key=<VictronSensor.OPERATION_MODE: 'operation_mode'>, device_class=<SensorDeviceClass.ENUM: 'enum'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=None, options=['off', 'low_power', 'fault', 'bulk', 'absorption', 'float', 'storage', 'equalize_manual', 'inverting', 'power_supply', 'starting_up', 'repeated_absorption', 'recondition', 'battery_safe', 'active', 'external_control', 'not_available'], state_class=None, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='signal_strength', device_id=None): SensorEntityDescription(key='signal_strength_dBm', device_class=<SensorDeviceClass.SIGNAL_STRENGTH: 'signal_strength'>, entity_category=None, entity_registry_enabled_default=False, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT: 'dBm'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None)}, entity_names={PassiveBluetoothEntityKey(key='power', device_id=None): 'Power', PassiveBluetoothEntityKey(key='voltage', device_id=None): 'Voltage', PassiveBluetoothEntityKey(key='current', device_id=None): 'Current', PassiveBluetoothEntityKey(key=<VictronSensor.YIELD_TODAY: 'yield_today'>, device_id=None): 'Yield Today', PassiveBluetoothEntityKey(key=<VictronSensor.OPERATION_MODE: 'operation_mode'>, device_id=None): 'Operation Mode', PassiveBluetoothEntityKey(key='signal_strength', device_id=None): 'Signal Strength'}, entity_data={PassiveBluetoothEntityKey(key='power', device_id=None): 0, PassiveBluetoothEntityKey(key='voltage', device_id=None): 26.25, PassiveBluetoothEntityKey(key='current', device_id=None): 0.0, PassiveBluetoothEntityKey(key=<VictronSensor.YIELD_TODAY: 'yield_today'>, device_id=None): 2440, PassiveBluetoothEntityKey(key=<VictronSensor.OPERATION_MODE: 'operation_mode'>, device_id=None): 'off', PassiveBluetoothEntityKey(key='signal_strength', device_id=None): -100})
2024-08-07 22:10:21.449 DEBUG (MainThread) [custom_components.victron_ble.device] Parsing Victron BLE advertisement data: {737: b'\x10\x02\x89\xa3\x02\xed\x97^?1\x87j\xbc\xbf\xc2\xe8yg\xcf\xcf\x9c@\xad'}
2024-08-07 22:10:21.452 DEBUG (MainThread) [custom_components.victron_ble.device] Handle Victron BLE advertisement data: {'remaining_mins': 3875, 'aux_mode': <AuxMode.MIDPOINT_VOLTAGE: 1>, 'current': -4.986, 'voltage': 26.29, 'consumed_ah': -13.9, 'soc': 96.4, 'alarm': <AlarmReason.NO_ALARM: 0>, 'midpoint_voltage': 13.14}
2024-08-07 22:10:21.455 DEBUG (MainThread) [custom_components.victron_ble.sensor] IN 2here: PassiveBluetoothDataUpdate(devices={None: {'name': 'Smart Shunt', 'manufacturer': 'Victron', 'model': 'SmartShunt 500A/50mV'}}, entity_descriptions={PassiveBluetoothEntityKey(key='voltage', device_id=None): SensorEntityDescription(key='voltage_V', device_class=<SensorDeviceClass.VOLTAGE: 'voltage'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ELECTRIC_POTENTIAL_VOLT: 'V'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='current', device_id=None): SensorEntityDescription(key='current_A', device_class=<SensorDeviceClass.CURRENT: 'current'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ELECTRIC_CURRENT_AMPERE: 'A'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='battery', device_id=None): SensorEntityDescription(key='battery_%', device_class=<SensorDeviceClass.BATTERY: 'battery'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.PERCENTAGE: '%'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.TIME_REMAINING: 'time_remaining'>, device_id=None): SensorEntityDescription(key=<VictronSensor.TIME_REMAINING: 'time_remaining'>, device_class=<SensorDeviceClass.DURATION: 'duration'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.TIME_MINUTES: 'min'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.CONSUMED: 'consumed'>, device_id=None): SensorEntityDescription(key=<VictronSensor.CONSUMED: 'consumed'>, device_class=None, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement='Ah', options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.ALARM_REASON: 'alarm_reason'>, device_id=None): SensorEntityDescription(key=<VictronSensor.ALARM_REASON: 'alarm_reason'>, device_class=None, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=None, options=None, state_class=None, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.AUX_MODE: 'aux_mode'>, device_id=None): SensorEntityDescription(key=<VictronSensor.AUX_MODE: 'aux_mode'>, device_class=<SensorDeviceClass.ENUM: 'enum'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=None, options=['starter_voltage', 'midpoint_voltage', 'temperature', 'disabled'], state_class=None, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key=<VictronSensor.MIDPOINT_VOLTAGE: 'midpoint_voltage'>, device_id=None): SensorEntityDescription(key=<VictronSensor.MIDPOINT_VOLTAGE: 'midpoint_voltage'>, device_class=<SensorDeviceClass.VOLTAGE: 'voltage'>, entity_category=None, entity_registry_enabled_default=True, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.ELECTRIC_POTENTIAL_VOLT: 'V'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None), PassiveBluetoothEntityKey(key='signal_strength', device_id=None): SensorEntityDescription(key='signal_strength_dBm', device_class=<SensorDeviceClass.SIGNAL_STRENGTH: 'signal_strength'>, entity_category=None, entity_registry_enabled_default=False, entity_registry_visible_default=True, force_update=False, icon=None, has_entity_name=False, name=<UndefinedType._singleton: 0>, translation_key=None, translation_placeholders=None, unit_of_measurement=None, last_reset=None, native_unit_of_measurement=<Units.SIGNAL_STRENGTH_DECIBELS_MILLIWATT: 'dBm'>, options=None, state_class=<SensorStateClass.MEASUREMENT: 'measurement'>, suggested_display_precision=None, suggested_unit_of_measurement=None)}, entity_names={PassiveBluetoothEntityKey(key='voltage', device_id=None): 'Voltage', PassiveBluetoothEntityKey(key='current', device_id=None): 'Current', PassiveBluetoothEntityKey(key='battery', device_id=None): 'Battery', PassiveBluetoothEntityKey(key=<VictronSensor.TIME_REMAINING: 'time_remaining'>, device_id=None): 'Time remaining', PassiveBluetoothEntityKey(key=<VictronSensor.CONSUMED: 'consumed'>, device_id=None): 'Consumed', PassiveBluetoothEntityKey(key=<VictronSensor.ALARM_REASON: 'alarm_reason'>, device_id=None): 'Alarm', PassiveBluetoothEntityKey(key=<VictronSensor.AUX_MODE: 'aux_mode'>, device_id=None): 'Auxilliary Input Mode', PassiveBluetoothEntityKey(key=<VictronSensor.MIDPOINT_VOLTAGE: 'midpoint_voltage'>, device_id=None): 'Midpoint Voltage', PassiveBluetoothEntityKey(key='signal_strength', device_id=None): 'Signal Strength'}, entity_data={PassiveBluetoothEntityKey(key='voltage', device_id=None): 26.29, PassiveBluetoothEntityKey(key='current', device_id=None): -4.99, PassiveBluetoothEntityKey(key='battery', device_id=None): 96.4, PassiveBluetoothEntityKey(key=<VictronSensor.TIME_REMAINING: 'time_remaining'>, device_id=None): 3875, PassiveBluetoothEntityKey(key=<VictronSensor.CONSUMED: 'consumed'>, device_id=None): -13.9, PassiveBluetoothEntityKey(key=<VictronSensor.ALARM_REASON: 'alarm_reason'>, device_id=None): 'no_alarm', PassiveBluetoothEntityKey(key=<VictronSensor.AUX_MODE: 'aux_mode'>, device_id=None): 'midpoint_voltage', PassiveBluetoothEntityKey(key=<VictronSensor.MIDPOINT_VOLTAGE: 'midpoint_voltage'>, device_id=None): 13.14, PassiveBluetoothEntityKey(key='signal_strength', device_id=None): -73})

I also have a SmartShunt as you can see, and no issue with it. The device is very close to the RPi running HA, and the solar charger is broadcasting GATT. Screenshot_20240808-043813~2 (It's night so it's normal the zeros)

wutu commented 3 months ago

I have same problem with SmartSolar 100|50.

huafu commented 3 months ago

Just got a 150/45 Smart Solar and while it has worked perfectly for 24 hours, it is now starting to have the same issues as the 2 others I had previously... The BLE attrs are sent, it's definitely not a Victron' side issue. Nothing in the log which can help badly. I've tried with victron2mqtt and ESPHome victron_ble, both do work correctly but I'd like to avoid using multiple external tools

j9brown commented 1 month ago

Is this still an issue? If so, please take a closer look at your Home Assistant logs and try to locate any errors or exceptions that might be related. I didn't see anything unusual in the log snippet that you included above.

For what it's worth, this integration has been working reliably for my 100|50 Smart Solar. It's possible that yours occasionally emits data that the parser can't handle. Perhaps some flags. Assuming the integration is crashing, the reason should become obvious given the exception and stack trace.

huafu commented 1 month ago

Hi @j9brown thanks for your answer. I actually tried victron-ble on my hardware (a Raspberry Pi 4) and on my computer. Of course at the time of the test it was reliable. So I restarted HA and all is reliable... Will try to catch when there is no readout and stop HA, run the victron-ble CLI on RPi and my laptop to see if there is any diff. But your integration never crashed nor reported any error...

huafu commented 1 month ago

Hi again @j9brown. I found the source of the issue. I do have some ESP32 which are acting as BT proxy using ESPHome:

  bluetooth_proxy:
    active: True
    cache_services: True

They are a bit far from the Victron units. Tho the RPi itself running HA and your integration is close to the Victron devices. I tried to disable all BT proxies, restarted HA, and the updates were very fluid during more than 24h. Now I've moved one ESP32 close to the Victron devices and re-enabled the past config. All is working fluently. So I believe that HA do not use the BT device where it is when there is at least one BT proxy (but can't make any verification other than the one I've made).

So at the end it was a distance from device issue.

For others, ensure you do not have any ESPHome BT proxy on your network, or bring one closer to your Victron device(s). Having one BLE proxy seems to make HA NOT use the internal BT hardware...

huafu commented 1 month ago

Before moving an ESPHome acting as a BT BLE proxy as close as where the RPi with HA is installed: image

After: image