====== w1retap plugin ====== This plugin returns the value that belongs to a key from a file with lines in the form //KEY=VALUE//. It was written by Jonathan Hudson for the [[http://www.daria.co.uk/wx/tech.html|w1retap]] weather station logging software (1-Wire sensors), but it can be used with every file in this format. ---- ===== Functions ===== |w1retap::readkey(file, key)|returns the value of //key// from //file//| * The file is read at every call, the first line that starts with //key=// is used. * The value ends at the first blank or at the end of the line, so a unit after the value (//OTMP0=12.34 C//) is cut off. * If the value is a number, it is formatted with one decimal place; values greater than 500 (e.g. the air pressure) are formatted without decimal places. * If the key is not found or the file cannot be opened, an empty string is returned. ---- ===== Example ===== A file ///tmp/.w1retap.dat// with this content OTMP0=12.34 C OPRS=1013.25 hPa and this configuration Variables { tick 120000 file '/tmp/.w1retap.dat' } Widget Temp { class 'Text' expression w1retap::readkey(file, 'OTMP0') prefix 'Extr ' width 10 align 'L' update tick } Widget Press { class 'Text' expression w1retap::readkey(file, 'OPRS') prefix 'Pres ' width 10 align 'L' update tick } will display 'Extr 12.3' and 'Pres 1013'. For other files in the form //key=value// see also //file::readconf()// of the [[:lcd4linux:plugin_file|file plugin]]. ---- ===== Requirements ===== No external libraries. The plugin is selected at build time with //--with-plugins=w1retap// (it is part of 'all'). ----