Custom Configuration Errors

Good afternoon,
I’m seeing errors in my logs for Honeywell Lyric My custom configuration. I’ve posted the errors on the developer’s github site, but I’m not sure how active the developer is.

Logger: homeassistant.components.sensor
Source: components/sensor/init.py:729
integration: Sensor (documentation, issues)
First occurred: 7:23:12 AM (10 occurrences)
Last logged: 10:22:46 AM

Entity sensor.basement_water_leak_detector_basement_battery (<class 'custom_components.lyric_my.sensor.LyricLeakSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('battery') it is using; expected one of ['%']; Please update your configuration if your entity is manually configured, otherwise report it to the author of the 'lyric_my' custom integration
Entity sensor.basement_water_leak_detector_basement_wifi (<class 'custom_components.lyric_my.sensor.LyricLeakSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('signal_strength') it is using; expected one of ['dB', 'dBm']; Please update your configuration if your entity is manually configured, otherwise report it to the author of the 'lyric_my' custom integration
Entity sensor.laundry_room_water_leak_detector_laundry_room_battery_2 (<class 'custom_components.lyric_my.sensor.LyricLeakSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('battery') it is using; expected one of ['%']; Please update your configuration if your entity is manually configured, otherwise report it to the author of the 'lyric_my' custom integration
Entity sensor.laundry_room_water_leak_detector_laundry_room_wifi_2 (<class 'custom_components.lyric_my.sensor.LyricLeakSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('signal_strength') it is using; expected one of ['dB', 'dBm']; Please update your configuration if your entity is manually configured, otherwise report it to the author of the 'lyric_my' custom integration

I know I should be able to edit the code in the custom configuration folder for the sensor.py file, but I’m not sure what I need to change based upon the errors I’m seeing (not a developer, but I do IT work for a living).

I found these entries in the sensor.py config file for the integration:

    LyricSensorEntityDescription(
        key="Battery",
        translation_key="battery",
        device_class=SensorDeviceClass.BATTERY,
        state_class=SensorStateClass.MEASUREMENT,
        value_fn=lambda device: device.attributes.get("batteryRemaining"),
        suitable_fn=lambda device: device.attributes.get("batteryRemaining"),
    ),
    LyricSensorEntityDescription(
        key="WiFi",
        translation_key="wifi",
        device_class=SensorDeviceClass.SIGNAL_STRENGTH,
        state_class=SensorStateClass.MEASUREMENT,
        value_fn=lambda device: abs(device.attributes.get("wifiSignalStrength")),
        suitable_fn=lambda device: abs(device.attributes.get("wifiSignalStrength")),
    ),

Can anybody advise how to fix the errors?

I guess this is a custom component?
Take example on the official integration, e.g.

It was an offshoot of the official component for their leak detectors. The official Lyric integration doesn’t work with HA, so a developer did an offshoot and came up with this solution.

Thanks. I’ll give that a shot and see if the error goes away.

Okay, adding the line with PERCENTAGE worked for Battery, but I've been trying to add dBm or dB for WiFi signal stregth, and it's not working.

Logger: homeassistant.loader
Source: loader.py:1275
First occurred: 10:27:39 AM (2 occurrences)
Last logged: 10:27:39 AM

Unexpected exception importing platform custom_components.lyric_my.sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1275, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1307, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 201, in protected_loop_func
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/lyric_my/sensor.py", line 205, in <module>
    native_unit_of_measurement=dB,
                               ^^
NameError: name 'dB' is not defined

This reference seems to indcate either one of those should be used, but it also just says “%” for the Battery class, and I needed to use PERECENTAGE.

    LyricSensorEntityDescription(
        key="Battery",
        translation_key="battery",
        device_class=SensorDeviceClass.BATTERY,
        state_class=SensorStateClass.MEASUREMENT,
        native_unit_of_measurement=PERCENTAGE,
        value_fn=lambda device: device.attributes.get("batteryRemaining"),
        suitable_fn=lambda device: device.attributes.get("batteryRemaining"),
    ),
    LyricSensorEntityDescription(
        key="WiFi",
        translation_key="wifi",
        device_class=SensorDeviceClass.SIGNAL_STRENGTH,
        state_class=SensorStateClass.MEASUREMENT,
        native_unit_of_measurement=dB,
        value_fn=lambda device: abs(device.attributes.get("wifiSignalStrength")),
        suitable_fn=lambda device: abs(device.attributes.get("wifiSignalStrength")),
    ),

See core/homeassistant/const.py at 88c4d88e06556ba034d6d62b8c7db3c5e06b9813 · home-assistant/core · GitHub for the list of contants.

You can use strings, but then they have to be between double quotes.