Skip to content

Commit 2c43d93

Browse files
committed
Improve logging
1 parent cb71433 commit 2c43d93

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

custom_components/nmea2000/NMEA2000Sensor.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ def __init__(
5656
else:
5757
self._available = True
5858

59+
def __str__(self) -> str:
60+
return f"NMEA2000Sensor(name={self._attr_name}, state={self._attr_native_value}, unit={self._attr_native_unit_of_measurement}, device={self._device_name}, via_device={self._via_device}, manufacturer={self._manufacturer}, friendly_name={self._attr_friendly_name}, )"
61+
62+
def __repr__(self) -> str:
63+
return self.__str__()
64+
5965
@property
6066
def native_value(self):
6167
"""Return the state of the sensor."""
@@ -112,7 +118,7 @@ def set_state(self, new_state, ignore_tracing = False):
112118
if new_state != old_state:
113119
# Since the state is valid, update the sensor's state
114120
if not ignore_tracing:
115-
_LOGGER.info("Setting state for sensor: '%s' to %s", self.entity_id, new_state)
121+
_LOGGER.debug("Setting state for sensor: '%s' to %s from %s", self.entity_id, new_state, old_state)
116122
should_update = True
117123

118124
if should_update:

custom_components/nmea2000/hub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,6 @@ async def receive_callback(self, message: NMEA2000Message) -> None:
406406
# Check for sensor existence and create/update accordingly
407407
sensor = self.sensors.get(sensor_id)
408408
if sensor is None:
409-
_LOGGER.info("Creating new sensor for %s", sensor_id)
410-
411409
# Create new sensor
412410
sensor = NMEA2000Sensor(
413411
id=sensor_id,
@@ -420,6 +418,8 @@ async def receive_callback(self, message: NMEA2000Message) -> None:
420418
ttl=message.ttl,
421419
manufacturer=str(message.source_iso_name)
422420
)
421+
_LOGGER.info("Created new sensor for %s: %s, source: %s, destination: %s, source_iso_name: %s, hash: %s, fields: %s", sensor_id, sensor, message.source, message.destination, message.source_iso_name, message.hash, field)
422+
423423
self.async_add_entities([sensor])
424424
self.sensors[sensor_id] = sensor
425425
else:

custom_components/nmea2000/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"iot_class": "local_push",
1212
"issue_tracker": "https://github.com/tomer-w/ha-nmea2000/issues",
1313
"requirements": [
14-
"nmea2000==2025.10.4"
14+
"nmea2000==2025.10.5"
1515
],
16-
"version": "2025.10.1"
16+
"version": "2025.10.2"
1717
}

0 commit comments

Comments
 (0)