Created At

Nov 29, 2017

Last Update

Dec 17, 2018

Platforms

HC 2

Views

114

Download

2

Current status: Pre-release

Next steps: Get user feedback and improve

Need help or want to contribute?: help@tibber.com

How to

To enable price updates from Tibber you will need to download and import the virtual device which will hold the current price. You will also create a scene which is responsible for fetching the price and update you virtual device.

1. Go to tibber api login and retreive your access token. If you dont have a tibber account you can use demo token to test this.

https://developer.tibber.com/settings/accesstoken

2. Download the virtual device and import it. Optionally update icon. Retreive the deviceId, you will need it in step 3.

3. Create the LUA scene and call it I.e "Tibber scene". Add the code which is at the bottom of this post. Update the field where token is required. Update the DeviceId fields.

4. Now that your scene is setup you will have to update your device with the scene id.

 

Extended help:

The scene id is visible under: Scenes/Scene name/ general tab

The device id can be found using the local fibaro api i.e: http://192.168.0.0/api/devices

 

 

 

LUA script for scene:

local http = net.HTTPClient();

local payload = '{"query": "{viewer {homes {currentSubscription {priceInfo {current {total currency}}}}}}", "variables": null, "operationName": null}';

 

http : request('https://api.tibber.com/v1-beta/gql',  {

    options = {

        method = "POST",

        headers = {

            ['Authorization'] = 'Bearer YOUR_UNIQUE_TOKEN_HERE',

            ['Content-Type'] = 'application/json'

        

      },

      data = payload

    },

    success = function(response) 

      fibaro:debug (response.data)      

      local startIndex = string.find(response.data,'{"total":') + 9;

      local endIndex = string.find(response.data,',')-1;

      local price = string.sub(response.data,startIndex, endIndex);    

      startIndex = string.find(response.data,'currency":"') + 11;

      endIndex = string.find(response.data,'}')-2;

      local currency = string.sub(response.data,startIndex, endIndex);

      fibaro:debug(price)

      fibaro:debug(currency)

      fibaro:call(DEVICE_ID, 'setProperty', 'ui.Price.value', price);

      fibaro:call(DEVICE_ID, 'setProperty', 'ui.TibberPrice.value', price..' '..currency);  

    end,

         error = function(err) fibaro:debug ("Error:" .. err)

    end

});

 

 

1 Comment,  Want to add comment please login
6702959fe52e7c8f6978cdfee24a86fa

maby im stupid but where do i find deviceid? what deviceid?

Load more comments