Skip to content

Instantly share code, notes, and snippets.

@hollie
Last active December 10, 2016 07:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hollie/631b7351532210fced976f358cb1ff38 to your computer and use it in GitHub Desktop.
Save hollie/631b7351532210fced976f358cb1ff38 to your computer and use it in GitHub Desktop.
Example code for MisterHouse: react to xPL-enabled motion detector
# In items.mht:
# XPL_SENSOR, hollie-jeenodes.nessie:room31, motion_berging, Berging, motion
# in user code
if ($motion_berging->state_changed()) {
my $state = $motion_berging->state();
if ($plafond_berging->get_set_by() =~ /^web/ && $plafond_berging->state() ne 'off') {
# Was set on by web interface, don't react to motion detector right now to allow forcing the light to steady 'on' via web interface
} else {
if ($state eq 'on') {
$plafond_berging->bri(100);
} else {
$plafond_berging->set('off');
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment