We have moved at community.getvera.com

Author Topic: Free graphs for your temp/power sensors  (Read 2746 times)

Offline Gabriel

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +3/-0
Re: Free graphs for your temp/power sensors
« Reply #15 on: March 15, 2019, 07:19:11 am »
1-
What about moving the variables array into startup.lua ( before monitcode = require("Moniton") )?
That would allow to update the monitored sensors within the startup.lua (which can be modified directly from IU7 or AltUI), instead of having to download/modify/update the Moniton.lua file.

2-
What about not pushing the data when the current value is identical to the previous one? That would reduce the load on Veras and on the backend.

Offline Forzaalfa

  • Full Member
  • ***
  • Posts: 227
  • Karma: +5/-0
Re: Free graphs for your temp/power sensors
« Reply #16 on: March 15, 2019, 07:56:59 am »
Cool!

Any chance these graphs could be shown in i.e. Imperihome, og do you have to go to that dashboard site?
Vera Plus - RFXtrx433e

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #17 on: March 15, 2019, 12:04:43 pm »
1-
What about moving the variables array into startup.lua ( before monitcode = require("Moniton") )?

2-
What about not pushing the data when the current value is identical to the previous one? That would reduce the load on Veras and on the backend.

1. I would prefer not to, the right way would be for somebody step up and create a plugin instead. Messing with startup lua is IMHO the wrong way to do it.

But I will think about better options. For example I can make a way to dynamically update that list on HundredGraphs and Vera would pull it up from there

2. Ah, but the plugin doesn't remember what it has submitted last time. And for the backend it just upserts the data. It doesn't matter much if you have pushed 8 unchanged and 2 changed variables or only 2 that were changed

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #18 on: March 15, 2019, 12:12:17 pm »
Cool!

Any chance these graphs could be shown in i.e. Imperihome, og do you have to go to that dashboard site?

those graphs are generated dynamically and in fact locally by your browser, so no images on a server, only raw and aggregated data (when you for example requested a monthly graph). I will look into what IH can do, but for now I don't see much of the option unless it is embedded

Android app is coming if it helps
« Last Edit: March 15, 2019, 12:19:23 pm by ipstas »

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #19 on: March 16, 2019, 09:56:35 am »
Upd: new version of lua file. Now it sends data over https so you can have a bit more privacy over transferred data.

Please make sure you have updated Startup too. Now it looks like
monitcode = require("Moniton")
monitcode.HGTimer(600)

where 600 is time in seconds, now you can change it dynamically without changing a file itself

A question.
- Does anybody uses IFTTT for anything?
- Or anybody needs that data read for anything (API read access)?

Offline Talisker

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: Free graphs for your temp/power sensors
« Reply #20 on: March 16, 2019, 10:11:22 am »
I have followed the instructions, checked and double checked that I have followed them line by line, but my vera is not pushing any data.  I can do a https push from my web browser and that works fine.  Any suggestions of what I could do or check? Thanks.

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #21 on: March 16, 2019, 10:23:40 am »
I think it was a bug in that lua file before. If you manually can do that https://www.hundredgraphs.com/api?key=AAbbCC&node=10&json={House:2111.571,Total:2111.571} with your key of course and your feeds come up, then https://www.hundredgraphs.com accepts data.

Then if your DEBUG = true, you should be able to see in the log lines like

50      03/16/19 2:27:00.100    luup_log:0: [Moniton] Logger:  HGTimer 1 60 <0x73576520>
50      03/16/19 2:27:00.103    luup_log:0: [Moniton] Logger:  collected vars: 26 <0x73576520>
50      03/16/19 2:27:00.104    luup_log:0: [Moniton] Logger:  sending data: &debugtrue&version=3.16.2019&node=1&json={House:2026.537} <0x73576520>
50      03/16/19 2:27:00.297    luup_log:0: [Moniton] Logger:  sent data status: 200 <0x73576520>
50      03/16/19 2:27:00.298    luup_log:0: [Moniton] Logger:  next in 60 <0x73576520>


If you don't see it, it is definitely a problem with lua. Next step would be - just copy and paste the whole file in Test Luup code (Lua) and let me know if it came as Success of Failed

