-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Uses websocket to get sensor device class units #15014
Conversation
cdff33e
to
866cf1b
Compare
@@ -177,6 +126,24 @@ const OVERRIDE_WEATHER_UNITS = { | |||
wind_speed: ["ft/s", "km/h", "kn", "m/s", "mph"], | |||
}; | |||
|
|||
const CONVERTIBLE_UNITS_SENSOR_DEVICE_CLASS = new 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.
Can we include this in the ws command from core?
export const SENSOR_DEVICE_CLASS_BATTERY = "battery"; | ||
export const SENSOR_DEVICE_CLASS_TIMESTAMP = "timestamp"; | ||
|
||
export type SensorDeviceClassUnits = { units: 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.
Something like
export type SensorDeviceClassUnits = { units: string[] }; | |
export type SensorDeviceClassUnits = { units: string[]; convertible: boolean; }; |
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.
That's what I suggested in the core PR
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.
Is there a plan to make use of this list for things other than unit conversion?
If it's only for unit conversion, then I think it's better to simply return an empty list when it's not convertible, as adjusted in home-assistant/core@9632158.
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 updated the endpoint et removed the hardcoded list in frontend
Proposed change
Fetch sensor device class units from core instead of hardcoded ones.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: