Code copied from http://forum.mysensors.org/topic/1764/customizable-sonar-sensor to merge with code from this tutorial- http://www.instructables.com/id/SIMPLE-ARDUINO-ULTRASONIC-SENSOR-DOOR-ALARM-/ for usage as a presence sensor that can be relayed via a mysensors gateway to trigger events in an instance running homeassistant.io