unixorn/ha-mqtt-discoverable

[BUG] metric_name config is required but undocumented

mion00 opened this issue · 2 comments

Describe the bug
When creating a binary sensor the config dict must have a metric_name key, even if in the README there are no mentions of it.

To Reproduce
Create a binary sensor with the following config:

mysensor = BinarySensor(settings={
    "mqtt_server": "localhost",
    "client_name": "client",
    "mqtt_user": "user",
    "mqtt_password": "password",
    "mqtt_prefix": "homeassistant",

    "device_id": "test_device",
    "unique_id": "my_sensor",
    "device_name": "MySensor",
    "device_class": "motion",
})

We receive the following error:

  File "/home/mion00/.pyenv/versions/3.10.8/envs/hikvision-addon-sdk/lib/python3.10/site-packages/ha_mqtt_discoverable/sensors.py", line 16, in __init__
    self.metric_name = settings["metric_name"]
KeyError: 'metric_name'

Expected behavior
What is the meaning behind metric_name?

Deferring until after #15 is merged

metric_name wes removed with #15, and is no longer used in the code.