Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
mortesan 9
I have created a LUA scene to fetch the current electricity prices from Tibber, I then store the values in global variables. This can again be used to control appliances according to prices.
Tibber api:
Please login or register to see this link.
In the scene below I have used a demo token from tibber.
LUA scene:
local http = net.HTTPClient();
http:request('https://api.tibber.com/v1-beta/gql',{
options = {
method = 'POST',
headers = {
["Content-Type"] = 'application/json',
["Authorization"] = 'Bearer d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a'
},
data = '{ "query": "{viewer {homes {currentSubscription {priceInfo {current {total energy tax startsAt }}}}}}" }'
},
success = function(resp)
if (resp.status == 200) or (resp.status == 201) then
local data = json.decode(resp.data);
fibaro:debug(resp.data);
print ("price: "..tostring(data.data.viewer.homes[1].currentSubscription.priceInfo.current.total));
fibaro:setGlobal('Strompris',data.data.viewer.homes[1].currentSubscription.priceInfo.current.total);
else
fibaro:debug(resp.status);
fibaro:debug("ERR");
end
end,
error = function(error)
fibaro:debug"ERROR"
fibaro:debug(error)
end
})
fibaro:sleep (90000);
fibaro:startScene(370);
I use the energy price in a virtual device to show the current vaule, and todays and yesterdays high low.
Please login or register to see this image.
/monthly_2018_05/image.png.4e5bb541b72603e00cf1c1cdfc22aac6.png" alt="image.png.4e5bb541b72603e00cf1c1cdfc22aac6.png" />Link to comment
Share on other sites
20 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.