Attributes in multiscrape are output as "str" and not, as desired, as "datetime"

Hello,

I’m having trouble defining an attribute as “datetime”. Whenever I access it, the object is displayed as a string.

multiscrape:
  - resource: https://www.eurosport.de/watch/schedule.shtml
    headers:
      {
        "User-Agent": "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
      }
    sensor:
      - name: eurosport1_epg
        unique_id: eurosport1_epg
        select_list: 'div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(1) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(1)'
        value_template: "{{ value | trim }}"
        attributes:
          - name: title
            select_list: 'div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(3) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span:nth-child(3)'
            value_template: "{{states.sensor.eurosport1_epg.state}}{{' | '}}{{ value | trim }}"
          - name: Start
            select_list: 'div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2)'
            value_template: "{{(((now().strftime('%Y-%m-%d')~' '~value[:5]) | as_datetime).isoformat()) | as_datetime}}"
          - name: End
            select_list: 'div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2) , div.\!w-\[267px\]:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > span:nth-child(2)'
            value_template: "{{(((now().strftime('%Y-%m-%d')~' '~value[8:]) | as_datetime).isoformat()) | as_datetime}}"
          - name: test
            value_template: "{{as_datetime(now())}}"

Is there a way to pass a “datetime” object directly as an attribute in multiscrape?
Thank you in advance

All states and attributes are stored as strings inside HA.
You can change the format of a datetime for storage or displaying with the appropriate templating functions:

That’s not true, attributes can be native types like integers, floats, booleans, lists, mappings/dictionaries and also datetime objects.
For example, the last_triggered attribute of an automation is a datetime object, not a isoformat datetime string.

However, the template parser converts datetime objects to a datetime string, so using templates you won’t be able to set a datetime object as attribute.

1 Like

That’s a shame, but thank you for the reply anyway.