Time & Date sensor is not updating

Hi,
I’m using hassio. Since this morning, I see the time is not right and 1 and half hour behind. When I checked the time sensor, it shows it was updated 4 days back, but time based automation worked yesterday. No problem with Time zone and Date & Time settings.

  - platform: time_date
    display_options:
      - 'time_date'
      - 'time'
      - 'date'
      - 'date_time_iso'

Tried to find similar issue but couldn’t find anywhere. Is there any way to sync time manually?

What are you using to view the time? Are you referring to it not updating in your UI? Please use pictures.

the sensor itself not updating

You can see my PC time below.

Do you have a sensor.time_date_2 that is updating?

But, that sensor doesn’t exist in my states page

Ok so the answer is no.

Do you have errors in your logs? Do you have 2 sensor sections in your configuration?

no, I have separate files for all groups. So, I have sensor: !include sensors.yaml in configuration.yaml file and in sensors.yaml,

  - platform: time_date
    display_options:
      - 'time_date'
      - 'time'
      - 'date'
      - 'date_time_iso'

No duplicates in config and sensors files

and errors in your logs?

I’ve checked logs in developer tools, this is the last time $ date related log,

2020-01-17 21:48:01 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.time, old_state=<state sensor.time=21:47; friendly_name=Time, icon=mdi:clock @ 2020-01-17T21:47:01.017919+05:30>, new_state=<state sensor.time=21:48; friendly_name=Time, icon=mdi:clock @ 2020-01-17T21:48:01.012827+05:30>>
2020-01-17 21:48:01 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.date_time_iso, old_state=<state sensor.date_time_iso=2020-01-17T21:47:00; friendly_name=Date & Time (ISO), icon=mdi:calendar-clock @ 2020-01-17T21:47:01.022047+05:30>, new_state=<state sensor.date_time_iso=2020-01-17T21:48:00; friendly_name=Date & Time (ISO), icon=mdi:calendar-clock @ 2020-01-17T21:48:01.017690+05:30>>
2020-01-17 21:48:01 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2962630896] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.time_date, old_state=<state sensor.time_date=21:47, 2020-01-17; friendly_name=Time & Date, icon=mdi:calendar-clock @ 2020-01-17T21:47:01.013664+05:30>, new_state=<state sensor.time_date=21:48, 2020-01-17; friendly_name=Time & Date, icon=mdi:calendar-clock @ 2020-01-17T21:48:01.008223+05:30>>}
2020-01-17 21:48:01 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2962630896] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.time, old_state=<state sensor.time=21:47; friendly_name=Time, icon=mdi:clock @ 2020-01-17T21:47:01.017919+05:30>, new_state=<state sensor.time=21:48; friendly_name=Time, icon=mdi:clock @ 2020-01-17T21:48:01.012827+05:30>>}
2020-01-17 21:48:01 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2962630896] Sending {'id': 2, 'type': 'event', 'event': <Event state_changed[L]: entity_id=sensor.date_time_iso, old_state=<state sensor.date_time_iso=2020-01-17T21:47:00; friendly_name=Date & Time (ISO), icon=mdi:calendar-clock @ 2020-01-17T21:47:01.022047+05:30>, new_state=<state sensor.date_time_iso=2020-01-17T21:48:00; friendly_name=Date & Time (ISO), icon=mdi:calendar-clock @ 2020-01-17T21:48:01.017690+05:30>>}

Please let me know if I want to fetch logs in any other way (I don’t know much about debugging).

Yes that’s a normal update. We need to find whats causing it to not update. Looking for errors is simple. Look for the word ERROR, then any indication what platform/integration it’s coming from.

