The part which starts "if ($state = state_now $Kitchen_Motion) {" should really have been put elsewhere in the MH code, not in this plugin, and the lmce_motion or lmce_still called from there.
In
if ($state eq MOTION)
is MOTION a scalar variable name that's set to a value before entering that line, or is it a filehandle, or some other kind of variable? Or is it a string literal? In other words, should that line really read something like
if($state eq 'MOTION')
or even
$inMotion = 'MOTION';
$motionless = 'STILL';
$locationCode = '184';
if($state eq $inMotion)
{
lmce_motion($locationCode);
}
elsif($state eq $motionless)
{
lmce_still(locationCode);
}
Can state_now return any value other than MOTION or STILL? If so, is there a message for "other", or just silently ignore it?
And are those identifiers like state_now , active_now , inactive_now , new_minute , active , print_log all function names that should end with () when called on an argument list rather shell-script-style on a single argument, separated with a space (eg. "inactive_now $pluto_device_event_receiver" is equivalent to "inactive_now($pluto_device_event_receiver)"?
Can you parenthesize the logic below to make its operator precedence properly explicit, rather than relying on Perl to sort it out?
if(new_minute 1 && !active $pluto_device_event_receiver || new_minute 1 && !active $pluto_device_command_sender)
And finally, does that script not need an initial "#!/usr/local/bin/perl" invocation, because it's imported by some other perl script as a string and eval()'d or something?