Skip to content

Card Editor: Special Row doesn't show warning#7093

Merged
zsarnett merged 5 commits intodevfrom
add-special-rows
Sep 24, 2020
Merged

Card Editor: Special Row doesn't show warning#7093
zsarnett merged 5 commits intodevfrom
add-special-rows

Conversation

@zsarnett
Copy link
Contributor

@zsarnett zsarnett commented Sep 21, 2020

Proposed change

This makes it so that special Rows do not break the editor.

image

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

type: entities
entities:
  - entity: vacuum.0_ground_floor
  - type: divider
  - entity: vacuum.1_first_floor
  - entity: vacuum.2_second_floor
  - entity: vacuum.3_third_floor
  - type: call-service
    icon: 'mdi:power'
    name: Bed light
    action_name: Toggle light
    service: light.toggle
    service_data:
      entity_id: light.bed_light
  - type: section
    label: Testing The New Editor
  - type: divider
  - type: attribute
    entity: vacuum.1_first_floor
    attribute: fan_speed
    name: Fan Speed
  - type: weblink
    name: Home Assistant
    url: 'https://www.home-assistant.io/'
    icon: 'mdi:home-assistant'
  - type: conditional
    conditions:
      - entity: light.bed_light
        state: 'on'
    row:
      entity: light.bed_light
  - type: buttons
    entities:
      - vacuum.3_third_floor
      - light.bed_light
  - type: button
    name: Button to Press
    tap_action:
      action: call-service
      service: light.toggle
      service_data:
        entity_id: light.bed_light
  - type: cast
    view: entities-card
    name: testing this cast
footer:
  type: graph
  entity: sensor.random_sensor
  hours_to_show: 24

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.

<div class="entity" data-entity-id=${entityConf.entity}>
<div
class="entity"
data-entity-id=${entityConf.entity || entityConf.type}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why TS is complaining that the entity property doesn't exist here? I thought that having the OR here would make it go away...

Its because entity doesn't exist on all of the RowConfigs

Any suggestions?

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it play better with a ternary expression? entityConf.entity ? entityConf.entity : entityConf.type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that too. Same issue

Copy link
Member

Choose a reason for hiding this comment

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

"entity" in entityConf ? entityConf.entity : entityConf.type

@zsarnett zsarnett changed the title Add the ability to have special rows with editor Card Editor: Special Row doesn't show warning Sep 21, 2020
@value-changed=${this._valueChanged}
allow-custom-entity
></ha-entity-picker>
${entityConf.type
Copy link
Member

Choose a reason for hiding this comment

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

Thinking we might want to extend this instead, seems very strange to have something specific to only the entities card in this element.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably not a bad idea

Copy link
Member

@iantrich iantrich Sep 22, 2020

Choose a reason for hiding this comment

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

We do that and then we can change how we add rows later as well, and give a new prompt instead allowing you choose special row or entity and expand on the entity options

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea that was the plan for this. I have a branch ready to do that and have entity options. But this is the first step

@property({ attribute: false }) protected hass?: HomeAssistant;

@property({ attribute: false }) protected entities?: EntityConfig[];
@property({ attribute: false }) protected entities?: LovelaceRowConfig[];
Copy link
Member

Choose a reason for hiding this comment

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

This should not be in the entity-editor, as we use that for different cards, we should make a specific entities-card-row-editor that accepts a LovelaceRowConfig[]

@zsarnett
Copy link
Contributor Author

New element created. Entity editor is no longer touched and stay the same for other elements using it

@zsarnett
Copy link
Contributor Author

image

Comment on lines +78 to +83
${this.hass!.localize(
`ui.panel.lovelace.editor.card.entities.entity_row.${entityConf.type}`
)}
${this.hass!.localize(
"ui.panel.lovelace.editor.card.entities.special_row"
)}
Copy link
Member

Choose a reason for hiding this comment

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

We should combine this in 1 localize:

Suggested change
${this.hass!.localize(
`ui.panel.lovelace.editor.card.entities.entity_row.${entityConf.type}`
)}
${this.hass!.localize(
"ui.panel.lovelace.editor.card.entities.special_row"
)}
${this.hass!.localize(
"ui.panel.lovelace.editor.card.entities.special_row", "row_type", this.hass!.localize(
`ui.panel.lovelace.editor.card.entities.entity_row.${entityConf.type}`
)
)}

But maybe we should just drop the special_row? Just "Button row" would be enough?

@zsarnett zsarnett merged commit a349e34 into dev Sep 24, 2020
@zsarnett zsarnett deleted the add-special-rows branch September 24, 2020 16:36
@bramkragten bramkragten mentioned this pull request Sep 30, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

divider and weblink causing warning on UI editor

5 participants