Forum Discussion
mnagel
2 years agoProfessor
Here is the core chunk of a script that dumps all properties for each device. It was just a throaway POC I kept around, might be helpful. In Perl because I still Perl :). Get off my lawn!
my $lmapi = WM::LMAPI->new(company => $COMPANY) or die;
my %filter = (filter => $FILTER) if (defined $FILTER and length $FILTER);
my $devices = $lmapi->get_all(path => "/device/devices", fields => "id,name,displayName", %filter);
verbose 1, "@{[scalar @$devices]} devices found\n";
DEVICE:
for my $device (@$devices) {
# extract and display device properties
if (my $properties = $lmapi->get_all(path => "/device/devices/$device->{id}/properties")) {
my $output;
for my $prop (sort { $a->{name} cmp $b->{name} } @{$properties}) {
if (my ($filtername,$filtervalue) = ($HACKFILTER =~ /^([^:]+):(.*)/)) {
next DEVICE if (lc $prop->{name} eq lc $filtername and $prop->{value} ne $filtervalue);
}
$output .= $prop->{name} . ": " . $prop->{value} . "\n";
}
print $device->{displayName}, "\n";
print $output, "\n";
}
}