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

input_datetime - timestamp attribute is incorrect #13396

Closed
point-4ward opened this issue Mar 22, 2018 · 5 comments
Closed

input_datetime - timestamp attribute is incorrect #13396

point-4ward opened this issue Mar 22, 2018 · 5 comments

Comments

@point-4ward
Copy link
Contributor

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.65.6

Python release (python3 --version):
3.6.4

Component/platform:
input_datetime

Description of problem:
The timestamp attribute of the input_datetime's are an hour out. There was this issue - #10784 - (that I opened ages ago, and was fixed) where they were displaying an hour out, but this is different. Trying to use the timestamp attribute to do a calculation on the time does not work correctly.

Expected:
Timestamp to be correct.

Problem-relevant configuration.yaml entries and steps to reproduce:

input_datetime:
  my_test:
    has_date: false
    has_time: true
  1. Add the above to configuration.yaml
  2. Set the datetime to any time you like
  3. Go to template page and convert the timestamp attribute to the time

{{ (states.input_datetime.my_test.attributes.timestamp) | timestamp_custom("%H:%M") }}

  1. Note that the output is an hour out.
@Mariusthvdb
Copy link
Contributor

Mariusthvdb commented Mar 22, 2018

+1!!
so glad you bring this up, been struggling with these time issues in Python for a longer period now....

Trying to solve it by adding +1 manually seems to work in the frontend, but throws many many errors. Besides that, it is of utmost awkwardness the time is off while it shouldn't in the first place...

this is a typical piece of code in my scripts:

for entity_id in hass.states.get(switches_group).attributes['entity_id']:
    dt = hass.states.get('automation.sense_switches_change').attributes.get('last_triggered')
    dt = dt + datetime.timedelta(hours=+1)
    time = '%02d:%02d' % (dt.hour, dt.minute)

errors are that im am adding two different types (especially when the automation isn't set yet, Nonetype)..
All i am asking is for help, and hope this is solved somehow. Its not only a input_datetime thats off. Its a more global time-setting issue, that should be taken care of globally, not per script or entity....

maybe im doing thing wrong, the time is there somewhere:

correct time:
schermafbeelding 2018-03-22 om 21 26 39

filtering the attributes changes it:
schermafbeelding 2018-03-22 om 21 28 06

schermafbeelding 2018-03-22 om 21 28 19

Cheers,
Marius

@OttoWinter
Copy link
Member

I suspect this might be due to timezones... Do you have time zone set as in https://home-assistant.io/docs/configuration/basic/?

@point-4ward
Copy link
Contributor Author

Yup, Europe/London.

All my times and everything display correctly, it's just the timestamp that is an hour out. We go to British Summer Time in the UK in 27 hours, so by all means wait for that and I'll let you know if it corrects when in BST or not.

@point-4ward
Copy link
Contributor Author

point-4ward commented Mar 24, 2018

Ooh - interesting to note, this...

trigger:
  platform: template
  value_template: "{{ states('sensor.time') == (states.input_datetime.bedroom_alarm_clock_time.attributes.timestamp | int | timestamp_custom('%H:%M', False)) }}"

still triggers the alarm clock at the right time, so I'm totally baffled.

Only 5 hours until BST, I'll update tomorrow whether it changes anything...

@point-4ward
Copy link
Contributor Author

Arghhhh - so, I worked this out (sort of) and it's not an issue - It was staring me in the face the whole time. I don't know what the boolean 'false' does in the second example I gave, but if included the calculation works as expected - so I'll close this issue, but if anyone feels like explaining what the boolean is for and why it needs to be set to false to get the correct time I would appreciate it just for my own curiosity.

Thanks all.

@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants