Display MQTT debug info#5375
Merged
bramkragten merged 14 commits intohome-assistant:devfrom Apr 22, 2020
Merged
Conversation
balloob
reviewed
Mar 31, 2020
balloob
reviewed
Mar 31, 2020
balloob
reviewed
Mar 31, 2020
balloob
reviewed
Mar 31, 2020
balloob
reviewed
Mar 31, 2020
balloob
reviewed
Mar 31, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
zsarnett
reviewed
Apr 3, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
bramkragten
reviewed
Apr 15, 2020
Co-Authored-By: Zack Arnett <arnett.zackary@gmail.com>
67efae9 to
b46efef
Compare
bramkragten
reviewed
Apr 17, 2020
| @property() private _showTopic = false; | ||
|
|
||
| protected firstUpdated(): void { | ||
| this._payloadsJson = new Array(this.messages.length); |
Member
There was a problem hiding this comment.
Use a WeakMap instead of an Array
bramkragten
reviewed
Apr 17, 2020
| ? html` | ||
| <ul> | ||
| ${this.messages.map( | ||
| (_, i) => html` |
Member
There was a problem hiding this comment.
Suggested change
| (_, i) => html` | |
| (message) => html` |
bramkragten
reviewed
Apr 17, 2020
| ${this.messages.map( | ||
| (_, i) => html` | ||
| <li> | ||
| ${this._renderSingleMessage(i)} |
Member
There was a problem hiding this comment.
Suggested change
| ${this._renderSingleMessage(i)} | |
| ${this._renderSingleMessage(message)} |
bramkragten
reviewed
Apr 17, 2020
| `; | ||
| } | ||
|
|
||
| private _renderSingleMessage(i: number): TemplateResult { |
Member
There was a problem hiding this comment.
Suggested change
| private _renderSingleMessage(i: number): TemplateResult { | |
| private _renderSingleMessage(message): TemplateResult { |
bramkragten
reviewed
Apr 17, 2020
| } | ||
|
|
||
| private _renderSingleMessage(i: number): TemplateResult { | ||
| const topic = this.messages[i].topic; |
Member
There was a problem hiding this comment.
Suggested change
| const topic = this.messages[i].topic; | |
| const topic = message.topic; |
bramkragten
reviewed
Apr 17, 2020
| Topic: ${topic} | ||
| </li> | ||
| <li> | ||
| Payload: ${this._renderSinglePayload(i)} |
Member
There was a problem hiding this comment.
Suggested change
| Payload: ${this._renderSinglePayload(i)} | |
| Payload: ${this._renderSinglePayload(message)} |
bramkragten
reviewed
Apr 17, 2020
| </li> | ||
| </ul> | ||
| ` | ||
| : this._renderSinglePayload(i); |
Member
There was a problem hiding this comment.
Suggested change
| : this._renderSinglePayload(i); | |
| : this._renderSinglePayload(message); |
bramkragten
reviewed
Apr 17, 2020
| : this._renderSinglePayload(i); | ||
| } | ||
|
|
||
| private _renderSinglePayload(i: number): TemplateResult { |
Member
There was a problem hiding this comment.
Suggested change
| private _renderSinglePayload(i: number): TemplateResult { | |
| private _renderSinglePayload(message): TemplateResult { |
bramkragten
reviewed
Apr 17, 2020
Comment on lines
+79
to
+81
| if (this._payloadsJson && this._payloadsJson[i] === undefined) { | ||
| this._payloadsJson[i] = this._tryParseJson(this.messages[i].payload); | ||
| } |
Member
There was a problem hiding this comment.
Move this below the check for this.showDeserialized
bramkragten
reviewed
Apr 17, 2020
|
|
||
| private _renderSinglePayload(i: number): TemplateResult { | ||
| if (this._payloadsJson && this._payloadsJson[i] === undefined) { | ||
| this._payloadsJson[i] = this._tryParseJson(this.messages[i].payload); |
Member
There was a problem hiding this comment.
let json;
if (!this._payloadsJson.has(message)) {
json = this._tryParseJson(message.payload);
this._payloadsJson.set(message, json);
} else {
json = this._payloadsJson.get(message);
}
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change
Proposed change
Display MQTT debug info
Screenshots:

Showing recent messages, maybe timestamps should be added:

MQTT Discovery payload and subsribed topic payload can be displayed as JSON:

or as YAML:

Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: