Skip to content

MQTT Trigger to Ha-Form#11643

Merged
zsarnett merged 8 commits intodevfrom
mqtt-ha-form
Feb 10, 2022
Merged

MQTT Trigger to Ha-Form#11643
zsarnett merged 8 commits intodevfrom
mqtt-ha-form

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@zsarnett zsarnett added the needs design preview PRs with this label will trigger a GitHub action to generate a gallery preview label Feb 10, 2022
handleChangeEvent(this, ev);
ev.stopPropagation();
const newTrigger = ev.detail.value;
Object.keys(newTrigger).forEach((key) =>
Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesnt seem to

Copy link
Copy Markdown
Contributor Author

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 },
      });
    });

Copy link
Copy Markdown
Member

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.

balloob
balloob previously approved these changes Feb 10, 2022
import { TriggerElement } from "../ha-automation-trigger-row";

const SCHEMA: HaFormSchema[] = [
{ name: "topic", selector: { text: {} } },
Copy link
Copy Markdown
Member

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: {} } },
Copy link
Copy Markdown
Member

@balloob balloob Feb 10, 2022

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?

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

@balloob balloob Feb 10, 2022

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
private _computeLabelCallback(schema: HaFormSchema): string {
private _computeLabelCallback = (schema: HaFormSchema): string => {

balloob
balloob previously approved these changes Feb 10, 2022
balloob
balloob previously approved these changes Feb 10, 2022
…er-mqtt.ts

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
zsarnett and others added 2 commits February 10, 2022 15:33
…er-mqtt.ts

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
@zsarnett zsarnett enabled auto-merge (squash) February 10, 2022 21:42
@zsarnett zsarnett disabled auto-merge February 10, 2022 21:44
@zsarnett zsarnett enabled auto-merge (squash) February 10, 2022 21:44
@zsarnett zsarnett merged commit ac90bb7 into dev Feb 10, 2022
@delete-merged-branch delete-merged-branch bot deleted the mqtt-ha-form branch February 10, 2022 22:11
@github-actions github-actions bot locked and limited conversation to collaborators Feb 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed needs design preview PRs with this label will trigger a GitHub action to generate a gallery preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants