HAH died

6 replies [Last post]
g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011

we had a major power incident a couple of weeks ago in the village and it hurt my HAH, so far the basenode (or lead) has failed and the cc usb lead and hah main PCB

 

well i had a spare hour or so today so built another HAH.

only thing i cannot get working is the pvoutput script, and i know not where to start!

 

Dean

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
Most unfortunate

That's a pity. I have some 'core' kit on an UPS ... not sure if this would protect against this sort of thing but it does help with the odd power cut. The good thing about the Livebox is that you can still pick these up on eBay for under a tenner delivered. Not so many now as there used to be though.

As for pvoutput do search the forum. There are a few folks there who, like you, have been using this. Once you get that script up & going again, put a copy up onto this forum ... that will give you a free backup ;-)

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
yes i know backups are

yes i know backups are useful, one question regarding the pv scetch should the quotes be left round the api and user details? and yes all stuff is on an APC UPS (or rather two) did not help.

spent many an hour round neighbours houses replacing adsl routers over the last 2 weeks.

allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Which pvoutput script

Dean

which pv script is it/What does it do?

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
does this look right? do i need speach marks round the api/user

require ('xap')
require('xap.bsc')
require("string")
local io = require("io")
local http = require("socket.http")
local ltn12 = require("ltn12")

module(...,package.seeall)

info={
    version="1.0", description="PVoutput poster"
}

CurrentTemp = 0
Logtime = os.time()
TempCumulativeKwH = 0
CumulativeKwH = 0
CurrentKwH = 0
watts = 0
elapsed = 0
ConvFactor = 0.95
-- Api = "c97e54b0ba3eee819b18d3eb4225ef9f7033b472"  -- put your  PVoutput api key here
-- Feed = "3791"  -- put your PVoutput feed ID here Postinterval = 5  -- The number of minutes between posts to PVoutput url='://pvoutput.org/service/r2/addstatus.jsp?key='
Power = 1


function init()
     local f = xap.Filter()
     f:add("xap-header", "source", "dbzoo.livebox.CurrentCost:ch.1")
     f:add("xap-header","class","xAPBSC.event")
     f:callback(powerlog)
     local f = xap.Filter()
     f:add("xap-header", "source", "dbzoo.livebox.CurrentCost:temp")
     f:add("xap-header","class","xAPBSC.event")
     f:callback(GetTemp)
end



function post(self)
    local ckwh = math.floor(CumulativeKwH *1000 )
         if CumulativeKwH ~= 0 then
        if tonumber(Power) ~= 0 then
    b, c, h = http.request("http" ..url ..Api .. "&sid="..Feed .. "&d=" 
..os.date("%Y%m%d") .. "&t=" ..os.date("%H:%M") .. "&v1=" ..ckwh.. "&v2=" 
..Power .."&v5=" ..CurrentTemp)
        end
         end
end

function powersave(self)
     local file = io.open("/etc/plugboard/CumulativeKwH","r")
         CumulativeKwH = file:read("*all")
         file:close()
    CumulativeKwH = tonumber(CumulativeKwH) + TempCumulativeKwH
    TempCumulativeKwH = 0
    local cmd = string.format("echo '%s'>/etc/plugboard/CumulativeKwH",
CumulativeKwH)
    os.execute(cmd)
    self:reset()
    post()
end

function GetTemp(frame)
    CurrentTemp = frame:getValue("input.state","text")
end


function powerlog(frame)
     local CurrentPeriod = os.difftime(os.time(), Logtime)
     Logtime = os.time()
     local CurrentKwH = Power * CurrentPeriod / 3600000
     TempCumulativeKwH = TempCumulativeKwH + CurrentKwH
     Power = frame:getValue("input.state","text")
     if tonumber(Power) < 45 then
     Power = 0
     elseif tonumber(Power) < 300 then
     Power = tonumber(Power) * 0.5
     else
     Power = tonumber(Power) * ConvFactor
     end
end

function filereset(self)
    local Logtime = os.date("%H")
    if tonumber(Logtime)  > 18 then
    local cmd = string.format("echo 0 >/etc/plugboard/CumulativeKwH")
    os.execute(cmd)
    end
    self:reset()
end

xap.Timer(powersave, Postinterval*60):start()
xap.Timer(filereset, 1800):start()                  -- reset the cumulative 
file after 7 pm. Check the time every half hour


allanayr
Offline
Ayr, United Kingdom
Joined: 25 Sep 2011
Yes

Yes it looks about right. I think that you need the double quotes around the api/feed id because they are string variables but you need to remove the double subtraction marks (--) from the beginning of the lines starting Api =  and Feed =

 

Also in the function post(self) in the line beginning b, c, h = you should take out any carriage return/line feed and just make it into one long statement up to the bracket after CurrentTemp

 

Allan

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
not using script

HAH is too reliable, i stopped using script years ago, was grabing from Pachbe/Xiveley.

 

took me 2 hours to figure it all out. now working fine.

 

Thanks for input Alan

Hardware Info