Skip to content

add never_triggered#4442

Merged
iantrich merged 11 commits into
home-assistant:devfrom
Mariusthvdb:patch-3
Jan 21, 2020
Merged

add never_triggered#4442
iantrich merged 11 commits into
home-assistant:devfrom
Mariusthvdb:patch-3

Conversation

@Mariusthvdb
Copy link
Copy Markdown
Contributor

@Mariusthvdb Mariusthvdb commented Jan 9, 2020

Add never_triggered to the last-triggered secondary_info.
as it stands, the secondary_info line is empty when used on an automation or script that hasn't been triggered yet, while the user expects info on that line.

my suggestion would be to add:

"automation": {
        "last_triggered": "Last triggered",
        "never_triggered":"Never triggered",
        "trigger": "Execute"
      }

and

"script": {
        "last_triggered": "Last triggered",
        "never_triggered":"Never triggered",
        "execute": "Execute"
      }

to the translation file.

Add never_triggered to the last-triggered secondary_info.
as it stands, the secondary_info line is empty when used on an automation or script that hasn't been triggered yet, while the user expects info on that line.
Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts Outdated
Copy link
Copy Markdown
Contributor Author

@Mariusthvdb Mariusthvdb left a comment

Choose a reason for hiding this comment

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

thanks for your feedback, appreciated!

for automation and script, to use in secondary_info
add last_triggered on script, because it was missing
Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts Outdated
Comment thread src/translations/en.json Outdated
},
"script": {
"last_triggered": "Last triggered",
"never_triggered":"Never triggered",
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.

Remove these two. You are not using them.

Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts Outdated
to entities, delete incorrect entries to automation and script
Comment thread src/translations/en.json Outdated
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts Outdated
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts
@bramkragten
Copy link
Copy Markdown
Member

Please also test your PR

Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

Please also test your PR

ok let me know how?

@bramkragten
Copy link
Copy Markdown
Member

bramkragten commented Jan 10, 2020

@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

That is a bit overtaxing at the moment I fear... setting up a full development environment I wouldn't know where to start with, for such a small edit..
Hope to have a spare device for that anytime soon, please have patience.

Comment thread src/panels/lovelace/components/hui-generic-entity-row.ts
@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

@bramkragten
having some difficulties setting up my dev environment, which won't go beyond setting up an integration (Sonos) and doesn't finish the full startup sequence... because of this, I can't set up any testing yet I fear. Is there any way you guys can test if this works now, so we can proceed with the PR?

@ludeeus
Copy link
Copy Markdown
Member

ludeeus commented Jan 12, 2020

Tested, it does not work, probably needs a check against null and/or undefined.
When you get your env up and running, you will probably find it :)

@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

Mariusthvdb commented Jan 13, 2020

a check is what I had in my first suggestion, which was later on superseded with Ian 's code.

what would be best? to first check if not null? like

              : this.config.secondary_info === "last-triggered" &&
                 stateObj.attributes.last_triggered !== null
                 ? html`
                     <ha-relative-time
                       .hass=${this.hass}
                       .datetime=${stateObj.attributes.last_triggered}
                     ></ha-relative-time>
                   `
                 : this.hass.localize(
                     "ui.panel.lovelace.card.entities.never_triggered"
                   )

or should it be:

              : this.config.secondary_info === "last-triggered"
              ? stateObj.attributes.last_triggered !== null
                 ? html`
                     <ha-relative-time
                       .hass=${this.hass}
                       .datetime=${stateObj.attributes.last_triggered}
                     ></ha-relative-time>
                   `
                 : this.hass.localize(
                     "ui.panel.lovelace.card.entities.never_triggered"
                   )

@bramkragten
Copy link
Copy Markdown
Member

Probably the second with a falsy check instead of null (as you now don't catch undefined)

@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

since this is new to me, I'm not sure what I should add. Checked all never_triggered automations and scripts in HA states, and in template editor.

In states they all show last_triggered: null, while in templates attributes_last_triggered == None or none. Never unknown or null.

Schermafbeelding 2020-01-13 om 13 40 49

Schermafbeelding 2020-01-13 om 13 42 32

If that still leaves you needing an extra falsy check, please let me know what that would need to be besides testing for !== null

@iantrich
Copy link
Copy Markdown
Member

The problem is not the check it is your translation path. You added your translation to ui.panel.lovelace.editor.entities.never_triggered in en.json

@Mariusthvdb
Copy link
Copy Markdown
Contributor Author

Mariusthvdb commented Jan 18, 2020

wow, thanks Ian, really appreciated!
was seriously confused by all of this, yet so simple....
glad it is finally approved!
anything else left for Merge?

@iantrich iantrich merged commit eeced62 into home-assistant:dev Jan 21, 2020
@lock lock Bot locked and limited conversation to collaborators Jan 24, 2020
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.

5 participants