Datetime component

Hi,
In a lot of my esphome projects I needed a time of day value provided by the user after compile time.
No problem in Ha, there we have the input_datetime component, but in esphome we had to work around the none existing datetime component.

A practical way to create a similar option in esphome was to create a select component with a list of times and strore the selected one in a globals component, then we created a intervall component and check every second if the current time matches our selected time.

I got tired of that and was never happy to have to scroll through a long list to select a time, so I create my own datetime component.
It was a lot of work since it had to be intergrated into the core to be able to set the a time via the web_server component.

it is not part of esphome yet and since it is not just a simple custom component you would need to build a custom version of esphome from my github

I also had to modify the web_server component which you can get here

My plan would be to get it fully intecrated into esphome and the api, but only if there is a need for it.
Let me know what you think about this.
More informations and some example yamls can be found here

Here is what it is going to look like on different platforms.









5 Likes

Hello, very nice.
I’m interested about this but i don’t know how to use your github repo to build a esphome docker container.
I’ve tried building it with a stack from portainer but docker-compose.yml is missing for that purpose.
How can i install this? I’m too much of a beginner. Thank you anyway!

Hi,
I am not familiar with Docker, but

docker build -t esphome -f docker/Dockerfile .

executed in the ‘esphome-add-datetime’ folder should build a docker

Here is a way you could install it on a windows maschine using PowerShell
Assuming you have Python and PIP installed
Step 1.
Download the zip file of this repo and extract its content
https://github.com/RFDarter/esphome/archive/refs/heads/add-datetime.zip

Step 2.
Open a PowerShell and navigate to the downloaded folder

cd C:\Users\darter\Downloads\esphome-add-datetime\esphome-add-datetime

Step 3.
Create a Virtual Environment

python3 -m venv .venv

Step 4
Activate it

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
.venv\Scripts\activate

if it worked your promt should have changed to
(.venv) PS C:\Users\darter\Downloads\esphome-add-datetime>

Step 5
Install esphome on this virtual environment using the downloaded fork

pip install -r .\requirements.txt
pip install -e .

Step 6.
Use esphome as normal

esphome run my_config.yaml

To use it again after you closed the PowerShell just redo Step 4

Nice, i will try it.
Hoping we can have this component in the official version soon.
Thank you very much!