Manually adding values to sensor's data

Hi,
I would like to quantify some personal behaviors in Home Assistant. One example use case for today: sleep time. Let’s say I want to compare my real bedtime to the estimation from my watch.

I created a helper toggle in home assistant. Yet, if I forget to toggle it when waking up, the value will be completely wrong.

So I have two questions:

  • How can I manually edit the timestamp of a sensor value? Do I have to ssh connect to the server and perform an sql request? I went to “Dev Tools ⇒ States” tab, and this toggle doesn’t show ‘last_changed’ in the state_attributes list. (even if it had, I was looking for a more friendly option to fix this artificially)

  • Is it possible to create some kind of helper entity that would be a combo of “Date and/or Time” (meaning 'editable by the user) and ‘Text’ (or ‘Select’). I mean, at the end of the day, it would be something like a real form for Select, but where the timestamp is not dictated by the state change time, but by the “input datetime” value. That way I could have a form to add missing values, whether the entire interval is missing or just one end of it.

Thanks.

Server info:

  • HA docker image 2025.1.2 on Debian 12, not the full HAOS.

Thanks @tom_l
How can I specify a state to the input-datetime. Afaik, it will not tell me whether the datetime is for sleeptime_on or sleeptime_off, will it?

I can’t see such config in the doc link you provided, did I miss it?

You can enter the date manually in your dashboard or you can set it in an automation or script. See the set_datetime action.

It wont “tell” you anything. You specify what it is for. If you want both start and end times then use two input_datetimes, one for start date and time and one for end date and time. Call them input_datetime.sleep_start and input_datetime.sleep_end. Then you know which is which.