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

Dates off from what is set to what is in Attributes #106

Closed
tetragram55 opened this issue Jun 15, 2021 · 44 comments
Closed

Dates off from what is set to what is in Attributes #106

tetragram55 opened this issue Jun 15, 2021 · 44 comments
Labels
bug Something isn't working

Comments

@tetragram55
Copy link

tetragram55 commented Jun 15, 2021

I love this add on, thank you for making it.
I noticed this today, I don't know when it started but it wasn't always like this.
I am using core-2021.6.4 with the latest version of Anniversaries
The date set in the set up is as follows:
HASS-Anniv-error-2

But what is shown in Attributes is this:

HASS-Anniv-error

@bbgott
Copy link

bbgott commented Jun 21, 2021

I'm having the same issue, but I am noticing it is only happening to newer entries. Birthdays or anniversaries that I had in there from before are displaying the correct date.
I am running core-2021.6.5 and Anniversaries version 4.3.1

@pinkywafer
Copy link
Owner

Unable to reproduce.... Can you give any more info?

@Grey-Lancaster
Copy link

not sure what info you need. same issue. Not sure when HA changed to the dropdown box to see the dates. Did not notice it before. Timezone America/Indiana/Indianapolis units imperial/Fahrenheit

image
image

@Grey-Lancaster
Copy link

perhaps having different sensor names?
image

@pinkywafer
Copy link
Owner

Sensor names shouldn't affect it.... But I'm wondering if timezone could be affecting it... The sensor is based on the date, so effectively the time in the datetime object is 0:00:00. I'm wondering if this is the issue... I'll investigate.

Also, just as a check.. can you tell me if the countdown number of days is reporting correctly, ie. It's not also a day off?

@Grey-Lancaster
Copy link

if I ask google how many days until it matched the # of days you display

@pinkywafer
Copy link
Owner

Thanks. I'll look into the date... Expect it's timezone related

@Grey-Lancaster
Copy link

The date should not be calculated in attributes ? It should just pull/match from the input?

@Grey-Lancaster
Copy link

Or does it need to be calculated for the half anniversary?

@pinkywafer
Copy link
Owner

It's checked and converted to a datetime rather than a text (it could come from a template in the configuration.yaml) so it's most likely to be there. Ie if the date returned to home assistant is 15/7/21@0:00:00UTC, that would equate to 14/7/21@20:00 Washington

That's what I'm expecting anyway.... Leave it with me!

@pinkywafer
Copy link
Owner

well, so far, I'm drawing a blank.

If I add some extra debug lines would anyone who has this issue mind testing and send me back the logs please.

@pinkywafer
Copy link
Owner

OK, I've published a beta release with debug logging in an attempt to find out where this issue is coming from.
to install it using hacs, go to your integrations. Find the Anniversaries integration. Press the menu (Three dots). Press Reinstall.
You should be presented with the option to select the version to install. Turn on show beta versions.
Choose version 4.4.1b1

to enable the debug logging, you will need the following in your configuration.yaml:

logger:
  default: warning
  logs:
    custom_components.anniversaries: debug

reboot home assistant and we should get some logging information

@pinkywafer pinkywafer added the bug Something isn't working label Jul 15, 2021
@Grey-Lancaster
Copy link

How long will it take for a debug file to show? I have installed 1b1 added logger: and rebooted, but I do not see anything

@pinkywafer
Copy link
Owner

The log entries should appear as soon as you reboot (assuming you have anniversary sensors configured) or whenever you add a new one on the integrations page. The logs should be in your main home assistant log. - on the log page you need to press load full home assistant log

@Grey-Lancaster
Copy link

I was looking in the aniverseries folder. I misspelled test lol

anniversaries
Version: 4.4.1b1
This is a custom integration
If you have any issues with this you need to open an issue here:
https://github.com/pinkywafer/Anniversaries/issues

2021-07-15 16:21:40 DEBUG (MainThread) [custom_components.anniversaries.sensor] teat - config string - 2020-07-17
2021-07-15 16:21:40 DEBUG (MainThread) [custom_components.anniversaries.sensor] teat - date - 2020-07-17 00:00:00
2021-07-15 16:21:40 DEBUG (MainThread) [custom_components.anniversaries.sensor] teat - formatted date - 2020-07-17
image

@pinkywafer
Copy link
Owner

Ok, so I believe that the issue started when Home assistant started using native types instead of attributes just being text.

