-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow not_set value for timestamp device class #10006
Conversation
src/data/sensor.ts
Outdated
export const SENSOR_DEVICE_CLASS_BATTERY = "battery"; | ||
export const SENSOR_DEVICE_CLASS_TIMESTAMP = "timestamp"; | ||
export const NOT_SET = "not_set"; | ||
export const VALID_TIMESTAMP_STATES = UNAVAILABLE_STATES + [NOT_SET]; |
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.
"unknown" (or rather (None
)) would be the correct state when it does not have a timestamp for this device class.
If it has a "random" string it's no longer a timestamp class.
Which integrations does that?
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.
The problem with "unknown" is that state is actually known, that confuses people. Other alternatives I thought about: "none"
(as a string, should be rendered as "None", a bit confusing for developers) or "off"
.
For example there're android next alarm sensor which uses unavailable
when there's no alarm:
https://companion.home-assistant.io/docs/core/sensors/#next-alarm-sensor
I think that's semantically incorrect because data is available and causes unexpected side effects as I described with entity manager.
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.
For that example it should not be unavailable
it should be None
("unknown"), the next alarm is not known so the state is not known.
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.
There is currently nothing in the backend that would ever set "not_set" as a state. So it's not something that the frontend should react to.
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.
You're right there's nothing right now. I guess that's because frontend doesn't support it. I want to use this in custom integration and provide people meaningful UX with nicely formatted timestamp and not set value which is not Unknown
because Unknown
is confusing and doesn't mean what it should mean.
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 agree that neither unknown or unavailable are correct. Changes for a device class should happen in the architecture issue though.
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.
Opened a discussion in the architecture repo: home-assistant/architecture#635
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
Currently sensor with device class timestamp only supports
unavailable
andunknown
states apart from actual timestamp.These states are quite special and usually used for error states.
unavailable
for example renders as a red sign in entity manager:Some timestamp entities like alarms or timers may be not set and
unknown
state also doesn't represent that state correctly.Right now
not_set
state will be rendered asInvalid timestamp
, this PR addresses that.Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: