Only report invalid numeric value for sensors once (#87010)

This commit is contained in:
Franck Nijhof 2023-01-31 12:44:18 +01:00 committed by GitHub
parent 35b82db8b0
commit 4dba9c09fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -599,21 +599,22 @@ class SensorEntity(Entity):
f"({type(value)})" f"({type(value)})"
) from err ) from err
# This should raise in Home Assistant Core 2023.4 # This should raise in Home Assistant Core 2023.4
self._invalid_numeric_value_reported = True if not self._invalid_numeric_value_reported:
report_issue = self._suggest_report_issue() self._invalid_numeric_value_reported = True
_LOGGER.warning( report_issue = self._suggest_report_issue()
"Sensor %s has device class %s, state class %s and unit %s " _LOGGER.warning(
"thus indicating it has a numeric value; however, it has the " "Sensor %s has device class %s, state class %s and unit %s "
"non-numeric value: %s (%s); Please update your configuration " "thus indicating it has a numeric value; however, it has the "
"if your entity is manually configured, otherwise %s", "non-numeric value: %s (%s); Please update your configuration "
self.entity_id, "if your entity is manually configured, otherwise %s",
device_class, self.entity_id,
state_class, device_class,
unit_of_measurement, state_class,
value, unit_of_measurement,
type(value), value,
report_issue, type(value),
) report_issue,
)
return value return value
else: else:
numerical_value = value numerical_value = value