I am using the tankerkoenig node to fetch gas station prices. The result is in json format, the value "prices" goes into an InfluxDB and grafana. Example for the json:
What isn't nice is that even if the gas station is closed, a price is reported and displayed. A price for something that I can't buy (because it's closed) looks wrong to me in the graphic. That's why I'm wondering how I can evaluate the key "isOpen" so that if it's "false", nothing is written to the database?
let x = (the message you receive with the gas price)
if (x == undefined)
{
// set the part of the message to be 0
}
Then if that part of the message doesn't exist, you get 0.
Or what ever you wan it to be.
Just a thought.
Ok, after a bit more thought looking at your message:
let x = msg.price
if (x == undefined)
{
// What eve you want to do.
}
Maybe return?
You may need to post the message you get when it is closed.
Ok, third time lucky:
let x = msg.isOpen
if (x == false)
{
msg.price = ""
}
return msg
Maybe?
Or:
let x = msg.isOpen
if (x == true)
{
return msg
}
return
In the last one if it is false (closed) you could just return rather than return msg.
Then nothing would be sent and therefore not add to the database.
Sorry, brain is not playing nicely with me just now.
thanks for all your answers. I choose the switch node with "payload.isOpen" "is true". That work fine. Prices (or dots in the grafana board) only when the gas station is open.
Thanks so much, Micha