Offline Talisker

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: Free graphs for your temp/power sensors
« Reply #22 on: March 16, 2019, 10:50:28 am »
Thanks for the prompt response ipstas.

I don't actually know where to find the log, but I did paste my Monitcode.lua into Test Luup code (lua) and it came back Success.   I have attached my file in case you can see where I have made an error.
« Last Edit: March 16, 2019, 11:33:32 am by Talisker »

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #23 on: March 16, 2019, 11:21:13 am »
You know that API key in the file gives unrestricted write access over api? I would regenerate it now

I ran the code it definitely works (i have changed the key so it would not mess with your data, but I see it is pushing). I forgot to mention when you are running it manually you need to add 1 more line at the end. Like this
HGTimer(600)
It starts the timer.

Now can you try these 2 in the Test Luup code (Lua)
monitcode = require("Moniton")
monitcode.HGTimer(600)


And it will popup in the log

To see logs. If you have ALTUI go to Misc/OS Command/Tail logs and just run default or use this
grep Monito /var/log/cmh/LuaUPnP.log. Other way is to access that log over ssh on your Vera

Of course make sure you have these 2 in your Startup Lua
monitcode = require("Moniton")
monitcode.HGTimer(600)


This is what starts the loop, otherwise you have just a file sitting there doing nothing

Offline Talisker

  • Sr. Newbie
  • *
  • Posts: 25
  • Karma: +0/-0
Re: Free graphs for your temp/power sensors
« Reply #24 on: March 16, 2019, 11:38:02 am »
Great stuff.  I am now getting my data pushed through.  I very much appreciate your help.  I will also take your advise and change my API key!

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #25 on: March 16, 2019, 12:09:39 pm »
no problem at all

Offline ipstas

  • Sr. Newbie
  • *
  • Posts: 49
  • Karma: +2/-0
Re: Free graphs for your temp/power sensors
« Reply #26 on: March 17, 2019, 01:01:21 pm »
Would somebody need a push/sms about energy/temp spike?

Offline tomtcom

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1050
  • Karma: +27/-31
Re: Free graphs for your temp/power sensors
« Reply #27 on: March 17, 2019, 02:20:22 pm »
**Re-editing post**

A graph doesn't display in the dashboard but does in the graphs tab.

« Last Edit: March 17, 2019, 03:52:46 pm by tomtcom »

Offline Cor

  • Hero Member
  • *****
  • Posts: 1249
  • Karma: +8/-4
Re: Free graphs for your temp/power sensors
« Reply #28 on: March 18, 2019, 05:16:06 am »
 :( I can't get it to work.

I changed the API key and the local VARIABLES , I think with the last one I did something wrong.
but what?

Attached a screenshot of the startup LUA and the moniton file which I uploaded.




Code: [Select]
-- API Key
local API_KEY = "BN741D9X" -- grab that KEY from your settings on https://www.hundredgraphs.com/settings
local NODE_ID = 1
local TOTAL = 'Total'
local version = '3.16.2019'

-- Upload Frequency in seconds. We do not accept updates more often than 60 sec
local updateInterval = 600

-- Log debug messages
local DEBUG = true
local remotedebug = false

-- Setup your devices here. You can use a function to calculate the power as illustrated in the sample.
-- For device logging, use: key, deviceId, serviceId, serviceVar
-- For function based logging, use: key, calculate, serviceVar
-- if you want power to be counted for Total use countTotal=true
local VARIABLES = {
{ key='Boiler Temperature', deviceId=480, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Outside Temperature', deviceId=268, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Living Room Temperature', deviceId=37, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Corridor Temperature', deviceId=40, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Radiator Temperature', deviceId=481, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Buffer Temperature', deviceId=478, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Ambient Temperature', deviceId=479, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Garage Temperature', deviceId=416, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Hobby Temperature', deviceId=228, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Hobby Humidity', deviceId=230, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom UP Humidity', deviceId=88, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom Down Humidity', deviceId=79, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom UP Temperature', deviceId=87, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Bathroom Down Temperature', deviceId=78, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
-- { key="Energy", deviceId = 301, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts", countTotal=false },
-- { key="Energy2", deviceId = 301, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts", countTotal=true },
-- { key='Lock', deviceId=437, serviceId="urn:micasaverde-com:serviceId:HaDevice1", serviceVar="BatteryLevel"},
-- { key='Temperature', deviceId=355, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
-- { key='Tripped', deviceId=331, serviceId="urn:micasaverde-com:serviceId:MotionSensor1", serviceVar="Tripped"},
-- { key='Humidity', deviceId=318, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
-- { key='BedroomHum', deviceId=385, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
-- { key='House B', deviceId=13, serviceId="urn:upnp-org:serviceId:SwitchPower1", serviceVar="Status"}, -- Send switch status
-- { key='Computer', calculate=function() return (IsComputerPingSensorTripped() and 38 or 1) end, serviceVar="Watts" }, -- Send variable value
-- { key='Other', calculate=function() return 15 end, serviceVar="Watts" } -- Send a constant value
}


-- You shouldn't need to change anything below this line --

Many thanks,
Cor


« Last Edit: March 18, 2019, 05:21:06 am by Cor »

Offline tomtcom

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1050
  • Karma: +27/-31
Re: Free graphs for your temp/power sensors
« Reply #29 on: March 18, 2019, 07:25:50 am »
:( I can't get it to work.

I changed the API key and the local VARIABLES , I think with the last one I did something wrong.
but what?

Attached a screenshot of the startup LUA and the moniton file which I uploaded.




Code: [Select]
-- API Key
local API_KEY = "BN741D9X" -- grab that KEY from your settings on https://www.hundredgraphs.com/settings
local NODE_ID = 1
local TOTAL = 'Total'
local version = '3.16.2019'

-- Upload Frequency in seconds. We do not accept updates more often than 60 sec
local updateInterval = 600

-- Log debug messages
local DEBUG = true
local remotedebug = false

-- Setup your devices here. You can use a function to calculate the power as illustrated in the sample.
-- For device logging, use: key, deviceId, serviceId, serviceVar
-- For function based logging, use: key, calculate, serviceVar
-- if you want power to be counted for Total use countTotal=true
local VARIABLES = {
{ key='Boiler Temperature', deviceId=480, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Outside Temperature', deviceId=268, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Living Room Temperature', deviceId=37, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Corridor Temperature', deviceId=40, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Radiator Temperature', deviceId=481, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Buffer Temperature', deviceId=478, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Ambient Temperature', deviceId=479, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Garage Temperature', deviceId=416, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Hobby Temperature', deviceId=228, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Hobby Humidity', deviceId=230, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom UP Humidity', deviceId=88, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom Down Humidity', deviceId=79, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
{ key='Bathroom UP Temperature', deviceId=87, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
{ key='Bathroom Down Temperature', deviceId=78, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
-- { key="Energy", deviceId = 301, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts", countTotal=false },
-- { key="Energy2", deviceId = 301, serviceId='urn:micasaverde-com:serviceId:EnergyMetering1', serviceVar="Watts", countTotal=true },
-- { key='Lock', deviceId=437, serviceId="urn:micasaverde-com:serviceId:HaDevice1", serviceVar="BatteryLevel"},
-- { key='Temperature', deviceId=355, serviceId="urn:upnp-org:serviceId:TemperatureSensor1", serviceVar="CurrentTemperature"},
-- { key='Tripped', deviceId=331, serviceId="urn:micasaverde-com:serviceId:MotionSensor1", serviceVar="Tripped"},
-- { key='Humidity', deviceId=318, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
-- { key='BedroomHum', deviceId=385, serviceId="urn:micasaverde-com:serviceId:HumiditySensor1", serviceVar="CurrentLevel"},
-- { key='House B', deviceId=13, serviceId="urn:upnp-org:serviceId:SwitchPower1", serviceVar="Status"}, -- Send switch status
-- { key='Computer', calculate=function() return (IsComputerPingSensorTripped() and 38 or 1) end, serviceVar="Watts" }, -- Send variable value
-- { key='Other', calculate=function() return 15 end, serviceVar="Watts" } -- Send a constant value
}


-- You shouldn't need to change anything below this line --

Many thanks,
Cor

It looks right to me. Mine stopped working yesterday around 3:45PM EDT I believe. Hasn't updated since then.