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
Added refresh rate for picture entity card #5466
Conversation
Number(this.refreshRate ? this.refreshRate : DEFAULT_REFRESH_RATE) * | ||
1000 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't do the Number
conversion, the values are numbers
@@ -40,6 +40,8 @@ export class HuiImage extends LitElement { | |||
|
|||
@property() public aspectRatio?: string; | |||
|
|||
@property() public refreshRate?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a number, not a string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally coded it with "number", however the value was never saved. Maybe I missed somewhere I needed to change.
@@ -208,9 +211,13 @@ export class HuiImage extends LitElement { | |||
return; | |||
} | |||
|
|||
const cacheTime = | |||
(Number(this.refreshRate ? this.refreshRate : DEFAULT_REFRESH_RATE) - 1) * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
@@ -36,6 +36,7 @@ const cardConfigStruct = struct({ | |||
camera_image: "string?", | |||
camera_view: "string?", | |||
aspect_ratio: "string?", | |||
refresh_rate: "string?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number
src/panels/lovelace/editor/config-elements/hui-picture-entity-card-editor.ts
Outdated
Show resolved
Hide resolved
src/panels/lovelace/editor/config-elements/hui-picture-entity-card-editor.ts
Outdated
Show resolved
Hide resolved
src/panels/lovelace/editor/config-elements/hui-picture-entity-card-editor.ts
Outdated
Show resolved
Hide resolved
translations/ca.json
Outdated
@@ -2178,6 +2178,7 @@ | |||
}, | |||
"generic": { | |||
"aspect_ratio": "Relació d'aspecte", | |||
"refresh_rate": "Velocitat d’actualització (segons)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translations are handled in Localize, you should not add them here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is my first time contributing to HA -- I didn't find any other finds that contained the translations. When you say "handled in Localize", what do you mean? Is there a different git repo for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src\translations\en.json
This is the only place that it needs to be added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I get it now. Thanks for pointing that out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the other translation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
I don't think this is a good idea, a user can flood his Home Assistant now. We have |
The |
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
…card-editor.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
…card-editor.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
…card-editor.ts Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
Co-Authored-By: Bram Kragten <mail@bramkragten.nl>
Changed everything to number and it is working. The only thing that wasn't working well is when, for example, the user changed the default of 10 to 5, the user would press the delete key twice to delete "10" before entering "5". When the field is empty it resulted in the field getting initialized back to 10. I changed the getter to return NaN instead of 10 when value is not specified by user which then uses the internal default of 10. Since this is an optional field, this seemed acceptable. |
translations/ca.json
Outdated
@@ -2164,6 +2164,7 @@ | |||
"name": "Filtre d'entitats" | |||
}, | |||
"entity": { | |||
"description": "La targeta entitat mostra una visualització ràpida dels estats d'una o més entitats.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All translations will need removed except for src/translations/en.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good now
Maybe we can limit this to being 10 seconds or greater? If the user makes it lower than 10 it is changed to being 10 |
@zsarnett The original use case was to set the update interval to lower then 10 seconds as the live streaming from Blue Iris that flows through HA has a 7+ second delay. So the work around was to refresh a static image every 3 seconds. Maybe we can do some type of warning if the value is less than 10 seconds to inform user that the performance may be impacted. |
Are you able to test and see if that work? Refreshing at a 3 second delay? IS HA now more in sync? I know I see a delay with RTSP but I am not sure the delay is HA or just the RTSP |
I can have a 1 second refresh rate on a modern laptop and it keeps up, but the target is a Fire Tablet which is slow, so backed off to 3 seconds which seems to work well. As for live streaming delay. I can see that there is a 3 second delay coming from Blue Iris on the type of stream that is requested (m3u8 MIME type application/vnd.apple.mpegurl). I think its because it has to transcode to get this format. The additional delay seems to happen between between HA getting the stream and the browser getting the steaming bytes. This is something I want to dig in more to see if the native "video/mpeg" content type can be used from Blue Iris as this is much faster -- but that's a different issue. |
@kkellner I still don't think this is a good idea, if we would add this, it should not be in the UI editor as it is too advanced and could break systems. Would it be an idea to create a custom card for this? |
@bramkragten It doesn't seem like a refresh rate is too advanced of an option. Are you thinking that users will change to a value that is too low that HA would not be able to keep up? I was trying to avoid creating another card type in order to keep the functionality together and the code in sync with what is already provided. If you think this isn't going to workout, you can toss the change. |
3 seconds is perfect here. 10 seconds too slow. |
Proposed change
The hui-image used in picture-entity card has a hard-coded refresh rate of 10 seconds. To provide more flexibility in the image refresh rate a new user-configurable attribute has been added to the picture-entity card.
Type of change
Example configuration
For
picture-entity
card add arefresh_rate
property. This is optional and defaults to the original behavior of 10 seconds if the attribute is not defined.Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: