Integration of weird Javascript API

Hey guys,
I have a Varta Battery Storage which is not officially supported (i.e. has no existing integration) but provides a local API.

The problem is: the API is not JSON, XML or something standardized/useful, but just a .js located at http://[deviceip]/cgi/ems-data.js

The response looks like this:

Zeit = "14.02.2022 00:07:25";
WR_Data = [-2500,2500,109,-577,0,0,0,0,19,17,18,0,0,1,4,0,"255.255.255.255",0,0,0,0,0,0,0,112,1,0,0,2500,2500,2500,2500,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
EMETER_Data = [2356,-50,-47,-1031,4991,1,0,0,0,0,0,0,-51,-49,-1037,-5,-10,-121];
Charger_Data = [[0,1,0,0,4792,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1731,577,0,100,0,0,34819,0,0,0,4,4,75,20,5,1860,0,
["LG_Neo",5,0,0,4800,0,10,980,581,310,100,0,
  [ [0,0,0,0,0,0,40,985,480,0,3423,3443,3429,31,10,1512,526,0,0,0,0,167,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]  ]
]
]
];

How can I get those values into my Homeassistant?

Thanks for your help in advance.

PS: I am of course aware that I have to figure out which of these values is which, but that’s not the problem atm

The way I would approach this is to write a custom component that fetches the JavaScript and then use regular expressions to extract and interpret the data, and subsequently generate entities.

Thanks for your reply.
Since I’m pretty new to HA, can you point me to some example or other resources that could help me? I’m not exactly sure what to search for tbh.
I’ve read into various topics already, but all I can seem to find is either using JSON/REST or some specific question that is not related to my problem

edit: I just found this Creating your first integration | Home Assistant Developer Docs - I didn’t know about the developers documentation, maybe I just searched too spefically before. I’ll look into this

If you are looklng for a simple example, here is the code of a custom component where I grab a HTML snippet and then use a regular expression to a device status to create a binary sensor.

You could create a script that runs from time to time and retrieves the data, parses it and creates a new file in the expected format, like json, yaml, xml, …

Then you would read from the new file.