Skip to content

Commit 68d3ba6

Browse files
committed
Fix tracing issue
1 parent 7631131 commit 68d3ba6

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

custom_components/victron_mqtt/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
_LOGGER = logging.getLogger(__name__)
20+
_VICTRON_MQTT_LOGGER = logging.getLogger("victron_mqtt")
2021

2122
# Config schema - this integration is config entry only
2223
CONFIG_SCHEMA = cv.config_entry_only_config_schema(DOMAIN)
@@ -39,10 +40,17 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
3940

4041
return True
4142

43+
def _sync_library_logging():
44+
"""Sync the log level of the library to match integration logging."""
45+
lib_level = _LOGGER.getEffectiveLevel()
46+
_VICTRON_MQTT_LOGGER.setLevel(lib_level)
47+
_VICTRON_MQTT_LOGGER.propagate = True # Let it go through HA logging
48+
4249
async def async_setup_entry(
4350
hass: HomeAssistant, entry: ConfigEntry
4451
) -> bool:
4552
"""Set up victronvenus from a config entry."""
53+
_sync_library_logging()
4654

4755
hub = Hub(hass, entry)
4856
await hub.start()

custom_components/victron_mqtt/hub.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,7 @@ def __init__(
163163
def __repr__(self) -> str:
164164
"""Return a string representation of the sensor."""
165165
return (
166-
f"VictronSwitch(device={self._device.name}, "
167-
f"metric={self._switch.short_id}, "
168-
f"translation_key={self._attr_translation_key}, "
169-
f"value={self._attr_native_value})"
166+
f"VictronSwitch({super().__repr__()}, is_on={self._attr_is_on})"
170167
)
171168

172169
async def _on_update_task(self, metric: VictronVenusMetric):
@@ -205,7 +202,7 @@ def __init__(
205202

206203
def __repr__(self) -> str:
207204
"""Return a string representation of the sensor."""
208-
return f"VictronNumber({super().__repr__()})"
205+
return f"VictronNumber({super().__repr__()}, native_value={self._attr_native_value})"
209206

210207
async def _on_update_task(self, metric: VictronVenusMetric):
211208
self._attr_native_value = metric.value
@@ -263,7 +260,7 @@ def __init__(
263260

264261
def __repr__(self) -> str:
265262
"""Return a string representation of the sensor."""
266-
return f"VictronSelect({super().__repr__()})"
263+
return f"VictronSelect({super().__repr__()}, current_option={self._attr_current_option}, options={self._attr_options})"
267264

268265
async def _on_update_task(self, metric: VictronVenusMetric):
269266
self._attr_current_option = self._map_value_to_state(metric.value)

custom_components/victron_mqtt/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
"X_MqttOnLan": "1"
2020
}
2121
],
22-
"version": "2025.7.13"
22+
"version": "2025.7.14"
2323
}

0 commit comments

Comments
 (0)