Whats wrong with my config? input_datetime unavailable!

Despite having an entry in my configuration.yaml for “default_config:” I’m getting these errors.
Also, when I check my configuration it reports as being valid.
Any idea?

There is something wrong with where or how you have defined default_config. Show your (sanitised) config for help with this.

In the Configuration.yaml file

I would # the Input_datetime bits

#  last_rain:
 #   name: Time of last reported rainfall
 #   has_date: true
 #   has_time: true

do a Configuration check and a reboot and see if you still getting same errors

added the configuration.yaml
nothing fancy, pretty basic really

Next thing to look at is your input_datetime config (copy and paste, not screenshot).

```

surround your pasted code in three backticks like this to format it propertly

```

oh sorry about that.
not sure I understood, there’s nothing more, that’s the whole configuration.yaml

this is a windows/python server if that makes any difference

The notification only tells you there was a problem, not what problem.
Most likely there will be more details in the logfile.
Either via the interface, development tools -> logs or otherwise, check the file home-assistant.log next to configuration.yaml

here:

2020-05-29 14:58:43 ERROR (MainThread) [homeassistant.setup] Error during setup of component input_datetime
Traceback (most recent call last):
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\setup.py", line 170, in _async_setup_component
    result = await component.async_setup(  # type: ignore
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\components\input_datetime\__init__.py", line 113, in async_setup
    await storage_collection.async_load()
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\collection.py", line 172, in async_load
    await self.notify_change(CHANGE_ADDED, item[CONF_ID], item)
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\collection.py", line 111, in notify_change
    await listener(change_type, item_id, item)
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\collection.py", line 269, in _collection_changed
    await entity_component.async_add_entities([entity])
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 295, in async_add_entities
    await asyncio.gather(*tasks)
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\entity_platform.py", line 445, in _async_add_entity
    entity.async_write_ha_state()
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 297, in async_write_ha_state
    self._async_write_ha_state()  # type: ignore
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\helpers\entity.py", line 323, in _async_write_ha_state
    attr.update(self.state_attributes or {})
  File "C:\Users\Joaquim\AppData\Local\Programs\Python\Python38\lib\site-packages\homeassistant\components\input_datetime\__init__.py", line 329, in state_attributes
    attrs["timestamp"] = self._current_datetime.timestamp()
OSError: [Errno 22] Invalid argument
2020-05-29 14:58:45 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: input_datetime
2020-05-29 14:58:45 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: Could not set up all dependencies.

Anyone there?
Still waiting for some help please!

The log file clearly shows that Home Assistant failed to load the module that implements input_datetime. That explains why input_datetime is unavailable for use. However, the deeper question is why did it fail to load the input_datetime module? This line seems to be the key but, unfortunately, I don’t understand its cause:

OSError: [Errno 22] Invalid argument

Thanks,
Is there anything I can try before reinstalling the whole thing?

Unfortunately, due to my unfamiliarity with the root-cause of this issue, I’m in no position to offer advice.

All I can say is that if I were in the same position, I would also consider re-installing it.

I’ve fixed it!
After a bit of digging in homeassistant internals, I found an ‘input_datetime’ file inside ‘.storage’ folder.
I’ve opened it with a text editor and inside was an old configuration I did some time ago, that was the root cause of the issue.

Once I deleted this file, the startup notification is gone and the helper is again available.
Thank you all for your time.

That file is created when you define an input_datetime via Configuration > Helpers. Its mere presence is not the ‘root cause’. The file will re-created when you define your next input_datetime. The problem may have been due to data corruption (i.e. the file’s contents were not in proper format).

Were you able to observe if it was valid JSON format?

1 Like

yes, you’re absolutely right, it gets re-created and the issue is back :frowning:
I can’t evaluate its correctness but leave it here for you to have a look:

{
    "data": {
        "items": [
            {
                "has_date": true,
                "has_time": true,
                "icon": "mdi:timer",
                "id": "timer",
                "name": "Timer"
            },
            {
                "has_date": true,
                "has_time": true,
                "id": "timer_2",
                "name": "timer"
            },
            {
                "has_date": true,
                "has_time": true,
                "id": "timer_3",
                "name": "Timer"
            },
            {
                "has_date": false,
                "has_time": true,
                "id": "timer_4",
                "name": "Timer"
            }
        ]
    },
    "key": "input_datetime",
    "version": 1
}