Skip to content
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 date_time_iso to time_date sensor #22199

Merged
merged 3 commits into from Mar 21, 2019

Conversation

Projects
None yet
5 participants
@uchagani
Copy link
Contributor

commented Mar 20, 2019

Description:

This PR adds a date_time_iso sensor to the time_date sensor platform. This will us to easily write template triggers that compare the current time against the state of another entity since all entities that use the DEVICE_CLASS_TIMESTAMP device class are required to be in ISO format.

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#8995

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: time_date
    display_options:
      - 'date_time_iso'

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

uchagani added some commits Mar 20, 2019

@uchagani uchagani referenced this pull request Mar 21, 2019

Merged

add doc for date_time_iso to time_date component #8995

2 of 2 tasks complete
@fabaff

fabaff approved these changes Mar 21, 2019

@fabaff fabaff merged commit 21871b3 into home-assistant:dev Mar 21, 2019

4 checks passed

Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.002%) to 93.686%
Details

@ghost ghost removed the in progress label Mar 21, 2019

@balloob balloob referenced this pull request Apr 3, 2019

Merged

0.91.0 #22688

@akasma74

This comment has been minimized.

Copy link
Contributor

commented Apr 4, 2019

Description:

This PR adds a date_time_iso sensor to the time_date sensor platform. This will us to easily write template triggers that compare the current time against the state of another entity since all entities that use the DEVICE_CLASS_TIMESTAMP device class are required to be in ISO format.

could you give an example?
I thought times are compared not as strings..

@uchagani

This comment has been minimized.

Copy link
Contributor Author

commented Apr 4, 2019

@akasma74 say you have a sensor that has a state of 2017-05-18T00:54:00, and you want to create an automation that runs at that time. Before this PR, you would have had to use the time_date sensor, convert it to ISO format, then compare it to the state of the sensor in question. Now you can just compare directly without having to convert anything. it would be a simple template trigger where the state of date_time_iso equals the state of my sensor.

#Automation with template trigger
    value_template: '{{ states.sensor.my_sensor == states.sensor. date_time_iso.state }}'
@akasma74

This comment has been minimized.

Copy link
Contributor

commented Apr 4, 2019

Thanks.
But are there many sensors of that type around?
I mean, is it typical to have a sensor that has a date in future as its state?

@uchagani

This comment has been minimized.

Copy link
Contributor Author

commented Apr 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.