[mh] Insteon debouncing with tie_event & tie_filter
Stephen Switzer <[email protected]>
| Newsgroups | gmane.comp.misc.misterhouse.user |
|---|---|
| Message-ID | <CALSXUc1met+=Ka_hBbZV5oVWb8FJJZ=fOcmvPFXwRQ60azpTww@mail.gmail.com> |
I recently purchased some hidden door sensors and used
"INSTEON_MOTIONSENSOR" in my MHT file, since I couldn't find a better match
for this device. I linked them to the PLM and they work as I would expect.
However, I many times get duplicate ON and OFF events. Given the nature of
the network and relaying, I understand why this happens. Typically, I used
state_chaged to detect changes, but I'm trying a new (to me) approach,
with tie_event:
sub insteon_door_change {
my ( $iDoor_Obj, $iDoor_State ) = @_;
my $iDoor_Name = $iDoor_Obj->get_object_name();
#return unless defined $iDoor_Obj->state_changed;
#print_log "[INSTEON] $iDoor_Name State: " . $iDoor_Obj->state;
#print_log "[INSTEON] $iDoor_Name State Changed: " .
$iDoor_Obj->state_changed;
$iDoor_State =~ s/^on$/open/; $iDoor_State =~ s/^off$/closed/;
$iDoor_Name =~ s/^\$//;
$iDoor_Name =~ s/^i[a-z]*_/Door /;
print_log "[INSTEON] $iDoor_Name = $iDoor_State";
}
$ioc_test -> tie_event('&insteon_door_change($object,$state);'); # noloop
This will trigger the sub twice per event sometimes. I was able to add the
return if not defined line and this filtered, but it just seems that there
should be a better way. So, I tried the tie_filter option:
$ioc_test -> tie_filter('$state_changed ne $state'); # noloop
Unless I put something there about $state or a simple 1 == 1, it fired
every time. I'm not sure of the best way to accomplish this, but for now I
hacked Generic_Item.pm with an additional if statement here:
# Set/fire tied objects/events
# - do it in main, so eval works ok
&main::check_for_tied_events($ref) if defined $ref->{state_changed};
It seems that others would not want to fire an event on each set given the
nature of Insteon, but maybe there's a use case I'm not thinking of?
I welcome feedback. :)
Thanks!
--
Best regards,
Steve Switzer
---
Get world-class business I.T. services and a phone system with
high-end features that won't challenge your
budget!http://www.sbsROC.com
________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users