save RF states and restore after reboot

Hi,

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

Member for

15 years 7 months

garrydwilms

15 years 1 month ago

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

Member for

15 years 4 months

wpmax

15 years 1 month ago

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,

Markus

 

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!

Attachments

Member for

15 years 4 months

wpmax

14 years 6 months ago

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

Member for

14 years 5 months

mark_baldwin

14 years 1 month ago

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 xAPBSC.info 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)

Member for

16 years 5 months

BodgeIT

11 years 11 months ago

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

Attachments