This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
pimatic-netcheck with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
pimatic-netcheck is a pimatic plugin that allows you to check if some network or bluetooth devices are present.
The main goal of this plugin is to send specific messages (using other plugins like pimatic-telegram) or do some actions if a contact sensor is opened and nobody is at home (no smartphones are at home).
You can trigger a NetCheck by a rule and execute other rules as a result of this check.
contact-sensor-door is opened
check netcheck-1 if absent exec rule send-alarm-message
Additionally a check can be triggert automatically using an interval.
Device configuration localized in:
There are two supported check methods:
You have to create at least one NetCheckDevice, which will act as a PresenceSensor (present = NetCheck successfull, absent = NetCheck not successfull).
To this device you may add some IP addresses/hostnames and/or bluetooth MAC addresses. These are the external devices (e.g. smartphones) which will be checked.
Using the needAll option, you can define if all listed devices must be peresent or only one.
You may also set a check interval to do a scheduled automatic check.
check <NetCheckDevice> [if present exec rule <RuleID>] [if absent exec rule <RuleID>]
If a ContactSensor is opened, then do a NetCheck and only if the NetCheck failed send a message using telegram.
First create a new rule containing the action to send the message. Here you should use a When condition which is never fulfilled, e.g.
1 is 0:
1 is 0
send text telegram to "test"
Then create a second rule to run the NetCheck and if needed trigger the first rule:
contact-sensor-1 is opened
check netcheck-test if absent exec rule tg-send-test
This will run the NetCheck of the device
netcheck-test and if this check reported absent (the check failed) the action of the first rule
tg-send-test is executed.
You may also add a rule which gets executed if the check reported present.
You need a Raspberry Pi with integrated bluetooth (e.g. 3B) or an additional bluetooth dongle.
If your hardware is ready you need to install the
bluetooth package from command line:
sudo apt-get install bluetooth
To use the bluetooth netcheck you must pair your bluetooth device with your Raspberry Pi running pimatic.
This can be done using the commant line as follows:
hcitool scanfrom your command line to get the MAC address (e.g. BA:BE:13:37:BE:EF).
sudo hcitool cc <MAC>; sudo hcitool auth <MAC>from your command line. Make shure to replace
<MAC>with your MAC address from step 2.
sudo hcitool info <MAC>from your command line. This should print some information about your device.
If the pairing was successfull you can add the MAC address to a NetCheckDevice in pimatic.
Licensed under GPL Version 2
Copyright (c) 2017 Peter Müller email@example.com (https://crycode.de/)