2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-21 01:46:08 +00:00

70_NEUTRINO: bugfixes

git-svn-id: https://svn.fhem.de/fhem/trunk@14922 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
michael.winkler 2017-08-19 09:18:05 +00:00
parent 963eeab2c8
commit 99e5f52979

View File

@ -1,6 +1,14 @@
# $Id$ # $Id$
############################################################################ ############################################################################
# 2017-07-28, v1.0.8 # 2017-08-19, v1.0.10
#
# v1.0.10
# - BUFIX: Code Optimierungen
#
# v1.0.9
# - BUFIX: BUG EPG Info https://forum.fhem.de/index.php/topic,54481.msg665959.html#msg665959
# Change Volume
# - CHANGE Readings für EPG zurücksetzen wenn keine Infos vorhanden sind
# #
# v1.0.8 # v1.0.8
# - BUFIX: Code Optimierungen # - BUFIX: Code Optimierungen
@ -138,7 +146,7 @@ sub NEUTRINO_GetStatus($;$) {
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_GetStatus] called function"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_GetStatus] called function";
if ($update ne '') {Log3 $name, 5, "NEUTRINO $name [NEUTRINO_GetStatus] Update = $update";} if ($update ne '') {Log3 $name, 5, "NEUTRINO $name [NEUTRINO_GetStatus] Update = $update";}
RemoveInternalTimer($hash); #RemoveInternalTimer($hash);
InternalTimer( gettimeofday() + $interval, "NEUTRINO_GetStatus", $hash, 0 ); InternalTimer( gettimeofday() + $interval, "NEUTRINO_GetStatus", $hash, 0 );
return if ( AttrVal( $name, "disable", 0 ) == 1 ); return if ( AttrVal( $name, "disable", 0 ) == 1 );
@ -729,7 +737,7 @@ sub NEUTRINO_Define($$) {
} }
# start the status update timer # start the status update timer
RemoveInternalTimer($hash); #RemoveInternalTimer($hash);
InternalTimer( gettimeofday() + 2, "NEUTRINO_GetStatus", $hash, 1 ); InternalTimer( gettimeofday() + 2, "NEUTRINO_GetStatus", $hash, 1 );
return; return;
@ -775,7 +783,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
} }
# volume data = 0 then data = off # volume data = 0 then data = off
if ($service eq "volume" && $data == 0){ if ($service eq "volume" && $data eq '0'){
$data = "off"; $data = "off";
} }
@ -795,9 +803,9 @@ sub NEUTRINO_ReceiveCommand($$$) {
} }
$presence = "absent"; $presence = "absent";
readingsBulkUpdate( $hash, "power", "off" ); readingsBulkUpdateIfChanged( $hash, "power", "off" );
readingsBulkUpdate( $hash, "state", "off" ); readingsBulkUpdateIfChanged( $hash, "state", "off" );
readingsBulkUpdate( $hash, "presence", $presence ) readingsBulkUpdateIfChanged( $hash, "presence", $presence )
if ( ReadingsVal( $name, "presence", "" ) ne $presence ); if ( ReadingsVal( $name, "presence", "" ) ne $presence );
} }
} }
@ -806,7 +814,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
elsif ($data) { elsif ($data) {
$presence = "present"; $presence = "present";
$state = "on"; $state = "on";
readingsBulkUpdate( $hash, "presence", $presence ) readingsBulkUpdateIfChanged( $hash, "presence", $presence )
if ( ReadingsVal( $name, "presence", "" ) ne $presence ); if ( ReadingsVal( $name, "presence", "" ) ne $presence );
#2017.07.21 - Log anzeigen wenn $cmd befüllt ist #2017.07.21 - Log anzeigen wenn $cmd befüllt ist
@ -884,8 +892,8 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (@ans[0]) { if (@ans[0]) {
if (index(lc(@ans[0]), "on") != -1) { if (index(lc(@ans[0]), "on") != -1) {
readingsBulkUpdate( $hash, "power","off"); readingsBulkUpdateIfChanged( $hash, "power","off");
readingsBulkUpdate( $hash, "state", "standby" ); readingsBulkUpdateIfChanged( $hash, "state", "standby" );
$state = "off"; $state = "off";
} }
@ -894,8 +902,8 @@ sub NEUTRINO_ReceiveCommand($$$) {
# 2017.07.12 - Aenderungen nur durchfuehren wenn power vorher ungleich "on" war # 2017.07.12 - Aenderungen nur durchfuehren wenn power vorher ungleich "on" war
if (ReadingsVal( $name, "power", "unbekannt" ) ne 'on' ) { if (ReadingsVal( $name, "power", "unbekannt" ) ne 'on' ) {
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] detect change"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] detect change";
readingsBulkUpdate( $hash, "power","on"); readingsBulkUpdateIfChanged( $hash, "power","on");
readingsBulkUpdate( $hash, "state", "on" ); readingsBulkUpdateIfChanged( $hash, "state", "on" );
delete($hash->{helper}{FIRSTSTART}); delete($hash->{helper}{FIRSTSTART});
} }
@ -940,25 +948,25 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (index($type, "off") != -1) { if (index($type, "off") != -1) {
Log3 $name, 5, "NEUTRINO $name TYP = OFF"; Log3 $name, 5, "NEUTRINO $name TYP = OFF";
readingsBulkUpdate( $hash, "power", "on"); readingsBulkUpdateIfChanged( $hash, "power", "on");
readingsBulkUpdate( $hash, "state", "on" ); readingsBulkUpdateIfChanged( $hash, "state", "on" );
} }
elsif(index($type, "on") != -1) { elsif(index($type, "on") != -1) {
Log3 $name, 5, "NEUTRINO $name TYP = ON"; Log3 $name, 5, "NEUTRINO $name TYP = ON";
readingsBulkUpdate( $hash, "power", "off"); readingsBulkUpdateIfChanged( $hash, "power", "off");
readingsBulkUpdate( $hash, "state", "standby" ); readingsBulkUpdateIfChanged( $hash, "state", "standby" );
} }
else { else {
readingsBulkUpdate( $hash, "power", "off"); readingsBulkUpdateIfChanged( $hash, "power", "off");
readingsBulkUpdate( $hash, "state", "standby" ); readingsBulkUpdateIfChanged( $hash, "state", "standby" );
$state = "off"; $state = "off";
} }
NEUTRINO_SendCommand( $hash, "recordmode" ); NEUTRINO_SendCommand( $hash, "recordmode" );
} }
else{ else{
readingsBulkUpdate( $hash, "power", "undefined" ); readingsBulkUpdateIfChanged( $hash, "power", "undefined" );
readingsBulkUpdate( $hash, "state", "undefined" ); readingsBulkUpdateIfChanged( $hash, "state", "undefined" );
} }
} }
else { else {
@ -974,12 +982,12 @@ sub NEUTRINO_ReceiveCommand($$$) {
#2017.07.17 - Liste nur bei aenderung aktualisieren #2017.07.17 - Liste nur bei aenderung aktualisieren
if (ReadingsVal( $name, "bouquetnr", "99999" ) ne @ans[0] ) { if (ReadingsVal( $name, "bouquetnr", "99999" ) ne @ans[0] ) {
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] detect change"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] detect change";
readingsBulkUpdate( $hash, "bouquetnr", @ans[0] ); readingsBulkUpdateIfChanged( $hash, "bouquetnr", @ans[0] );
NEUTRINO_SendCommand( $hash, "bouquet_list" ); NEUTRINO_SendCommand( $hash, "bouquet_list" );
} }
} }
else { else {
readingsBulkUpdate( $hash, "bouquetnr", "0" ); readingsBulkUpdateIfChanged( $hash, "bouquetnr", "0" );
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no bouquetnr could be extracted"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no bouquetnr could be extracted";
} }
} }
@ -1033,10 +1041,10 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (@ans[0]) { if (@ans[0]) {
if (index(lc(@ans[0]), "1") != -1) { if (index(lc(@ans[0]), "1") != -1) {
#2017.07.12 - Änderung schreiben #2017.07.12 - Änderung schreiben
if (ReadingsVal( $name, "mute", "0" ) ne 'on' ) {readingsBulkUpdate( $hash, "mute","on");} readingsBulkUpdateIfChanged( $hash, "mute","on");
} }
else{ else{
if (ReadingsVal( $name, "mute", "0" ) ne 'off' ) {readingsBulkUpdate( $hash, "mute","off");} readingsBulkUpdateIfChanged( $hash, "mute","off");
} }
} }
else { else {
@ -1050,7 +1058,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (@ans[0]) { if (@ans[0]) {
if (index(lc(@ans[0]), "ok") != -1) { if (index(lc(@ans[0]), "ok") != -1) {
readingsBulkUpdate( $hash, "mute","on"); readingsBulkUpdateIfChanged( $hash, "mute","on");
} }
} }
else { else {
@ -1063,7 +1071,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (@ans[0]) { if (@ans[0]) {
if (index(lc(@ans[0]), "ok") != -1) { if (index(lc(@ans[0]), "ok") != -1) {
readingsBulkUpdate( $hash, "mute","off"); readingsBulkUpdateIfChanged( $hash, "mute","off");
} }
} }
else { else {
@ -1075,7 +1083,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
elsif ( $service eq "model" ) { elsif ( $service eq "model" ) {
if (@ans[0]) { if (@ans[0]) {
readingsBulkUpdate( $hash, "model",@ans[0]); readingsBulkUpdateIfChanged( $hash, "model",@ans[0]);
} }
else { else {
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no model could be extracted"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no model could be extracted";
@ -1112,8 +1120,8 @@ sub NEUTRINO_ReceiveCommand($$$) {
#2017.07.12 - Nur Änderungen schreiben #2017.07.12 - Nur Änderungen schreiben
if (ReadingsVal( $name, "timer$i", "0" ) ne $line ) { if (ReadingsVal( $name, "timer$i", "0" ) ne $line ) {
readingsBulkUpdate( $hash, "timer$i", $line ); readingsBulkUpdateIfChanged( $hash, "timer$i", $line );
readingsBulkUpdate( $hash, "timer$i" . "number", $timernumber ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "number", $timernumber );
# timertyp # timertyp
if ($timertyp eq "1") {$timertyp = "shutdown"} if ($timertyp eq "1") {$timertyp = "shutdown"}
@ -1126,7 +1134,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
elsif ($timertyp eq "8") {$timertyp = "exec_plugin"} elsif ($timertyp eq "8") {$timertyp = "exec_plugin"}
else {$timertyp = "unknown"} else {$timertyp = "unknown"}
readingsBulkUpdate( $hash, "timer$i" . "typ", $timertyp ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "typ", $timertyp );
# timer repeat # timer repeat
if ($timerrepeat eq "0") {$timerrepeat = "once"} if ($timerrepeat eq "0") {$timerrepeat = "once"}
@ -1138,25 +1146,25 @@ sub NEUTRINO_ReceiveCommand($$$) {
elsif ($timerrepeat eq "6") {$timerrepeat = "beeventdescription"} elsif ($timerrepeat eq "6") {$timerrepeat = "beeventdescription"}
else {$timerrepeat = "weekdays"} else {$timerrepeat = "weekdays"}
readingsBulkUpdate( $hash, "timer$i" . "repeat", $timerrepeat ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "repeat", $timerrepeat );
# timer repcount # timer repcount
readingsBulkUpdate( $hash, "timer$i" . "repcount", @timerlist[3] ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "repcount", @timerlist[3] );
# announceTime # announceTime
if ($timerannounceTime eq "0") {readingsBulkUpdate( $hash, "timer$i" . "manualrecord", "" );} if ($timerannounceTime eq "0") {readingsBulkUpdateIfChanged( $hash, "timer$i" . "manualrecord", "" );}
else { else {
my $date = localtime($timerannounceTime)->strftime('%F %T'); my $date = localtime($timerannounceTime)->strftime('%F %T');
readingsBulkUpdate( $hash, "timer$i" . "announceTime", $date ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "announceTime", $date );
} }
# startTime # startTime
my $date = localtime($timerstartTime)->strftime('%F %T'); my $date = localtime($timerstartTime)->strftime('%F %T');
readingsBulkUpdate( $hash, "timer$i" . "startTime", $date ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "startTime", $date );
# stopTime # stopTime
my $date = localtime($timerstopTime)->strftime('%F %T'); my $date = localtime($timerstopTime)->strftime('%F %T');
readingsBulkUpdate( $hash, "timer$i" . "stopTime", $date ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "stopTime", $date );
# timer name # timer name
$timername = ""; $timername = "";
@ -1167,12 +1175,12 @@ sub NEUTRINO_ReceiveCommand($$$) {
} }
$c++; $c++;
} }
readingsBulkUpdate( $hash, "timer$i" . "name", $timername ); readingsBulkUpdateIfChanged( $hash, "timer$i" . "name", $timername );
} }
# find running record # find running record
if ($neutrinotime > $timerstartTime && $neutrinotime < $timerstopTime) { if ($neutrinotime > $timerstartTime && $neutrinotime < $timerstopTime) {
readingsBulkUpdate( $hash, "recordchannel", $timername ); readingsBulkUpdateIfChanged( $hash, "recordchannel", $timername );
NEUTRINO_SendCommand( $hash, "epginforecord",""); NEUTRINO_SendCommand( $hash, "epginforecord","");
} }
@ -1183,19 +1191,19 @@ sub NEUTRINO_ReceiveCommand($$$) {
# timer count # timer count
#2017.07.12 - Nur Änderungen schreiben #2017.07.12 - Nur Änderungen schreiben
if (ReadingsVal( $name, "timer_count", "0" ) ne $i ) {readingsBulkUpdate( $hash, "timer_count", $i );} readingsBulkUpdateIfChanged( $hash, "timer_count", $i );
# timer maxcount # timer maxcount
if ($timermaxcount <= $i) { if ($timermaxcount <= $i) {
#2017.07.12 - Nur Änderungen schreiben #2017.07.12 - Nur Änderungen schreiben
if (ReadingsVal( $name, "timer_maxcount", "0" ) ne $i ) {readingsBulkUpdate( $hash, "timer_maxcount", $i );} readingsBulkUpdateIfChanged( $hash, "timer_maxcount", $i );
} }
else { else {
# detele not used timer # detele not used timer
while ($d < $timermaxcount) { while ($d < $timermaxcount) {
if ($d > $i -1 ) { if ($d > $i -1 ) {
foreach ( "","announceTime","name","number","repcount","repeat","startTime","stopTime","typ", ) { foreach ( "","announceTime","name","number","repcount","repeat","startTime","stopTime","typ", ) {
if (ReadingsVal( $name, "timer" . $d . $_, "0" ) ne '-' ) {readingsBulkUpdate( $hash, "timer" . $d . $_, "-" );}; readingsBulkUpdateIfChanged( $hash, "timer" . $d . $_, "-" );
} }
} }
$d++; $d++;
@ -1231,7 +1239,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
# recordtitle # recordtitle
$readvalue = $return->{prog}[$readnumber]{description}; $readvalue = $return->{prog}[$readnumber]{description};
readingsBulkUpdate( $hash, "recordtitle",$readvalue); readingsBulkUpdateIfChanged( $hash, "recordtitle",$readvalue);
} }
} }
else { else {
@ -1278,7 +1286,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
# stream URL # stream URL
elsif ( $service eq "build_live_url" ) { elsif ( $service eq "build_live_url" ) {
if (@ans[0]) { if (@ans[0]) {
readingsBulkUpdate( $hash, "channel_url", @ans[0] ); readingsBulkUpdateIfChanged( $hash, "channel_url", @ans[0] );
} }
else { else {
Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no build_live_url could be extracted"; Log3 $name, 5, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ERROR: no build_live_url could be extracted";
@ -1290,13 +1298,13 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (@ans[0]) { if (@ans[0]) {
if (index(lc(@ans[0]), "tv") != -1) { if (index(lc(@ans[0]), "tv") != -1) {
readingsBulkUpdate( $hash, "input","tv"); readingsBulkUpdateIfChanged( $hash, "input","tv");
} }
elsif(index(lc(@ans[0]), "radio") != -1) { elsif(index(lc(@ans[0]), "radio") != -1) {
readingsBulkUpdate( $hash, "input","radio"); readingsBulkUpdateIfChanged( $hash, "input","radio");
} }
else{ else{
readingsBulkUpdate( $hash, "input", "-" ) readingsBulkUpdateIfChanged( $hash, "input", "-" )
} }
} }
else { else {
@ -1340,13 +1348,19 @@ sub NEUTRINO_ReceiveCommand($$$) {
# channel_Name # channel_Name
$readvalue = $return->{channel_name}; $readvalue = $return->{channel_name};
readingsBulkUpdate( $hash, "channel_name",$readvalue); readingsBulkUpdateIfChanged( $hash, "channel_name",$readvalue);
# channel displayname # channel displayname
$readvalue =~ s/\s/_/g; $readvalue =~ s/\s/_/g;
readingsBulkUpdate( $hash, "channel",$readvalue); readingsBulkUpdateIfChanged( $hash, "channel",$readvalue);
if (defined( $return->{prog} ) && $return->{prog} ) { if(ref($return->{prog}) eq 'ARRAY') {
Log3 $name, 1, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ARRAY!!!" . ref($return->{prog});
}else {Log3 $name, 1, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] ARRAY!!! NOT" . ref($return->{prog});}
Log3 $name, 1, "NEUTRINO $name [NEUTRINO_ReceiveCommand] [$service] Data = $data";
if (defined( $return->{prog} ) && ref($return->{prog}) eq 'ARRAY' ) {
#egp stop time serach #egp stop time serach
my $arr_size = @{ $return->{prog} }; my $arr_size = @{ $return->{prog} };
@ -1356,7 +1370,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
$readvalue = $return->{prog}[$i]{stop_sec}; $readvalue = $return->{prog}[$i]{stop_sec};
if ($readvalue > $neutrinotime){ if ($readvalue > $neutrinotime){
$readnumber = $i; $readnumber = $i;
readingsBulkUpdate( $hash, "egp_current_number", $readnumber); readingsBulkUpdateIfChanged( $hash, "egp_current_number", $readnumber);
last; last;
} }
$i++; $i++;
@ -1370,7 +1384,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
# currentTitel # currentTitel
$readvalue = $return->{prog}[$readnumber]{description}; $readvalue = $return->{prog}[$readnumber]{description};
readingsBulkUpdate( $hash, "currentTitle",$readvalue); readingsBulkUpdateIfChanged( $hash, "currentTitle",$readvalue);
foreach ( "eventid","description","info1","info2","start_t","stop_t","duration_min","date","channel_id","stop_sec","start_sec", ) { foreach ( "eventid","description","info1","info2","start_t","stop_t","duration_min","date","channel_id","stop_sec","start_sec", ) {
$reading = $_; $reading = $_;
@ -1383,16 +1397,30 @@ sub NEUTRINO_ReceiveCommand($$$) {
$readvalue =~ s/\n//g; $readvalue =~ s/\n//g;
if ($readvalue) { if ($readvalue) {
readingsBulkUpdate( $hash, $readingname, $readvalue ); readingsBulkUpdateIfChanged( $hash, $readingname, $readvalue );
} }
else { else {
readingsBulkUpdate( $hash, $readingname, "-" ); readingsBulkUpdateIfChanged( $hash, $readingname, "-" );
} }
} }
else { else {
readingsBulkUpdate( $hash, $readingname, "-" ); readingsBulkUpdateIfChanged( $hash, $readingname, "-" );
} }
} }
}else{
readingsBulkUpdateIfChanged( $hash, "eventid", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_description", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_info1", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_info2", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_start_t", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_stop_t", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_duration_min", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_date", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_channel_id", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_stop_sec", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_start_sec", "-" );
readingsBulkUpdateIfChanged( $hash, "egp_current_number", "-" );
readingsBulkUpdateIfChanged( $hash, "currentTitle", "-" );
} }
} }
else { else {
@ -1429,7 +1457,7 @@ sub NEUTRINO_ReceiveCommand($$$) {
if (index(lc($line), "=") != -1) { if (index(lc($line), "=") != -1) {
$versionvalue = substr($line,index($line,"=")+1); $versionvalue = substr($line,index($line,"=")+1);
$versionname = substr($line,0,index($line,"=")); $versionname = substr($line,0,index($line,"="));
readingsBulkUpdate( $hash, "image_" . "$versionname",$versionvalue); readingsBulkUpdateIfChanged( $hash, "image_" . "$versionname",$versionvalue);
} }
} }
} }