In the example @tetragram55 gave at the beginning, the date in attributes is now listed as: December 21, 1960
This (ignore that it's the wrong date for now) is a home assistant date formatted by home assistant.
The date format option is configured as %Y-%m-%d which should give 1960-12-22

So I have two options:

  1. Keep the optional formatting and force the date attribute the be returned as a text
    Or (and I think my preferred option)
  2. Remove the configuration option for date format and let home assistant deal with the formatting and just ensure that the date is passed in a 'local' manner so that timezone issues do not give the wrong date

My reasoning for choosing 2... No-one has raised any issues regarding the lack of formatting in the date attribute, so I'm assuming that it hasn't caused any issues. Also, using the native format should actually make any templating on this attribute easier. Additionally, of the date is formatted by home assistant, it then visually matches all other dates in home assistant.

@Grey-Lancaster
Copy link

well I really have no idea what you just said :)
All I want to do is when I expand attributes I want to see the actually date, not one off :) Again could you just not show what the thing was set for without any calculation? The # of days is correct.
Thanks for working on it.
Grey

@bbgott
Copy link

bbgott commented Jul 16, 2021

I like the sound of option 2 because it will visually match other dates in home assistant

@Grey-Lancaster
Copy link

Any progress on this issue? I do not want to miss my Birthday ;-)

@pinkywafer
Copy link
Owner

pinkywafer commented Jan 4, 2022

Can anyone please try the 2022.01.04 release and let me know if that solves it? - For manual install, you only need the sensor.py from the timezone-fix-test branch.
To do hacs install, go to hacs and find the anniversaries integration. Click the menu (3 dots). Choose Redownload. Ensure Show beta versions is turned on and choose the 2022.01.04 release. You'll need to reboot Home Assistant

@Grey-Lancaster
Copy link

image
I did : To do hacs install, go to hacs and find the anniversaries integration. Click the menu (3 dots). Choose Redownload. Ensure Show beta versions is turned on and choose the 2022.01.04 release. You'll need to reboot Home Assistant

@pinkywafer
Copy link
Owner

Sorry my bad... I used an invalid version number.
I think I've fixed that now if you can redownload.

If not, revert to stable and I'll look again tomorrow

@Grey-Lancaster
Copy link

No it is all wrong. It did not fix previous so I made a new entry for March 13th. It still shows March 12th in attributes and the days (perhaps I should not have selected default, is off )
image

@Grey-Lancaster
Copy link

Yes, I selected count up and I should have not checked anything

@pinkywafer
Copy link
Owner

So still just date that's off?

@Grey-Lancaster
Copy link

yes,
image

@pinkywafer
Copy link
Owner

can you tell me if the sensor is updating at midnight (as it should) or at some other time?

@Grey-Lancaster
Copy link

Midnight

@pinkywafer
Copy link
Owner

Thanks - it looks like a frontend issue - I think I'm getting somewhere now!
seems unrelated to #110

@pinkywafer
Copy link
Owner

ok. The date is correct (internally): the template: {{state_attr("sensorname","date")}} returns the correct date.
The problem is that the UI recognises the attribute as a date, assumes it's UTC and converts it in the UI only to the date to suit the browser settings
bitmoji
This is NOT what is intended. I'll look into a way to stop this or a workaround.
In the meantime, anything else that reads the attribute should get the correct value!

@pinkywafer
Copy link
Owner

can you try the 2022.01.07 beta please?
I've forced the date into the "default" timezone. Hopefully this will cure the issue, but we've lost the option to format the date - something that I think we'll just have to live with as this is how the UI now works

@Grey-Lancaster
Copy link

Grey-Lancaster commented Jan 7, 2022

I also created a new one and it is the same, one day off

image

image

image

@pinkywafer
Copy link
Owner

Ok, let's try with the full datetime object - can you try 2022.01.07-2 please

@Grey-Lancaster
Copy link

dash 2 is not showing up for me yet

@pinkywafer
Copy link
Owner

on hacs, find anniversaries - press 3 dots - update information.
This saves you waiting for hacs to update!

@Grey-Lancaster
Copy link

well that is not working at all dash 2
image

@pinkywafer
Copy link
Owner

OK - Home Assistant doesn't like dash in release numbers....
try 2022.01.07r2 instead!

@Grey-Lancaster
Copy link

working on it
figured I best do a full backup first :-)

@Grey-Lancaster
Copy link

sorry, no change on old entries or new ones
image

@pinkywafer
Copy link
Owner

My bad... in my haste I released from the wrong branch!

can you try r3

@Grey-Lancaster
Copy link

That works, shows 12:00am
YEA :-)
image

@pinkywafer
Copy link
Owner

bitmoji
Thanks for your help.
I've had enough for tonight!
I'll sort out removing the unneeded config options etc and updating docs then I'll make a new release.

@Grey-Lancaster
Copy link

I figured you must not be on my side of the pond. Sleep well and thank you !

@pinkywafer
Copy link
Owner

closed by #114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants