Following these steps will allow you to integrate this API into the openHAB home automation system.
This enables you to make decisions based on the current or future energy price.
(function() {
const response = actions.HTTP.sendHttpGetRequest('https://pvpc-hourly-spanish-energy-prices-api.p.rapidapi.com/price/0/peninsular', {
'X-RapidAPI-Key': '**YOUR-RAPID-API-KEY**',
'X-RapidAPI-Host': '**YOUR-RAPID-API-HOST**'
}, 10000);
const parsed = JSON.parse(response);
const currentPriceItem = items.getItem('PVPCServer_current_price');
currentPriceItem.postUpdate(parseFloat(parsed['price']));
const currentPriceRating = items.getItem('PVPCServer_Currentpricerating');
currentPriceRating.postUpdate(parsed['price_rating']);
const currentPriceTimeStamp = items.getItem('PVPCServer_Timestampforcurrentprice');
currentPriceTimeStamp.postUpdate(parsed['time']);
})();
configuration: {}
triggers: