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 Trigger to Ha-Form #11643
MQTT Trigger to Ha-Form #11643
Conversation
handleChangeEvent(this, ev); | ||
ev.stopPropagation(); | ||
const newTrigger = ev.detail.value; | ||
Object.keys(newTrigger).forEach((key) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't ha-form does this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesnt seem to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
root.addEventListener("value-changed", (ev) => {
ev.stopPropagation();
const schema = (ev.target as HaFormElement).schema as HaFormSchema;
fireEvent(this, "value-changed", {
value: { ...this.data, [schema.name]: ev.detail.value },
});
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://design.home-assistant.io/#components/ha-form -> See OctoPrint (at the very bottom). Remove application path.
If a field is optional, it will be removed from the output.
src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts
Outdated
Show resolved
Hide resolved
import { TriggerElement } from "../ha-automation-trigger-row"; | ||
|
||
const SCHEMA: HaFormSchema[] = [ | ||
{ name: "topic", selector: { text: {} } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is required and should have required: true
|
||
const SCHEMA: HaFormSchema[] = [ | ||
{ name: "topic", selector: { text: {} } }, | ||
{ name: "payload", required: false, selector: { text: {} } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required: false is the default I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required is default true
because thats what it was before I updated the text fields to even have the ability to be optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have the same default for required across anything that you can create in ha-form. And that default is optional is the default if I recall correctly.
fireEvent(this, "value-changed", { value: newTrigger }); | ||
} | ||
|
||
private _computeLabelCallback(schema: HaFormSchema): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private _computeLabelCallback(schema: HaFormSchema): string { | |
private _computeLabelCallback = (schema: HaFormSchema): string => { |
src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts
Outdated
Show resolved
Hide resolved
src/panels/config/automation/trigger/types/ha-automation-trigger-mqtt.ts
Outdated
Show resolved
Hide resolved
…er-mqtt.ts Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
…er-mqtt.ts Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Breaking change
Proposed change
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: