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

Add default values for script fields in more-info dialog #20747

Closed
wants to merge 8 commits into from

Conversation

paolapersico1
Copy link

@paolapersico1 paolapersico1 commented May 6, 2024

Proposed change

Previously, the more-info dialog for script entities didn't show the user-defined default values for the script fields, this PR fixes this.

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

alias: TestScript
sequence:
  - if:
      - condition: template
        value_template: "{{ testfield == \"decrement\" }}"
    then:
      - service: counter.decrement
        metadata: {}
        data: {}
        target:
          entity_id: counter.helper
    else:
      - service: counter.increment
        target:
          entity_id:
            - counter.helper
        data: {}
mode: single
fields:
  testfield:
    selector:
      select:
        options:
          - increment
          - decrement
    name: testfield
    default: increment
    required: true
icon: mdi:account

counter:
  helper:
    initial: 0
    step: 1

Additional information

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:

home-assistant[bot]

This comment was marked as outdated.

@home-assistant home-assistant bot marked this pull request as draft May 6, 2024 18:54
@home-assistant

This comment was marked as outdated.

this._scriptData = { service: newState.entity_id, data: {} };
const fields =
this.hass.services.script[computeObjectId(newState.entity_id)]?.fields;
const defaultValues = {};
Copy link
Member

Choose a reason for hiding this comment

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

I think we should use computeInitialHaFormData here.

@paolapersico1 paolapersico1 marked this pull request as draft May 8, 2024 20:47
Copy link

github-actions bot commented Aug 6, 2024

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Aug 6, 2024
@github-actions github-actions bot closed this Aug 13, 2024
@karwosts karwosts mentioned this pull request Sep 17, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Script field defaults are not used in frontend
2 participants