Cool, thanks for sharing.
I was going to start trying to put together an example, but @VeloWulf already has a great start here: Coding an HTTPS request with authentication - #19 by VeloWulf
You could use a structure similar to @VeloWulf's pollASNServer()
from hubitat-myenergi-app.groovy in place of runCmd()
in the code you are using now.