PVPC tomorrow data not available sensor

It could be nice to have a “tomorrow data not available” as a sensor, because when trying to decide the best period to start an appliance, function gets an error when looking for the best hour for tomorrow if it’s not available. there is surely more ways to handle this, but it would be so easy to control if there is no info for tomorrow if there is a sensor,
thanks!

*thats what i do:
In NodeRed I get values from home assistant this way:


const states = global.get('homeassistant').homeAssistant.states;
var hora = parseInt (states['sensor.pvpc'].attributes.next_best_at[0]) //best hour for today
var hora_minimo =  parseInt (states['sensor.pvpc'].attributes.min_price_at) //its price
var hora_minimo_manana =   states['sensor.pvpc'].attributes['next_best_at (next day)'][0] //best hour for tomorrow

if next_best_at (next day) doesnt exist, it leads to an error that i can catch and make nodered wait for when this is available. If i just could say “if data for tomorrow is false, just dont check it” it would be easy for me to decide if i want to check for an low price hour for today or tomorrow.
The question is function hangs here, i cant say “if this is undefined”, it just stops. (i could go through catching the error, if it’s difficult to improve this)

thanks!

You need to fix your “function” to take this into account.

1 Like

I’ve explained a little more about it, thanks

Unfortunately I know nothing about Node Red, so can’t help other than to move this to the Node Red category if you like.

its just if it is possible to implement a sensor that tells if data for tomorrow is available or not.

Yes, but that is the sort of thing you have to implement.

1 Like