Skip to content

Instantly share code, notes, and snippets.

@yauh
Last active December 31, 2015 21:09
Show Gist options
  • Save yauh/8044583 to your computer and use it in GitHub Desktop.
Save yauh/8044583 to your computer and use it in GitHub Desktop.
Try to explain what the first sub of https://gist.github.com/asciidisco/cb094eadfb4c590e2701 does
sub HMLAN_Initialize($) { # sub takes only one argument
my ($hash) = @_; # takes all arguments provided during the sub routine call and shoves them into $hash
require "$attr{global}{modpath}/FHEM/DevIo.pm"; # gets another perl module involved (need to check this for function definitions as well)
# Provider
$hash->{ReadFn} = "HMLAN_Read"; # basically assigns values to the attributes provided to the sub routine call
$hash->{WriteFn} = "HMLAN_Write";
$hash->{ReadyFn} = "HMLAN_Ready";
$hash->{SetFn} = "HMLAN_Set";
$hash->{AttrFn} = "HMLAN_Attr";
$hash->{Clients} = ":CUL_HM:";
my %mc = ( # creates an associative array (hash) with a single value for now
"1:CUL_HM" => "^A......................",
);
$hash->{MatchList} = \%mc; # again, assigns to params provided to sub routine
# Normal devices
$hash->{DefFn} = "HMLAN_Define";
$hash->{UndefFn} = "HMLAN_Undef";
$hash->{AttrList}= "do_not_notify:1,0 dummy:1,0 " .
"loglevel:0,1,2,3,4,5,6 addvaltrigger " .
"hmId hmKey hmKey2 hmKey3 " .
"respTime wdStrokeTime:5,10,15,20,25 " .
"hmProtocolEvents:0_off,1_dump,2_dumpFull,3_dumpTrigger ".
"hmLanQlen:1_min,2_low,3_normal,4_high,5_critical ".
"wdTimer ".
$readingFnAttributes; # apparantly just a long, concatenated string of attributes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment