Jump to content

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


  • 1

Virtual Device report power consumption


Question

Posted

Hi,

Is it possible to report power consumption of an virtual device via LUA?

[ Added: 2013-10-06, 20:32 ]

<--bump-->

Is it possible today?

Recommended Posts

  • 0
Posted

Can i use this lua code for a qubino smart meter 3 phase?

I have made a virtual device with 1 button and added 3 labels. 

Here is my code when i have changed the ID's.

 

function getIcon(watt)
 if(watt > 8000) then return 1049
 elseif(watt >= 7500) then return 1047
 elseif(watt >= 6500) then return 1046
 elseif(watt >= 5500) then return 1045
 elseif(watt >= 4850) then return 1044
 elseif(watt >= 4250) then return 1043
 elseif(watt >= 3750) then return 1042
 elseif(watt >= 3450) then return 1041
 elseif(watt >= 3350) then return 1040
 elseif(watt >= 3250) then return 1039
 elseif(watt >= 3150) then return 1038
 elseif(watt >= 3050) then return 1037
 elseif(watt >= 2950) then return 1036
 elseif(watt >= 2850) then return 1035
 elseif(watt >= 2750) then return 1034
 elseif(watt >= 2650) then return 1033
 elseif(watt >= 2550) then return 1032
 elseif(watt >= 2450) then return 1031
 elseif(watt >= 2350) then return 1030
 elseif(watt >= 2250) then return 1029
 elseif(watt >= 2150) then return 1028
 elseif(watt >= 2050) then return 1027
 elseif(watt >= 1950) then return 1026
 elseif(watt >= 1850) then return 1025
 elseif(watt >= 1750) then return 1024
 elseif(watt >= 1650) then return 1023
 elseif(watt >= 1550) then return 1022
 elseif(watt >= 1450) then return 1021
 elseif(watt >= 1350) then return 1020
 elseif(watt >= 1250) then return 1019
 elseif(watt >= 1150) then return 1018
 elseif(watt >= 1050) then return 1017
 elseif(watt >= 950) then return 1016
 elseif(watt >= 850) then return 1015
 elseif(watt >= 750) then return 1014
 elseif(watt >= 650) then return 1013
 elseif(watt >= 550) then return 1012
 elseif(watt >= 450) then return 1011
 else return 1011 end
end

thisId = 368
started = os.date("%Y-%m-%d %H:%M:%S")
fibaro:debug("-- ["..started .."] Function Start --")
HC2 = Net.FHttp("192.168.10.187")
rwatt, status, errorCode = HC2:GET("/api/energy/now/now/single/devices/power/368")
rkwhour, status, errorCode = HC2:GET("/api/energy/now-3600/now/single/devices/power/368")
jsonTable = json.decode(rwatt)
jsonTable = json.decode(rkwhour)
watt = (jsonTable.W)
kwh = (jsonTable.kWh)
fibaro:debug(watt)
fibaro:debug(kwh)
time =  os.date("%H:%M:%S")
fibaro:log("Now: "..watt.."W | Last hour: "..kwh.."kWh")
fibaro:call(368, "setProperty", "ui.LabelNow.value", watt.." Watt");
fibaro:call(368, "setProperty", "ui.LabelHour.value",kwh.." kWh");
fibaro:call(368, "setProperty", "ui.LabelWhen.value", time);
fibaro:call(368, "setProperty", "currentIcon", getIcon(watt))

ended = os.date("%Y-%m-%d %H:%M:%S")
fibaro:debug("-- [".. ended .."] Function Ended --")
--fibaro:debug("Error: "..err)

fibaro:debug("Sleep 10 sec, then restart")
fibaro:sleep(10*1000)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...