Checked complete log with search term ERROR, getting hundreds of errors related to components that I don’t use. Later searched with ERROR (MainThread) and ERROR (, no key words related to time & date found.

is there any way to fetch/refresh time using ssh in hassio?

No, it should be updating. Can you post a snip-it of a few different types of errors?

These are errors I get when I searched with ERROR (MainThread)

2020-01-17 22:06:52 ERROR (MainThread) [frontend.js.latest.202001082] http://hassio.local:8123/lovelace/home:0:0 Uncaught
2020-01-17 22:02:41 ERROR (SyncWorker_2) [homeassistant.loader] Error parsing manifest.json file at /config/custom_components/emulated_hue/manifest.json: Expecting value: line 7 column 1 (char 6)
2020-01-17 22:02:50 ERROR (MainThread) [homeassistant.components.media_player] Error while setting up platform vlc
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 158, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/vlc/media_player.py", line 46, in setup_platform
    [VlcDevice(config.get(CONF_NAME, DEFAULT_NAME), config.get(CONF_ARGUMENTS))]
  File "/usr/src/homeassistant/homeassistant/components/vlc/media_player.py", line 55, in __init__
    self._instance = vlc.Instance(arguments)
  File "/usr/local/lib/python3.7/site-packages/vlc.py", line 1551, in __new__
    return libvlc_new(len(args), args)
  File "/usr/local/lib/python3.7/site-packages/vlc.py", line 3903, in libvlc_new
    ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
  File "/usr/local/lib/python3.7/site-packages/vlc.py", line 246, in _Cfunction
    raise NameError('no function %r' % (name,))
NameError: no function 'libvlc_new'

2020-01-17 22:02:53 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 417, in _async_add_entity
    await entity.async_added_to_hass()
  File "/usr/src/homeassistant/homeassistant/components/met/weather.py", line 82, in async_added_to_hass
    await self._fetch_data()
  File "/usr/src/homeassistant/homeassistant/components/met/weather.py", line 146, in _fetch_data
    self._update()
  File "/usr/src/homeassistant/homeassistant/components/met/weather.py", line 153, in _update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 297, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 327, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "/usr/src/homeassistant/homeassistant/components/weather/__init__.py", line 167, in state_attributes
    forecast_entry[ATTR_FORECAST_TEMP],
KeyError: 'temperature'

2020-01-17 22:06:52 ERROR (MainThread) [hacs] Tried to serve up '/config/www/community/light-entity-card/light-entity-card.js' but it does not exist

I’m getting these logs in Logs under Developer tools. Just wanted to make sure I’m getting these logs from right place.

yes, all those are correctable. They are coming from custom components that you have installed. Also, errors are inside home-assistant.log.

You should clean up your logs and fix all your errors. Errors like these could be causing the issues that you’re seeing. It’s hard to say.

  • vlc media player
  • hacs - Home Assistant Community can’t use light-entity-card because it’s not installed.
  • met weather has an error
  • You’re using a custom emulated_hue that has bad file.

Sure, thanks for the suggestion. Before I don’t know these components have errors and today for the first time I’m checking logs and I’ll further find any other errors in this log and clear them.

But didn’t find the exact cause for the date and time sensor.

I’ll try to remove and add the sensor and if it doesn’t help, may be I have to go for a fresh installation.

I’ve cleared all ERRORs and still can’t find the exact cause for the time and date issue.
I can see that all logs and history saving in to database, yesterday the last logbook entry was on 17 January and today I checked, it’s 18 Jan. It clearly saving all sensor data, but showing them as 4 days back logs (except weather showing right date on logs).
However, I’m backing up all data to format the sd card and flash again with recent hassio build.

it’s still tricky though, showing right date in logbook and history tab (showing entities for January 22, 2020). This means HA actually knows it’s Jan 22? Checked date command via SSH, shows Jan 18. All entities recording date as 4 days back from now.

SSH does not connect to HA, but to the OS so it sounds like you are in two different time ‘zones’ (for the want of a better word) HA / OS.
What is your base OS ?
Can you ssh a time update to it ?
Has it got a wired ethernet ?
Have you tried rebooting the whole installation ?

Im using hassio on RPi4 v 0.104.3 connected with Ethernet. Don’t know much about ssh commands (I see only few commands available for hassio users).
Still trying to make it work and each time I make change, restarting hassio and complete host system just to make sure to apply changes. But nothing changed.