bachya / ecowitt2mqtt

Send data from Fine Offset weather stations (Ecowitt, Ambient Weather, Froggit, etc.) to MQTT!
MIT License
219 stars 46 forks source link

Exception in async_discover when dispatching 'mqtt_discovery_new_binary_sensor_mqtt' #86

Closed VictorvandenHoven closed 3 years ago

VictorvandenHoven commented 3 years ago

ecowitt2mqtt version 2.0.0-2

Describe the bug I get in logging of Home Assistant a lot (>100 per hour) of "Exception in async_discover when dispatching 'mqtt_discovery_new_binary_sensor_mqtt'" errors for my "MISOL/1 wireless soil moisture sensor" that talks to the GW1000. It concerns only the battery values of the device, other values are working well.

To Reproduce Steps to reproduce the behavior:

  1. Install Ecowitt addon in HA
  2. Connect MISOL wireless soil moisture sensor to the GW1000 device
  3. Custom-connect the GW1000 device to Ecowitt-server
  4. Go to 'logging in HA'
  5. See error

Expected behavior I would expect the battery values to be visible in the HA-overview dashboard, just like the other senor values

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Full error message:

Logger: homeassistant.util.logging
Source: util/logging.py:105
First occurred: 0:54:02 (1058 occurrences)
Last logged: 9:57:58

Exception in async_discover when dispatching 'mqtt_discovery_new_binary_sensor_mqtt': ({'availability_topic': 'homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt1/availability', 'device': {'identifiers': ['4D7BAAD014504FDF81FE3ED4C86A3EA2'], 'manufacturer': 'Ecowitt', 'model': 'GW1000 Pro', 'name': 'GW1000 Pro', 'sw_version': 'GW1000_V1.6.8'}, 'name': 'soilbatt1', 'qos': 1, 'state_topic': 'homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt1/state', 'unique_id': '4D7BAAD014504FDF81FE3ED4C86A3EA2_soilbatt1', 'device_class': 'battery', 'unit_of_measurement': 'v', 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 180, in async_discover config = schema(discovery_payload) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data['unit_of_measurement']
Exception in async_discover when dispatching 'mqtt_discovery_new_binary_sensor_mqtt': ({'availability_topic': 'homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt2/availability', 'device': {'identifiers': ['4D7BAAD014504FDF81FE3ED4C86A3EA2'], 'manufacturer': 'Ecowitt', 'model': 'GW1000 Pro', 'name': 'GW1000 Pro', 'sw_version': 'GW1000_V1.6.8'}, 'name': 'soilbatt2', 'qos': 1, 'state_topic': 'homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt2/state', 'unique_id': '4D7BAAD014504FDF81FE3ED4C86A3EA2_soilbatt2', 'device_class': 'battery', 'unit_of_measurement': 'v', 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 180, in async_discover config = schema(discovery_payload) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 272, in __call__ return self._compiled([], data) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.9/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: extra keys not allowed @ data['unit_of_measurement']

config-part of Message on the MQTT-topic: {"availability_topic": "homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt1/availability", "device": {"identifiers": ["4D7BAAD014504FDF81FE3ED4C86A3EA2"], "manufacturer": "Ecowitt", "model": "GW1000 Pro", "name": "GW1000 Pro", "sw_version": "GW1000_V1.6.8"}, "name": "soilbatt1", "qos": 1, "state_topic": "homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/soilbatt1/state", "unique_id": "4D7BAAD014504FDF81FE3ED4C86A3EA2_soilbatt1", "device_class": "battery", "unit_of_measurement": "v"}

VictorvandenHoven commented 3 years ago

I am not sure why the message is published to the "homeassistant/binary_sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/ topic. When I publish it (by hand) to the "homeassistant/sensor/4D7BAAD014504FDF81FE3ED4C86A3EA2/topic and add some state and availability values, it seems to work well.

VictorvandenHoven commented 3 years ago

It must have something to do with this

commit

bachya commented 3 years ago

In your case, binary_sensor is selected because soilbatt1 has been identified as a "binary battery" (0 is OK, 1 is low). In that case, the inclusion of the v unit is now making HASS complain.

I'm on it!

VictorvandenHoven commented 3 years ago

In your case, binary_sensor is selected because soilbatt1 has been identified as a "binary battery" (0 is OK, 1 is low). In that case, the inclusion of the v unit is now making HASS complain.

I'm on it!

Thanks very much!