mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Move MQTT dev tools to integrations (#6189)
This commit is contained in:
parent
d8f530f8ac
commit
ed0e8c5e8d
@ -8,15 +8,18 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { computeStateName } from "../../common/entity/compute_state_name";
|
||||
import "../../components/ha-dialog";
|
||||
import "../../components/ha-switch";
|
||||
import "../../components/ha-formfield";
|
||||
import type { HaSwitch } from "../../components/ha-switch";
|
||||
import { computeDeviceName } from "../../data/device_registry";
|
||||
import { fetchMQTTDebugInfo, MQTTDeviceDebugInfo } from "../../data/mqtt";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { computeStateName } from "../../../../../../common/entity/compute_state_name";
|
||||
import "../../../../../../components/ha-dialog";
|
||||
import "../../../../../../components/ha-switch";
|
||||
import "../../../../../../components/ha-formfield";
|
||||
import type { HaSwitch } from "../../../../../../components/ha-switch";
|
||||
import { computeDeviceName } from "../../../../../../data/device_registry";
|
||||
import {
|
||||
fetchMQTTDebugInfo,
|
||||
MQTTDeviceDebugInfo,
|
||||
} from "../../../../../../data/mqtt";
|
||||
import { haStyleDialog } from "../../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../../types";
|
||||
import "./mqtt-discovery-payload";
|
||||
import "./mqtt-messages";
|
||||
import { MQTTDeviceDebugInfoDialogParams } from "./show-dialog-mqtt-device-debug-info";
|
||||
@ -187,19 +190,19 @@ class DialogMQTTDeviceDebugInfo extends LitElement {
|
||||
<li class="triggerlistitem">
|
||||
MQTT discovery data:
|
||||
<ul class="discoverydata">
|
||||
<li>
|
||||
Topic:
|
||||
<code>${trigger.discovery_data.topic}</code>
|
||||
</li>
|
||||
<li>
|
||||
<mqtt-discovery-payload
|
||||
.hass=${this.hass}
|
||||
.payload=${trigger.discovery_data.payload}
|
||||
.showAsYaml=${this._showAsYaml}
|
||||
.summary=${"Payload"}
|
||||
>
|
||||
</li>
|
||||
</mqtt-discovery-payload>
|
||||
<li>
|
||||
Topic:
|
||||
<code>${trigger.discovery_data.topic}</code>
|
||||
</li>
|
||||
<li>
|
||||
<mqtt-discovery-payload
|
||||
.hass=${this.hass}
|
||||
.payload=${trigger.discovery_data.payload}
|
||||
.showAsYaml=${this._showAsYaml}
|
||||
.summary=${"Payload"}
|
||||
>
|
||||
</mqtt-discovery-payload>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
`
|
@ -7,12 +7,12 @@ import {
|
||||
TemplateResult,
|
||||
css,
|
||||
} from "lit-element";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
import { removeMQTTDeviceEntry } from "../../../../../data/mqtt";
|
||||
import { showConfirmationDialog } from "../../../../../dialogs/generic/show-dialog-box";
|
||||
import { showMQTTDeviceDebugInfoDialog } from "../../../../../dialogs/mqtt-device-debug-info-dialog/show-dialog-mqtt-device-debug-info";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||
import { removeMQTTDeviceEntry } from "../../../../../../data/mqtt";
|
||||
import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box";
|
||||
import { showMQTTDeviceDebugInfoDialog } from "./show-dialog-mqtt-device-debug-info";
|
||||
import { haStyle } from "../../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../../types";
|
||||
|
||||
@customElement("ha-device-actions-mqtt")
|
||||
export class HaDeviceActionsMqtt extends LitElement {
|
@ -9,9 +9,9 @@ import {
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { classMap } from "lit-html/directives/class-map";
|
||||
import { formatTimeWithSeconds } from "../../common/datetime/format_time";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { MQTTMessage } from "../../data/mqtt";
|
||||
import { formatTimeWithSeconds } from "../../../../../../common/datetime/format_time";
|
||||
import { HomeAssistant } from "../../../../../../types";
|
||||
import { MQTTMessage } from "../../../../../../data/mqtt";
|
||||
|
||||
@customElement("mqtt-messages")
|
||||
class MQTTMessages extends LitElement {
|
@ -1,5 +1,5 @@
|
||||
import { fireEvent } from "../../common/dom/fire_event";
|
||||
import { DeviceRegistryEntry } from "../../data/device_registry";
|
||||
import { fireEvent } from "../../../../../../common/dom/fire_event";
|
||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||
|
||||
export interface MQTTDeviceDebugInfoDialogParams {
|
||||
device: DeviceRegistryEntry;
|
@ -8,17 +8,17 @@ import {
|
||||
css,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||
import { haStyle } from "../../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../../types";
|
||||
import {
|
||||
ZHADevice,
|
||||
fetchZHADevice,
|
||||
reconfigureNode,
|
||||
} from "../../../../../data/zha";
|
||||
import { navigate } from "../../../../../common/navigate";
|
||||
import { showZHADeviceZigbeeInfoDialog } from "../../../../../dialogs/zha-device-zigbee-signature-dialog/show-dialog-zha-device-zigbee-info";
|
||||
import { showConfirmationDialog } from "../../../../../dialogs/generic/show-dialog-box";
|
||||
} from "../../../../../../data/zha";
|
||||
import { navigate } from "../../../../../../common/navigate";
|
||||
import { showZHADeviceZigbeeInfoDialog } from "../../../../../../dialogs/zha-device-zigbee-signature-dialog/show-dialog-zha-device-zigbee-info";
|
||||
import { showConfirmationDialog } from "../../../../../../dialogs/generic/show-dialog-box";
|
||||
|
||||
@customElement("ha-device-actions-zha")
|
||||
export class HaDeviceActionsZha extends LitElement {
|
@ -8,11 +8,11 @@ import {
|
||||
css,
|
||||
PropertyValues,
|
||||
} from "lit-element";
|
||||
import { DeviceRegistryEntry } from "../../../../../data/device_registry";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import { ZHADevice, fetchZHADevice } from "../../../../../data/zha";
|
||||
import { formatAsPaddedHex } from "../../../integrations/integration-panels/zha/functions";
|
||||
import { DeviceRegistryEntry } from "../../../../../../data/device_registry";
|
||||
import { haStyle } from "../../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../../types";
|
||||
import { ZHADevice, fetchZHADevice } from "../../../../../../data/zha";
|
||||
import { formatAsPaddedHex } from "../../../../integrations/integration-panels/zha/functions";
|
||||
|
||||
@customElement("ha-device-info-zha")
|
||||
export class HaDeviceActionsZha extends LitElement {
|
@ -477,7 +477,9 @@ export class HaConfigDevicePage extends LitElement {
|
||||
): TemplateResult[] {
|
||||
const templates: TemplateResult[] = [];
|
||||
if (integrations.includes("mqtt")) {
|
||||
import("./device-detail/integration-elements/ha-device-actions-mqtt");
|
||||
import(
|
||||
"./device-detail/integration-elements/mqtt/ha-device-actions-mqtt"
|
||||
);
|
||||
templates.push(html`
|
||||
<div class="card-actions" slot="actions">
|
||||
<ha-device-actions-mqtt
|
||||
@ -488,8 +490,8 @@ export class HaConfigDevicePage extends LitElement {
|
||||
`);
|
||||
}
|
||||
if (integrations.includes("zha")) {
|
||||
import("./device-detail/integration-elements/ha-device-actions-zha");
|
||||
import("./device-detail/integration-elements/ha-device-info-zha");
|
||||
import("./device-detail/integration-elements/zha/ha-device-actions-zha");
|
||||
import("./device-detail/integration-elements/zha/ha-device-info-zha");
|
||||
templates.push(html`
|
||||
<ha-device-info-zha
|
||||
.hass=${this.hass}
|
||||
|
@ -323,6 +323,13 @@ class HaPanelConfig extends HassRouterPage {
|
||||
/* webpackChunkName: "panel-config-zwave" */ "./integrations/integration-panels/zwave/ha-config-zwave"
|
||||
),
|
||||
},
|
||||
mqtt: {
|
||||
tag: "mqtt-config-panel",
|
||||
load: () =>
|
||||
import(
|
||||
/* webpackChunkName: "panel-config-mqtt" */ "./integrations/integration-panels/mqtt/mqtt-config-panel"
|
||||
),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -46,6 +46,10 @@ declare global {
|
||||
}
|
||||
|
||||
const integrationsWithPanel = {
|
||||
mqtt: {
|
||||
buttonLocalizeKey: "ui.panel.config.mqtt.button",
|
||||
path: "/config/mqtt",
|
||||
},
|
||||
zha: {
|
||||
buttonLocalizeKey: "ui.panel.config.zha.button",
|
||||
path: "/config/zha/dashboard",
|
||||
|
@ -9,13 +9,14 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import "../../../components/ha-card";
|
||||
import "../../../components/ha-code-editor";
|
||||
import { haStyle } from "../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import "../../../../../components/ha-card";
|
||||
import "../../../../../components/ha-code-editor";
|
||||
import { haStyle } from "../../../../../resources/styles";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
import "./mqtt-subscribe-card";
|
||||
import "../../../../../layouts/hass-subpage";
|
||||
|
||||
@customElement("developer-tools-mqtt")
|
||||
@customElement("mqtt-config-panel")
|
||||
class HaPanelDevMqtt extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
|
||||
@ -37,43 +38,41 @@ class HaPanelDevMqtt extends LitElement {
|
||||
|
||||
protected render(): TemplateResult {
|
||||
return html`
|
||||
<div class="content">
|
||||
<ha-card
|
||||
header="${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.description_publish"
|
||||
)}"
|
||||
>
|
||||
<div class="card-content">
|
||||
<paper-input
|
||||
label="${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.topic"
|
||||
)}"
|
||||
.value=${this.topic}
|
||||
@value-changed=${this._handleTopic}
|
||||
></paper-input>
|
||||
<hass-subpage>
|
||||
<div class="content">
|
||||
<ha-card
|
||||
header="${this.hass.localize(
|
||||
"ui.panel.config.mqtt.description_publish"
|
||||
)}"
|
||||
>
|
||||
<div class="card-content">
|
||||
<paper-input
|
||||
label="${this.hass.localize("ui.panel.config.mqtt.topic")}"
|
||||
.value=${this.topic}
|
||||
@value-changed=${this._handleTopic}
|
||||
></paper-input>
|
||||
|
||||
<p>
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.payload"
|
||||
)}
|
||||
</p>
|
||||
<ha-code-editor
|
||||
mode="jinja2"
|
||||
.value="${this.payload}"
|
||||
@value-changed=${this._handlePayload}
|
||||
></ha-code-editor>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<mwc-button @click=${this._publish}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.publish"
|
||||
)}</mwc-button
|
||||
>
|
||||
</div>
|
||||
</ha-card>
|
||||
<p>
|
||||
${this.hass.localize("ui.panel.config.mqtt.payload")}
|
||||
</p>
|
||||
<ha-code-editor
|
||||
mode="jinja2"
|
||||
.value="${this.payload}"
|
||||
@value-changed=${this._handlePayload}
|
||||
></ha-code-editor>
|
||||
</div>
|
||||
<div class="card-actions">
|
||||
<mwc-button @click=${this._publish}
|
||||
>${this.hass.localize(
|
||||
"ui.panel.config.mqtt.publish"
|
||||
)}</mwc-button
|
||||
>
|
||||
</div>
|
||||
</ha-card>
|
||||
|
||||
<mqtt-subscribe-card .hass=${this.hass}></mqtt-subscribe-card>
|
||||
</div>
|
||||
<mqtt-subscribe-card .hass=${this.hass}></mqtt-subscribe-card>
|
||||
</div>
|
||||
</hass-subpage>
|
||||
`;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { formatTime } from "../../../common/datetime/format_time";
|
||||
import "../../../components/ha-card";
|
||||
import { MQTTMessage, subscribeMQTTTopic } from "../../../data/mqtt";
|
||||
import { HomeAssistant } from "../../../types";
|
||||
import { formatTime } from "../../../../../common/datetime/format_time";
|
||||
import "../../../../../components/ha-card";
|
||||
import { MQTTMessage, subscribeMQTTTopic } from "../../../../../data/mqtt";
|
||||
import { HomeAssistant } from "../../../../../types";
|
||||
|
||||
@customElement("mqtt-subscribe-card")
|
||||
class MqttSubscribeCard extends LitElement {
|
||||
@ -43,18 +43,14 @@ class MqttSubscribeCard extends LitElement {
|
||||
return html`
|
||||
<ha-card
|
||||
header="${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.description_listen"
|
||||
"ui.panel.config.mqtt.description_listen"
|
||||
)}"
|
||||
>
|
||||
<form>
|
||||
<paper-input
|
||||
.label=${this._subscribed
|
||||
? this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.listening_to"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.subscribe_to"
|
||||
)}
|
||||
? this.hass.localize("ui.panel.config.mqtt.listening_to")
|
||||
: this.hass.localize("ui.panel.config.mqtt.subscribe_to")}
|
||||
.disabled=${this._subscribed !== undefined}
|
||||
.value=${this._topic}
|
||||
@value-changed=${this._valueChanged}
|
||||
@ -65,12 +61,8 @@ class MqttSubscribeCard extends LitElement {
|
||||
type="submit"
|
||||
>
|
||||
${this._subscribed
|
||||
? this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.stop_listening"
|
||||
)
|
||||
: this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.start_listening"
|
||||
)}
|
||||
? this.hass.localize("ui.panel.config.mqtt.stop_listening")
|
||||
: this.hass.localize("ui.panel.config.mqtt.start_listening")}
|
||||
</mwc-button>
|
||||
</form>
|
||||
<div class="events">
|
||||
@ -78,7 +70,7 @@ class MqttSubscribeCard extends LitElement {
|
||||
(msg) => html`
|
||||
<div class="event">
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.message_received",
|
||||
"ui.panel.config.mqtt.message_received",
|
||||
"id",
|
||||
msg.id,
|
||||
"topic",
|
@ -38,6 +38,10 @@ class HaConfigZwave extends LocalizeMixin(EventsMixin(PolymerElement)) {
|
||||
static get template() {
|
||||
return html`
|
||||
<style include="iron-flex ha-style ha-form-style">
|
||||
app-toolbar {
|
||||
border-bottom: 1px solid var(--divider-color);
|
||||
}
|
||||
|
||||
.content {
|
||||
margin-top: 24px;
|
||||
}
|
||||
|
@ -25,10 +25,6 @@ class DeveloperToolsRouter extends HassRouterPage {
|
||||
tag: "developer-tools-event",
|
||||
load: () => import("./event/developer-tools-event"),
|
||||
},
|
||||
mqtt: {
|
||||
tag: "developer-tools-mqtt",
|
||||
load: () => import("./mqtt/developer-tools-mqtt"),
|
||||
},
|
||||
service: {
|
||||
tag: "developer-tools-service",
|
||||
load: () => import("./service/developer-tools-service"),
|
||||
|
@ -13,7 +13,6 @@ import {
|
||||
property,
|
||||
TemplateResult,
|
||||
} from "lit-element";
|
||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||
import scrollToTarget from "../../common/dom/scroll-to-target";
|
||||
import { navigate } from "../../common/navigate";
|
||||
import "../../components/ha-menu-button";
|
||||
@ -72,15 +71,6 @@ class PanelDeveloperTools extends LitElement {
|
||||
"ui.panel.developer-tools.tabs.events.title"
|
||||
)}
|
||||
</paper-tab>
|
||||
${isComponentLoaded(this.hass, "mqtt")
|
||||
? html`
|
||||
<paper-tab page-name="mqtt">
|
||||
${this.hass.localize(
|
||||
"ui.panel.developer-tools.tabs.mqtt.title"
|
||||
)}
|
||||
</paper-tab>
|
||||
`
|
||||
: ""}
|
||||
</paper-tabs>
|
||||
</app-header>
|
||||
<developer-tools-router
|
||||
|
@ -1506,6 +1506,20 @@
|
||||
"create": "Create"
|
||||
}
|
||||
},
|
||||
"mqtt": {
|
||||
"button": "Configure",
|
||||
"title": "MQTT",
|
||||
"description_publish": "Publish a packet",
|
||||
"topic": "topic",
|
||||
"payload": "Payload (template allowed)",
|
||||
"publish": "Publish",
|
||||
"description_listen": "Listen to a topic",
|
||||
"listening_to": "Listening to",
|
||||
"subscribe_to": "Topic to subscribe to",
|
||||
"start_listening": "Start listening",
|
||||
"stop_listening": "Stop listening",
|
||||
"message_received": "Message {id} received on {topic} at {time}:"
|
||||
},
|
||||
"zha": {
|
||||
"button": "Configure",
|
||||
"header": "Configure Zigbee Home Automation",
|
||||
@ -2299,19 +2313,6 @@
|
||||
"alert_event_type": "Event type is a mandatory field",
|
||||
"notification_event_fired": "Event {type} successful fired!"
|
||||
},
|
||||
"mqtt": {
|
||||
"title": "MQTT",
|
||||
"description_publish": "Publish a packet",
|
||||
"topic": "topic",
|
||||
"payload": "Payload (template allowed)",
|
||||
"publish": "Publish",
|
||||
"description_listen": "Listen to a topic",
|
||||
"listening_to": "Listening to",
|
||||
"subscribe_to": "Topic to subscribe to",
|
||||
"start_listening": "Start listening",
|
||||
"stop_listening": "Stop listening",
|
||||
"message_received": "Message {id} received on {topic} at {time}:"
|
||||
},
|
||||
"services": {
|
||||
"title": "Services",
|
||||
"description": "The service dev tool allows you to call any available service in Home Assistant.",
|
||||
|
Loading…
x
Reference in New Issue
Block a user