Get historic variable value

With a little D-tour:
The Device Capabilities app has the perfect flowcard, and you can emulate it in Hscript

Explained:

You can emulate most AND & THEN flowcards in Homeyscript.
Check example-flowcard-run on how to do that.
Now, when you haven’t already, install Device Capabilities app first
When you run example-flowcard-list it will return all And & Then cards available on your Homey → you can search for the Device Capabilities card ‘Then’ ‘Retrieve the insights value from’
(this script can take quite a while to finish, remove the ‘And’ part in order to show the ‘Then’ part results way more quicker)