home-assistant / frontend

:lollipop: Frontend for Home Assistant
https://demo.home-assistant.io
Other
4.13k stars 2.81k forks source link

Issue with multiple Selector types when using "Add Field" in Script Editor. #21997

Open Didgeridrew opened 2 months ago

Didgeridrew commented 2 months ago

Checklist

Describe the issue you are experiencing

When adding Fields using the Visual Editor for Script, an {} is inserted after the selector type key instead of null.

Example:

image

This causes the script to error and become unavailable. Many Selector types require further configuration using the YAML editor, but some do not require it and a few do not have any options beyond their key, so switching the the YAML editor to delete the {} should not be required.

Describe the behavior you expected

If additional configuration is not required by the Selector, just choosing the selector type should be sufficient to have a working field variable.

Steps to reproduce the issue

  1. Start a new script in the script editor.
  2. Add a Field using the "Add Field" button or Menu item
  3. Pick a selector from the Selector drop down menu. Most will work... but the 12 key-only types, like Template, Action, or Date definitely will.
  4. Add any action in the sequence.
  5. Save the script.

What version of Home Assistant Core has the issue?

2024.9.1

What was the last working version of Home Assistant Core?

No response

In which browser are you experiencing the issue with?

Firefox 130.0, Google Chrome 128.0.6613.137

Which operating system are you using to run this browser?

Pop!_OS 22.04 LTS

State of relevant entities

No response

Problem-relevant frontend configuration

No response

Javascript errors shown in your browser console/inspector

No response

Additional information

No response

karwosts commented 2 months ago

What exactly is the script error you are seeing?

I'm trying this but I don't see any errors, don't see any problem with having empty brackets there.

alias: Entity Selector
sequence:
  - action: logbook.log
    metadata: {}
    data:
      message: Test Message
      name: test
fields:
  example:
    selector:
      entity: {}
    name: Example
    description: Example Description
description: ""
AdarshPandey-07 commented 2 months ago

@Didgeridrew check again is the issue still persisting, if yes I would like to contribute.

Didgeridrew commented 2 months ago

What exactly is the script error you are seeing?

The script setup fails with the following:

The script "zTest data field" (script.ztest_data_field) is not active because the configuration has errors.

Error:Only one type can be specified. Found for dictionary value @ data['fields']['testent']['selector']. Got OrderedDict().

To fix this error, [edit the script](https://johns*****.***/config/script/edit/ztest_data_field) to correct it, then save and reload the script configuration.

And the system logs show:

Logger: homeassistant.components.script
Source: components/script/config.py:147
integration: Script (documentation, issues)
First occurred: 11:50:31 PM (1 occurrences)
Last logged: 11:50:31 PM

Script with alias 'zTest data field' could not be validated and has been disabled: Only one type can be specified. Found for dictionary value @ data['fields']['testent']['selector']. Got OrderedDict()

Updated to 2024.9.2, and the issue persists.

karwosts commented 2 months ago

Can you post the entire complete script that has this error (yaml not screenshot?)

Didgeridrew commented 2 months ago
alias: zTest data field
sequence:
  - action: persistent_notification.create
    metadata: {}
    data:
      message: "{{testent}}"
      title: This is a Test
fields:
  testent:
    selector:
      entity: {}
    name: TestEnt
description: ""
karwosts commented 2 months ago

Hmm strange that works perfectly for me. It says the same in safe mode?

image

image

Didgeridrew commented 2 months ago

Yes, I get the same repair message and error in the system log in Safe Mode.

karwosts commented 2 months ago

Hm sorry I'm stumped then, can't reproduce. 🤷