Reboot script
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
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
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...
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.
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
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.
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.
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
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.
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
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
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