save RF states and restore after reboot

6 replies [Last post]
Freilassing, Austria
Joined: 4 Jul 2011


I've built a script, which is saving the RF states on change events into a .ini file and restoring these values after a livebox reboot, so the states as seen on the livebox and the real states are equal.

Hope somebody can use this code!

Markus from Linz, Austria

WM_logRFStatesApplet.lua2.12 KB
United Kingdom
Joined: 31 Mar 2011
Thanks for sharing

Nice script Markus, thanks for sharing. I have no idea how this works however, I'm still using the "lua for dummies" manual. That said, scripts like these help us novices get new ideas.cheers. Garry

Freilassing, Austria
Joined: 4 Jul 2011
RF states to ini files

I modified the script, which does the following:

Reads the states of the RFs in the HAH (default: rf1-rf4, "on" or "off") when they are changed (event-triggered) and writes the states into the ini-file rf-settings.ini in the same folder as the xap-livebox.ini (/etc/).

When the HAH is rebooted, the states written down in the ini-file (= the real state of the rf) is restored to the HAH.

So with this script you always get the correct state of the rf's after a livebox-reboot, otherwise all states are set to off (default), even if they are on as they were before booting!

Hope that helps,



PS: when i reply to a topic, there is no possibility of adding an attachment, so i make a new topic for the correct attachment!

PPS: Thanks for resolving the problem, upload works fine now!

WM_logRFStatesApplet.lua 2.88 KB
United Kingdom
Joined: 11 Jan 2011
Just to confirm this is a v2 script


Freilassing, Austria
Joined: 4 Jul 2011
v2 script

yes of course, it works perfectly within the latest fw release!

Blackburn, United Kingdom
Joined: 19 May 2012

I currently have 12 rf controlled sockets and so had to make a small mod to this script.

The script as it stands only takes the first digit in the xap message which is fine if you have 9 or less rf sockets. My problem was when setting rf.10, rf.11 and rf.12.

These got stored in the rf-settings.ini file as rf1 rf1 and rf1

the mod is below

function logstate()                                                                           
        -- Ignore the class messages.                                             
        if xap.getValue("xap-header","class") == "xAPBSC.event" then                          
                -- Get the relays STATE either on or off                                      
                state = xap.getValue("output.state","state")                                  
                -- This LUA pattern will parse the source address ie. 'dbzoo.livebox.Controller:rf.1'
                -- From this string extract the digit 1.                                            
                rf = string.match(xap.getValue("xap-header","source"),"rf.(%d+)")                   
                -- Print out this relays current state                                              
                writeINIfile(filename, rf, state)

London, United Kingdom
Joined: 10 Jun 2010
Just got to 10 RFs

...and noticed that my 10th device was being stored as rf1 even with Mark's modification.

I've tried several things related to the pattern matching in the Applet but nothing fixed the issue.

e.g. :

Line 122: rf = string.match(frame:getValue("xap-header", "source"), "rf%.(%d+)")

added the % in front of the dot


Line 89: if string.find(lines[j], "rf%d*=") then

added the * to %d


Neither of these seemed to fix the issue, so I then removed the 'if' statement in the logstate function and expanded the filter in init with

f:add("xap-header", "class", "xAPBSC.event")

and bingo.  My 10th RF device now logs as rf10.  Not sure which of the above was the definitive fix so I've uploaded my logRFstatesApplet

logRFStatesApplet.lua 2.88 KB
Hardware Info