Hi Will
I’m a bit confused - your settings for input_number and automation are fine, and the command you have in the sensor must be working to some extent if you’re getting results returned in the right ballpark. Having results of 50 and 2 in my mind would indicate some sort of issue with timestamping. As per my previous posts, Octopus usually updates the previous day’s measurements to their API between 6-10am, so between midnight and the update time you should usually get 0 results because the command is requesting results between 0000 and 2359 the previous day, which aren’t yet available.
I presume you’re replacing the xxxxxxxx part with your API key authorisation code obtained with the instructions I posted in post #15 above? → Templates in command line sensor + Octopus Energy API - #15 by ajoyce
Either way if it’s authorising, then great!
I have two suggestions:
-
try appending a timezone to the times in your command and see if this changes anything:
curl -u "APIKey:" "https://api.octopus.energy/v1/electricity-meter-points/MPN/meters/SERIAL/consumption/?period_from={{ (as_timestamp(now()) - 86400) | timestamp_custom("%Y-%m-%d", True) }}T00:00:00+01:00&period_to={{ (as_timestamp(now()) - 86400) | timestamp_custom("%Y-%m-%d", True) }}T23:59:59+01:00"
-
switch to using the bash script version as per post #39
Let me know how you get on!