Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mqtt.homeassistant] Discovery exceptions processing #11315

Merged
merged 1 commit into from
Oct 24, 2021

Conversation

antroids
Copy link
Contributor

[mqtt.homeassistant] Discovery exceptions processing

Noticed that exceptions in mqtt message handlers are not processed properly during discovery and even not added to logs.
Mqtt transport implementation doesn't have an information about how to process exceptions, and not handling them.
org.openhab.core.io.transport.mqtt.MqttMessageSubscriber#processMessage

Added exceptions types for component config errors and added exceptions processing to mqtt handlers.
I think the bug could be closed after PR: #11085

Can be reproduced by sending invalid JSON to homeassistant discovery */config topic, for example:
mosquitto_pub -h 127.0.0.1 -p 1883 -t homeassistant/sensor/R5EE70BB9_N321346B4/config -m '{"~":"Bedroom/BME280","dev_cla":"temperature","name":"Bedroom Temperature","stat_t":"~state","unit_of_meas":"°C","json_attributes_topic":"~state","val_tpl":"{{ value_json.temperature }}","uniq_id":"R5EE70BB9_N321346B4","avty_t":"~status","pl_avail":"Online","pl_not_avail":"Offline","device":{"identifiers":["R5EE70BB9"],"connections":["mac","00155D009500"],"name":"BME280 Bedroom"}}'

Before PR there are no messages in the log.
After PR:
15:03:24.623 [WARN ] [rnal.discovery.HomeAssistantDiscovery] - HomeAssistant discover error: Cannot parse JSON array. Each connection must be defined as array with two elements: connection_type, connection identifier. For example: "connections": [["mac", "02:5b:26:a8:dc:12"]]

…omponents discovery

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
@Skinah Skinah added the bug An unexpected problem or unintended behavior of an add-on label Oct 2, 2021
@wborn wborn added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Oct 10, 2021
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

You are quite active on the mqtt.homeassistant binding. If you want to, you could add yourself as the codeowner in the CODEOWNERS file.
@davidgraeff doesn't seem to be active anymore.

@fwolter fwolter merged commit ce61044 into openhab:main Oct 24, 2021
@fwolter fwolter added this to the 3.2 milestone Oct 24, 2021
dschoepel pushed a commit to dschoepel/openhab-addons that referenced this pull request Nov 9, 2021
…omponents discovery (openhab#11315)

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
Signed-off-by: Dave J Schoepel <dave@theschoepels.com>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/broken-homeassistant-mqtt-discovery/125102/15

NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Dec 30, 2021
…omponents discovery (openhab#11315)

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
…omponents discovery (openhab#11315)

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
volkmarnissen pushed a commit to volkmarnissen/openhab-addons that referenced this pull request Mar 3, 2022
…omponents discovery (openhab#11315)

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…omponents discovery (openhab#11315)

Signed-off-by: Anton Kharuzhy <publicantroids@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants