I hate to resurrect and old thread but I have been trying to get this working for my own HA instance with my Octopus Tracker.
I have the below code which works fine and pulls tomorrows Electric and Gas prices from the Octopus API. I have disabled the scan_interval and run homeassistant.update_entity in an automation.
My biggest issue Is I’m seeing a ton of errors in my logs related to the above. Any idea how to resolve the below errors?
2023-08-03 09:04:37.810 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:04:37.816 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:05:07.482 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:05:07.486 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:05:37.420 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:05:37.424 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:06:07.425 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:06:07.429 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:06:37.407 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
2023-08-03 09:06:37.410 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: list object has no element 0 when rendering '{{(value_json.results[0].value_inc_vat) | round (4) }}'
@j1234 I really think you should look at your rest sensors again and change the scan_interval to something MUCH less aggressive. Do you really need all 4 sensors to be checking every 10 seconds? That frequent an update might get you rate limited/banned. Once an hour should be sufficient being as prices are static for the day
@Alister yes, same for me from the integration. No update since 1st October.
Interestingly mine is working, but the rate updates at 1pm in the afternoon instead of just after midnight as it did up until 1st October. Do other people get the same?
For someone or those who want to Automate specific price i have a simple code you can add to this developed code to archive this - you just add as a condition in HA