Rest API history and current state

Hello

It seems like the history through the rest api not always contain the latest state of an input_number?
I try to get the history of the last few hours, here it’s a quite newly created input_number.

I’m first reading out the current time of home assistant and use it in the history request (here code is in octave/matlab).

    % get latest time from home assistant (to avoid timezone/utc crap)
    url=strcat('http://',address_hass,'/api/states/sensor.date_time_iso');
    options = weboptions('HeaderFields',{'Authorization' ['Bearer ' auth_token]});
    full_url = [url, "&minimal_response"];
    data = webread(url, options);
    if isempty(data)
      entity_data='error';
      hass_time='Failed to get time from Home Assistant';
      most_recent_states='error';
      return
    end
    data = jsondecode(data);
    hass_time = data.state;

    % get actual data from entity
    base_url = strcat("http://",address_hass,"/api/history/period/");
    end_time = hass_time;
    t = parse_timestamp(hass_time);
    start_time=datestr(t-hours_of_data/24, 'yyyy-mm-ddTHH:MM:SS');
    encoded_end_time= urlencode(end_time);
    encoded_start_time = urlencode(start_time);

    full_url = [base_url, encoded_start_time,"?end_time=", encoded_end_time, "&filter_entity_id=", entity_id,"&minimal_response"];
    options = weboptions('HeaderFields',{'Authorization' ['Bearer ' auth_token]});
    data = webread(full_url, options);

full_url in this exapmle would result in:

http://192.168.0.205:8123/api/history/period/2025-01-06T20%3A31%3A00?end_time=2025-01-06T21%3A31%3A00&filter_entity_id=input_number.tgttempbedroom&minimal_response

However data returns empty, also the specific entity in home assistant says there is no history
image

    full_url='http://192.168.0.205:8123/api/states/input_number.tgttempbedroom'
    options = weboptions('HeaderFields',{'Authorization' ['Bearer ' auth_token]});
    data = webread(full_url, options);

Here the data gives a value as expected

data = {"entity_id":"input_number.tgttempbedroom","state":"8","attributes":{},"last_changed":"2025-01-06T19:55:10.384827+00:00","last_updated":"2025-01-06T19:55:10.384827+00:00","context":{"id":"01JGYJYZNG2218RQVG4ZVY2TCW","parent_id":null,"user_id":"3aad81cb0e584496a5741a371070a0ea"}}

Helpers are not put into history. If you want to save them, you will need to create a template sensor and add the state_class and device_class or unit of measure.

well for some input_numbers I do have history which gets downloaded through the rest api, for others apparently not.