Auch das Umwandeln in einzelne Füllstände ist nicht weiter problematisch:
READINGS:
2021-10-21 20:05:47 Black 89
2021-10-21 20:05:46 Cyan 14
2021-10-21 20:05:46 Magenta 7
2021-10-21 20:05:46 Photo_Black 26
2021-10-21 20:05:47 Yellow 16
2021-10-21 20:05:45 attributes-charset utf-8
2021-10-21 20:05:46 attributes-natural-language en
2021-10-21 20:05:46 marker-levels 26,14,7,16,89
2021-10-21 20:05:46 marker-names Photo Black ink,Cyan ink,Magenta ink,Yellow ink,Black ink
2021-10-21 20:05:45 printer-uri ipp://192.168.1.121:631/
2021-10-21 20:05:45 requested-attributes marker-names,marker-levels
2021-10-21 20:05:45 status-code successful-ok (successful-ok)
sub ipp_fill {
my $filename = '/tmp/ippdata.txt';
my ($err,@content) = FileRead({ FileName => $filename, ForceType => 'file' });
return $err if $err;
foreach my $line ( @content ){
next if $line !~ /=/;
$line =~ s/^\s+|\s+$//g;
my ($readingName,$value) = split (/=/,$line);
($readingName,undef) = split (/\(/,$readingName);
$readingName =~ s/^\s+|\s+$//g;
$readingName = makeReadingName($readingName);
$value =~ s/^\s+|\s+$//g;
fhem("setreading ipp_dummy $readingName $value");
}
my @colors = split(/,/,ReadingsVal('ipp_dummy','marker-names',''));
my @levels = split(/,/,ReadingsVal('ipp_dummy','marker-levels',''));
for (my $i = 0; $i <= $#colors; $i++) {
my $colorName = $colors[$i];
$colorName =~ s/.ink//i;
$colorName = makeReadingName($colorName);
fhem("setreading ipp_dummy $colorName $levels[$i]");
}
return;
}