-
Notifications
You must be signed in to change notification settings - Fork 9
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
Show Rain Delay Stop Time if rain delay is active #17
Conversation
@@ -209,6 +209,11 @@ export class OpensprinklerCard extends LitElement { | |||
private _secondaryText() { | |||
const entities: EntitiesFunc = p => this._matchingEntities(p) | |||
|
|||
if (hasRainDelayActive(entities)) { | |||
const stop_time = entities(isRainDelayStopTime).find(_ => true)?.state; |
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.
Likewise this feels like a hacky approach to selecting the first (and only expected) item in the list, without failing if the list is empty due to renames, etc. Good enough? Other ideas?
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 think entities(isRainDelayStopTime)[0]?.state
would have the same effect. If there are no rain delay entities entities(isRainDelayStopTime)[0]
will be undefined
.
- Use `relativeTime` formatting - Update `custom-card-helpers` for current `relativeTime` implementation
c4afc69
to
ee9bfc5
Compare
Converting to a draft for the moment... I somehow snuck through successful local testing in between It's possible that my newbie level JavaScript (and TypeScript) is simply missing some trick here, but at the moment I get errors like:
@rianadon Is it preferable here to propagate this upgrade onward into the timer bar card as well? Or, should I drop the The hang up on 1.8.0 is that something is going sideways in |
OK, in the interest of driving at least one of the possible solutions all the way to ground, here's one feature complete PR approach :) This follows the lead of This PR takes a dependency on
Let me know your thoughts :) This one is actually functional for me, and I still think a nice improvement 😄 Happy to do any linting, commit squashing etc that you prefer- just let me know! |
- Port relative_time from `custom-card-helpers` and `frontend` locally - Adjust types to align minimum required locale fields across `HomeAssistant` object versions. (We require only language.) - Take dependency on @formatjs/intl-utils for `selectUnit`, mirroring custom-card-helpers and frontend itself.
fb34533
to
5906f1d
Compare
"@mdi/js": "^6.5.95", | ||
"custom-card-helpers": "^1.8.0", | ||
"custom-card-helpers": "1.8.0", |
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.
Note: This is explicitly removing the "compatible with" ^
qualifier, in favor of pinning the custom-card-helpers
version at exactly 1.8.0. Version 1.9.0 ought to be compatible, but took a major version bump of home-assistant-js-websocket
, and we're exposed to the breaking changes due to data type incompatibility.
Sorry for the delay. I'll try to take a look by the end of this month. |
No worries, thanks 😄 |
Wow thanks for all the writeups! The information is super helpful. I remember there being some apis that were changed in |
Sorry it took so long to find time to look into this. The reason I can't upgrade I think maintaining our own |
The code looks spectacular to me so I'll do the merge. Thank you so much for the PR and comments @cmccambridge! |
Thanks very much @rianadon! It was fun to dive into this card to add this new ability in. Thanks for the pointers and feedback along the way 😄 |
Implements #16
In this PR:
relativeTime
formatting fromcustom-card-helpers
(off-the-shelf clone of the HA frontend implementation)custom-card-helpers
dependency for currentrelativeTime
implementation, and in turn update its dependencyhome-assistant-js-websocket
.Net Result:
2 hour rain delay:
28 hour rain delay:
Note: proper functionality here is dependent on a bugfix from the HACS opensprinkler integration being published, which corrects an issue on the integration side where the rain delay stop time was not being properly converted from local time to UTC. That fix is now merged and on its way through the release process, but without it the reported rain delay times may be surprising 😄
TODO:
Verify that the upgrade ofhome-assistant-js-websocket
is OKUsage:Connection, createCollection
inha_entity_registry.ts
,UnsubscribeFunc
inopensprinkler-cards.ts