70_ZoneMinder: Trigger-Port state fixed

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24925 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
delmar 2021-09-06 09:52:53 +00:00
parent 63c8687cc9
commit 57fa7646cf
2 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- bugfix: 70_ZoneMinder: Trigger-Port state fixed
- feature: 49_IPCAM: introduced attribute 'blocking'
- bugfix: 47_OBIS: Support Holley-smartmeters with negative metering
- change: 10_KNX: major rewrite of the module. pls. check forum #122582

View File

@ -93,10 +93,9 @@ sub ZoneMinder_Define {
# Log3 $name, 3, "ZoneMinder ($name) - Define done ... module=$module, zmHost=$zmHost";
DevIo_CloseDev($hash) if (DevIo_IsOpen($hash));
DevIo_OpenDev($hash, 0, undef);
DevIo_OpenDev($hash, 0, 'ZoneMinder_Trigger_init', 'ZoneMinder_Trigger_callback');
my $triggerPortState = $hash->{STATE};
ZoneMinder_updateState( $hash, $triggerPortState, 'n/a' );
if (!$init_done) {
InternalTimer(gettimeofday()+5, "ZoneMinder_afterInitialized", $hash, 0);
@ -108,6 +107,28 @@ sub ZoneMinder_Define {
return undef;
}
sub ZoneMinder_Trigger_init {
my ( $hash ) = @_;
ZoneMinder_updateState( $hash, 'opened', undef );
return 0; #0 means successful connection
}
sub ZoneMinder_Trigger_callback {
my ( $hash, $error ) = @_;
my $name = $hash->{NAME};
if ( defined ($error) ) {
Log3 $name, 0, "ZoneMinder ($name) - Error while connecting to trigger port: $error";
ZoneMinder_updateState( $hash, 'error', undef );
} else {
Log3 $name, 3, "ZoneMinder ($name) - Trigger port connected";
ZoneMinder_updateState( $hash, 'opened', undef );
}
}
sub ZoneMinder_updateState {
my ( $hash, $triggerPortState, $apiState ) = @_;
@ -817,7 +838,7 @@ sub ZoneMinder_Ready {
ZoneMinder_updateState( $hash, 'disappeared', undef );
return DevIo_OpenDev($hash, 1, undef ); #if success, $err is undef
return DevIo_OpenDev($hash, 1, 'ZoneMinder_Trigger_init', 'ZoneMinder_Trigger_callback' ); #if success, $err is undef
}