Skip to content

Handle unknown state#4481

Merged
balloob merged 1 commit into
devfrom
unknown-state
Jan 15, 2020
Merged

Handle unknown state#4481
balloob merged 1 commit into
devfrom
unknown-state

Conversation

@bramkragten
Copy link
Copy Markdown
Member

No description provided.

${name}<br />
${device.area} | ${device.integration}<br />
${battery
${battery && !isNaN(battery.state as any)
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.

battery.state is always a string. You will need to parse it first. But I prefer that you compare it against unavailable and unknown instead

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.

Or this:

Suggested change
${battery && !isNaN(battery.state as any)
${battery && !isNaN(Number(battery.state))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

isNaN does a string to number conversion, but I can also check for unavailable and unknown

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.

in that case it's fine.

@balloob balloob merged commit aaefe0b into dev Jan 15, 2020
@delete-merged-branch delete-merged-branch Bot deleted the unknown-state branch January 15, 2020 17:02
@lock lock Bot locked and limited conversation to collaborators Jan 16, 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.

4 participants