{"id":20084479,"url":"https://github.com/pierregode/mmm-phonedetect","last_synced_at":"2025-05-06T01:31:57.390Z","repository":{"id":215119008,"uuid":"738167664","full_name":"PierreGode/MMM-PhoneDetect","owner":"PierreGode","description":"Detect if phones or devices are in network and turns on and off mirror display.","archived":false,"fork":false,"pushed_at":"2024-07-13T00:36:55.000Z","size":128,"stargazers_count":9,"open_issues_count":3,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T06:50:30.323Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PierreGode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-02T15:32:36.000Z","updated_at":"2025-03-09T20:01:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2d45082-847d-4587-9f23-52369d77c674","html_url":"https://github.com/PierreGode/MMM-PhoneDetect","commit_stats":null,"previous_names":["pierregode/mmm-phonedetect"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreGode%2FMMM-PhoneDetect","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreGode%2FMMM-PhoneDetect/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreGode%2FMMM-PhoneDetect/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PierreGode%2FMMM-PhoneDetect/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PierreGode","download_url":"https://codeload.github.com/PierreGode/MMM-PhoneDetect/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252604360,"owners_count":21775089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T15:52:10.764Z","updated_at":"2025-05-06T01:31:57.129Z","avatar_url":"https://github.com/PierreGode.png","language":"JavaScript","funding_links":["https://ko-fi.com/J3J2EARPK"],"categories":[],"sub_categories":[],"readme":"# MMM-PhoneDetect\n\n**MMM-PhoneDetect is a module for [MagicMirror²](https://github.com/MagicMirrorOrg/MagicMirror) that automatically controls the screen's power based on the presence of specified phones or devices within the network.**\n\n## Screenshot\n\n![screenshot](screenshot.png)\n\n## Description\n\nFor raspberry pi\n\nDetect if phones are online in the network and turn on and off the mirror depending on the status.\nConfigured devices in config.js are represented as dots and will show them as green when the device is responding to ARP or nmap.\n\n\u003e [!WARNING]\n\u003e **update april 2024:** vcgencmd stopped working with latest rasbian Operating System: Debian GNU/Linux 12 (bookworm)\n\n\n## How to install\n\n```bash\ncd MagicMirror/modules\n```\n\n```bash\ngit clone https://github.com/PierreGode/MMM-PhoneDetect\n```\n\nThe module is designed for Raspberry Pi and requires apt programs:\n\n```bash\nsudo apt-get install arp-scan -y\nsudo apt-get install nmap -y\n```\n\n## Configuration\n\nIn MagicMirror/config/config.js\n\n```js\n{\n  module: \"MMM-PhoneDetect\",\n  position: \"bottom_right\", // Change the position as needed\n  config: {\n    phones: [\"XX:XX:XX:XX:XX:XX\", \"YY:YY:YY:YY:YY:YY\"], // List of phone MAC addresses to detect\n    turnOnCommand: \"vcgencmd display_power 1 2\", // Command to turn on the mirror\n    turnOffCommand: \"vcgencmd display_power 0 2\", // Command to turn off the mirror\n    startignoreHour: 23, // Begin ignore period at 23:00, this will prevent the Command to turn off/on the mirror specific hours\n    endignoreHour: 6,   // End ignore period at 6:00\n    checkInterval: 5000, // Check for phone presence every 5 seconds\n    nonResponsiveDuration: 1800000, // Duration in milliseconds (30 min by default)\n  },\n},\n```\n\nDefault is turn off mirror after 30 minutes if no device is detected, which can be adjusted in `config.js`.\n\nPhones go to sleep mode when not used and stop responding to ARP so recommended is to have 30 minutes for one device of inactivity ( nonResponsiveDuration ) configured before the module turns off the mirror.\n\nAlso best if you add multiple devices ( people ) for better stability/redundancy. 1 device 30 min, 2 devices, 15 min, 3 devices, 7 min and so on.\n\n## How it works\n\n\"Dual-Scan Technology\" in the context of the MMM-PhoneDetect module for MagicMirror² refers to the combined use of ARP (Address Resolution Protocol) and nmap (Network Mapper) scans to detect the presence of specific devices (like mobile phones) on a network. Here's a breakdown of how each technology contributes to the dual-scan approach:\n\n### ARP Scan\n\nPurpose: ARP is used for mapping IP network addresses to the hardware addresses (MAC addresses) used by a data link protocol.\nOperation: The ARP scan sends requests to each IP address in the subnet and listens for responses. Each responding device provides its MAC address.\n\nUse in MMM-PhoneDetect: ARP scanning is a fast and efficient way to discover devices that are directly reachable in the local network. In the context of MMM-PhoneDetect, it's used to quickly check if the phones (identified by their MAC addresses) are currently active on the local network.\n\n### nmap Scan\n\nPurpose: nmap is a network scanning tool used for network discovery and security auditing.\nOperation: nmap can be used to discover devices on a network and determine various characteristics about them, such as open ports, operating systems, device types, and more.\n\nUse in MMM-PhoneDetect: In this module, nmap is used in a more passive mode (-sn flag) to perform a network sweep without port scanning. It helps in identifying devices that might not respond to ARP but are still present on the network.\nHow Dual-Scan Works Together:\n\nComplementary Methods: While ARP scan is quick and works well within the local subnet, nmap provides a more comprehensive network sweep.\n\nEnhanced Reliability: By combining both methods, MMM-PhoneDetect increases the reliability of detecting whether the specified phones are present on the network. If a device doesn't respond to an ARP request (possibly due to being in a power-saving mode or other reasons), the nmap scan might still detect its presence.\n\nDecision Making for Screen Control: The module uses the results from both scans to decide whether to turn the MagicMirror screen on or off. If any of the specified devices are detected by either ARP or nmap scan, the screen is turned on; if all devices are absent according to both scans, and the specified time conditions are met, the screen is turned off.\n\n## Testing\n\nTest that the commands for turning on and off the mirror works in terminal:\n\n```bash\nvcgencmd display_power 1 2 # Command to turn on the mirror\nvcgencmd display_power 0 2 # Command to turn off the mirror\n```\n\nIf they do not work you might need to change the drivers in `/boot/config.txt`.\n\n```bash\nsudo nano /boot/config.txt\n```\n\nChange dtoverlay=vc4-kms-v3d to:\n\n```bash\ndtoverlay=vc4-fkms-v3d\n```\n\nand reboot.\n\n/Created by Pierre Gode\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/J3J2EARPK)\n\ndevelopment status = WIP\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierregode%2Fmmm-phonedetect","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpierregode%2Fmmm-phonedetect","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpierregode%2Fmmm-phonedetect/lists"}