-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
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
Add datetime object as valid StateType #52671
Conversation
d4470af
to
028fc7e
Compare
028fc7e
to
e2f6bfd
Compare
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.
Looks good!
We should probably run this by Paulus since he had some reservations for Joakim's PR. |
Interesting find in Z-Wave JS
Seems like one of the fixtures exposes a bug in the sensors device class handling? |
Co-authored-by: Martin Hjelmare <[email protected]>
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.
Looks good!
Breaking change
When using
datetime
anddate
device classes in sensors, the returned native value must (respectively) be adatetime
ordate
Python object.Returning an iso formatted date(time) string in these cases is now deprecated and will write a deprecation warning in the logs. This fallback/backward compatibility will be removed in Home Assistant 2022.2.
Proposed change
This PR makes a
datetime
object a valid native state return type for sensors.We currently accept:
None
,str
,int
andfloat
This PR adds
datetime
anddate
to it.It is converted as an ISO 8601 string. This prevents issues like #52666.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: