Wrong Day shown in HA

Hi,

I just noticed today that my Home Assistant istance sensor.data, sensor.weekday is reporting wrong information.

If this can help sensor.time is reporting correct time.

Below some screenshot.

Yesterday I noticed that during the afternoon, without any reason, data and weekday changed. So I don’t think is related to time zone. But maybe I’m wrong.

I run Home Assistant 0.108.4 inside my Unraid server using @digiblur hassio supervisor container.

Can someone please support me?

Thank you in advance

UPDATE: if I reboot data is updated

you have to verify that your timezone is set properly. Also make sure your os time is correct. If you are running home assistant supervised with hassOS, you should only have to set the timezone in home assistant.

Yes in HA setting time zone is shown correctly.

I run HA in my unraid server and also there time zone is correct.

well, it’s wrong somewhere on your setup. You gotta figure out where it’s wrong seeing that you’re running non-normal setup.

Oh, well. I know that’s something is wrong but maybe I wrote this post to get support :sweat_smile:

Well, you didn’t post any relevant information. I had to ask you for the info. I’m not sure what you expect. You’ve been here for years and you should know this by now.

Your title and initial post should include all relevant information:

  1. How you installed home assistant.
  2. What Home assistant you are running, Supervised or Core with Version number.
  3. What OS you are running.

And probably most importantly

  1. Where in the interface the time is off with screenshots.

I don’t have a solution for you, sorry, but just wanted to let you know that you are not alone. I’ve had this issue for over a year now. Today is Tuesday and HA shows Sunday. When I reboot, everything comes back to normal for a few days, then gets back to a few days behind.

Sorry Petro. I usually post those info when I think I’m facing a bug.

I thought this was a config error. I’ll edited my original post and title as your suggestion if this can be helpful.

Oh well.

Maybe I’m the same boat. I checked now to do some screenshot and time, weekday and date are now correct. Updated 1 hour ago!

Hey, I updated the original post as your suggestion. It is complete now?

much better. Now, where are you getting sensor.data and sensor.weekday from?

1 Like

Those are template sensor to have info in my native language:

  - platform: template
    sensors:
      data: 
        friendly_name: 'Data'
        value_template: >
          {% set months = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"] %}
          {% set month = months[now().strftime('%m') | int -1] %}  
          {{ now().strftime('%d') + ' ' + month + ' '+ now().strftime('%Y') }}  
          
          
  - platform: template
    sensors:
      week: 
        friendly_name: 'Settimana'
        value_template: '{{(now().strftime("%W"))}}'

  - platform: template
    sensors:
      day: 
        friendly_name: 'Giorno'
        value_template: '{{(now().strftime("%j"))}}'
        
  - platform: template
    sensors:
      weekday: 
        friendly_name: 'Giorno della Settimana'
        value_template: >
          {% if now().weekday() in (0,) %}Lunedì{% elif now().weekday() in (1,) %}Martedì{% elif now().weekday() in (2,) %}Mercoledì{% elif now().weekday() in (3,) %}Giovedì{% elif now().weekday() in (4,) %}Venerdì{% elif now().weekday() in (5,) %}Sabato{% elif now().weekday() in (6,)%}Domenica{% endif %}

Change those from strftime to timestamp_custom(), timestamp_custom will always be local time. I can’t remember if strftime will be local or not. Also, none of those will update because they don’t have anything to update against. You need to add a sensor that updates once a day at least. You could use the sun to cause updates if you wanted, or something that updates periodically but less. You could also incorporate the sensor.date and use that as the entity_id. Below i’m using the sun.sun entity.

  - platform: template
    sensors:
      day: 
        friendly_name: 'Giorno'
        entity_id:  sun.sun
        value_template: '{{ now().timestamp() | timestamp_custom("%j") }}'
1 Like

The other day I helped someone with a similar complaint. Turned out somehow the timezone setting in the configuration file was not the same as the timezone setting in the ui under settings/general. Removing the configuration file entry and setting the ui properly solved the problem.

That’s possible, but all of his templates will not update, he has to at least add an entity_id to them. With their current configuration they will only update on startup.

I changed as you suggested and now after midnight the updated ! Thank you!

1 Like