Reboot script

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

Here's the scenario.

 

i have a cc128 with 2 sensors (soon to be 3-to monitor grid supply) the main power sensor which monitors house usage power:-

dbzoo.livebox.CurrentCost:ch.1

 

a second which monitors solar power produced :-

dbzoo.livebox.CurrentCost:sensor.1

 

now if i do an xap-snoop all seems fine and is uploaded to pachube (feed 15114 if your interested)

 

problem is after a while (1-2 hours typical) sensor .1 (solar) is not registering on xap-snoop or pachube-stays at same value, a reboot of the HAH fixes this.

 

now short term i want to add a reboot script to reboot the HAH every hour can someone give me a low down on how to do this?

 

long term i am going to put a pc/laptop on the cc128 usb feed to see if its that or the hah playing nasty.

 

help?

 

 

PLEASE

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Possible problems

As I don't have a CC unit anymore since moving to the US I won't be to test, however I can offer some help.

If xap-snoop is not seeing the data then the problem must squarely lie with the xap-currentcost program.  I'm assuming here that only sensor.2 disappears and ch.1 is still reporting?   Is this the case?

As Sensor.2 is remote there are few possibilities

  • The COMMS to the main unit gets interrupted - do you still see updated on the CC display head?
  • A memory leaking is causing the xap-currentcost program to fail (completely) this would also take our CH.1 Is the program actually running when the stoppage occured?  Do you login and check with (ps) ?

There was a few minor updates to this component for build 280, so at least get yourself on this latest build as any fix will be applied here anyway so its good place to be.

If you run xap-currentcost in with debug enabled what is the last thing displayed before it dies?

Brett

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Reboot script

Hi

I run a cc unit and have two sensors plus temp:Ch.1, Sensor.9, and temp

these work no problems on version 279.23 so can't help you an that front but I do use a reboot script adapted from Bretts sample, its here if you need it.

 

Thanks, Garry.

 

--[[
   Auto reboot HAH every 3 hours.
--]]

module(...,package.seeall)

require("xap")

info={
   version="1.0", description="Auto reboot after set time"
}

function reboot(self)

  os.execute("/sbin/reboot")
 
 self:reset()
end


function init()
 
xap.Timer(reboot, 10800):start()

end

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
The COMMS to the main unit
  • The COMMS to the main unit gets interrupted - do you still see updated on the CC display head? YES
  • A memory leaking is causing the xap-currentcost program to fail (completely) this would also take our CH.1 Is the program actually running when the stoppage occured?  Do you login and check with (ps) ? CH.1 is still registering as is temp and sensor 2 only sensor 1 fail's or stops regestring?

will investigate further

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
Ok i put the reboot script in

Ok i put the reboot script in /etc/plugboard directory labelled rebootApplet.lua

 

restarted everything (and set it to 3 minute reboot) doesnt seem to be doing anything, now i know i have missed something can anyone advise what?

 

i am not a script guy, i am ok with linux and cisco cli but my main expertise is hardware not programming or scripting.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
HAH Version ?

Sorry, forgot to check. The script is for the new lua engine available on versions 279.x and 280.

If you are on any of these versions then the file in the link below should reboot every five mins if you put it in /etc/plugboard.

 

I have made it five mins as its short enough to test functionality but long enough to log in a remove/alter when you need to without getting into a reboot loop, which I have done before and wasn't much fun ;).

 

Thanks Garry

https://docs.google.com/leaf?id=0BwzJbOYgkNcVZGU3NDZhZjEtZWI4Mi00MjkxLTh...

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
Thanks for that put it in

Thanks for that put it in /etc/plugboard even gave it a 0777 security box still isnt rebooting, do i have to do anything else?

 

ignore me being stupid as normal :)) working now thanks for help.

 

got another couple of cc's on order with leads for data capture so going to do some serious data capturing :)

 

Ta

 

Dean

derek
Offline
Glasgow, United Kingdom
Joined: 26 Oct 2009
What is hanging up?

I've made extensive use of CC128 feeding pachube. Pretty damn solid for me (i have a planned reboot once a week, but I have let it run for > 20days).

Having seen a fair few liveboxen, I did get one that consistently hung up after 20mins or so. I put this down to a hardware issue in that livebox. In particular, the 5V regulator does run pretty damn hot in normal operation.

It might be worth you picking up another Livebox to do a 'contrast & compare' ... they are still readily available on eBay.

Cheers,
Derek.

 

brett
Offline
Providence, United States
Joined: 9 Jan 2010
Check your HAH version

You need to be on version 280 for this to work - if you are not then the reboot script will not run.

As always you can update your firmware with

# /etc/init.d/update

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
ignore me being stupid as

ignore me being stupid as normal :)) working now thanks for help.

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
way ahead of you

Bidding on 3 at present :)

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
I was being stupid but didnt say what now in same position

had to build a new livebox as mine died, now i have the problem that my scripts do not run automatically.

 

now i said i was being stupid last time but cannot remember what i did.

 

what else do you have to do apart from have a lua script in the /etc/plugboard directory to get it to run?

 

ta

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
Correct Filename

They do end with Applet.lua don't they?

ie myscriptApplet.lua, i beleive it is case sensitive as well, so make sure you use a capital A.

Also make sure that the plugboard scripting engine is enable on the assists tab on the web GUI.

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
yes, yes and it is.

 

code:-

 

--[[
   Auto reboot HAH every 5 mins.
--]]

module(...,package.seeall)

require("xap")

info={
   version="1.0", description="Auto reboot after set time"
}

function reboot(self)

  os.execute("/sbin/reboot")
 
 self:reset()
end


function init()
 
xap.Timer(reboot, 300):start()

end

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
Anyone, this is really bugging me now

I have done everything i can think of the script runneth not.

 

HELP

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
Looks Familiar

You should probably read this, http://www.homeautomationhub.com/content/lua-modules, Brett's posted an answer to the exact same question.  I want to test it myself to prove that I understand it properly, but I think that it basically comes down to the way you run/call the code, you can't call the module function when you run it using the command lua <script name>.

I'll try the code myself and see how I get on,

 

Karl

 

UPDATE:

I copied your script into the /etc/plugboard folder, called it rebootApplet.lua and then rebooted the HAH.  I then monitored the HAH and it did reboot after approx. 5 minutes.  I don't think there is anything wrong with the script, just the way you're trying to run it.

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
yes your right

 

 

running it manually does not work.

 

tried exactly what you did

"

UPDATE:

I copied your script into the /etc/plugboard folder, called it rebootApplet.lua and then rebooted the HAH.  I then monitored the HAH and it did reboot after approx. 5 minutes.  I don't think there is anything wrong with the script, just the way you're trying to run it."

 

and it does not reboot GRR

 

apart from enabling the plug board scripting engine having it in /etc/plugboard directory what else do i have to do??? (and yes i rebooted it)

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
Checks

OK, the plugboard is enable in the web GUI, and the filename is formatted correctly and stored in the correct place.

Log into the HAH as root and type 'ps', this should show you all the processs running on the HAH.  You should see  'lua /etc/plugboard/plugboard.lua', this is obviously the plugboard script running.  If you don't see it we need to find out why it's not running. 

You could also remove/rename any other script in the plugboard folder to stop them running just incase one of them my be causing a problem, again, remembering to reboot after altering the contents of this folder.

Karl

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
its not running :(

 

But in the ini it is enabled

 

 

so how should i correctly set it running with a debug on?

BoxingOrange
Offline
United Kingdom
Joined: 11 Jun 2010
Progress

Fist of all I'd remove ALL scripts from the /etc/plugboard directory, this isn't strictly necessary but we'd then know we're running clean.  I'd then reboot and check to see if the plugboard script runs, using ps again.

garrydwilms
Offline
United Kingdom
Joined: 31 Mar 2011
Try this way
Hi guys. The way I debug scripts is to add the properly named script into the plugboard folder then log in and kill the plugboard process using the kill command plus the relevant process number as found via ps command. Then restart it using xap-plugboard command. This will then load the script and output any errors. I suspect one of your scriPts is bugging plugboard out. Try restarting as discussed above and post the output and well see if we can help wiu the script errors Garry
brett
Offline
Providence, United States
Joined: 9 Jan 2010
As an applet

If you are running an applet and its failing any output will be logged to /var/log/xap-plugboard.log - check in there.

I'm also checking you've done a firmware upgrade recently and are not running a *really old* version of plugboard as in v1?

As Gary mentioned the best way to debug is run it manually on the command line and watch.  First stop the daemon, then run it manually.

# /etc/init.d/xap stop plugboad
# xap-plugboard

Brett

g7pkf
Offline
United Kingdom
Joined: 11 Jan 2011
well i decided to bite the

well i decided to bite the bullet and di a ini file backup only and a full and hard reset.

 

put it all back

 

and would you belive it it is now working fine

 

double GRRRRRRRRRRRRRRRRR

Hardware Info