{"id":24444122,"url":"https://github.com/ayshmnmm/lightsy","last_synced_at":"2025-08-03T13:07:29.520Z","repository":{"id":267591386,"uuid":"901728247","full_name":"ayshmnmm/lightsy","owner":"ayshmnmm","description":"Presence-based lighting control system triggered by motion alerts from CCTV cameras","archived":false,"fork":false,"pushed_at":"2024-12-11T12:05:13.000Z","size":26,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T22:49:34.004Z","etag":null,"topics":["hikvision","hikvision-isapi","iot","presence-light","smart-home","tuya"],"latest_commit_sha":null,"homepage":"","language":"Python","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/ayshmnmm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-11T07:51:14.000Z","updated_at":"2024-12-13T04:09:40.000Z","dependencies_parsed_at":"2024-12-11T11:55:18.487Z","dependency_job_id":null,"html_url":"https://github.com/ayshmnmm/lightsy","commit_stats":null,"previous_names":["ayshmnmm/lightsy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayshmnmm%2Flightsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayshmnmm%2Flightsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayshmnmm%2Flightsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ayshmnmm%2Flightsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ayshmnmm","download_url":"https://codeload.github.com/ayshmnmm/lightsy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243517679,"owners_count":20303684,"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":["hikvision","hikvision-isapi","iot","presence-light","smart-home","tuya"],"created_at":"2025-01-20T22:42:20.402Z","updated_at":"2025-03-14T03:26:57.496Z","avatar_url":"https://github.com/ayshmnmm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lightsy\n\nLightsy is a Python-based project for controlling lights based on motion detection events. It uses a `LightControl`\nclass to manage individual lights and a `PresenceLighting` class to handle motion detection events and control the\nlights accordingly. The `EventStream` class is used to listen for motion detection events from the DVR/NVR.\n\nThe project is designed to work with Hikvision cameras using the ISAPI event stream for motion detection events. It\ncontrols lights using the [tinytuya](https://github.com/jasonacox/tinytuya) library for Tuya smart devices.\n\n![](lightsy_classes.png)\n\n## Features\n\n- Turn lights on and off based on motion detection events.\n- Configure active times for lights to respond to motion.\n- Set duration for lights to stay on after motion is detected.\n- Map multiple cameras to multiple lights for presence lighting.\n\n## Installation\n\n1. Clone the repository:\n    ```sh\n    git clone https://github.com/ayshmnmm/lightsy.git\n    cd lightsy\n    ```\n\n2. Install the required dependencies:\n    ```sh\n    pip install -r requirements.txt\n    ```\n\n3. Create a `.env` file in the `src` directory with the following content:\n    ```dotenv\n    ISAPI_EVENT_URL=\"http://192.168.x.y/ISAPI/Event/notification/alertStream\"\n    ISAPI_USERNAME=\"username\"\n    ISAPI_PASSWORD=\"password\"\n    ```\n\n## Usage\n\n1. Create a `config.py` file in the `src` directory or rename `config.example.py` to `config.py` and configure the\n   devices, lights, and presence lighting mappings:\n    ```python\n    DEVICES = {\n        'device1_name': {\n            'ip': '192.168.x.y',\n            'dev_id': 'device1_id',\n            'local_key': 'device_local_key',\n            'version': 3.0\n        }\n    }\n   \n   LIGHTS = {\n         'light1_name': {\n              'device': 'device1_name',  # device name from DEVICES\n              'switch': 1  # switch id\n         }\n   }\n   \n   PRESENCE_LIGHTING_MAPPING = [\n        {\n            \"channels\": [1],  # camera channel ids\n            \"lights\": [{\n                \"light\": \"light1_name\",  # light name from LIGHTS\n                \"duration\": 45,  # duration in seconds for light to stay on after motion is detected\n                \"activeTime\": [(0, 800), (1600, 2400)]   # 24-hour format active times\n            }]\n        }\n   ]\n   ```\n\n2. Run the main script:\n    ```sh\n    python src/main.py\n    ```\n\n## Configuration\n\n- `config.py`: Contains the configuration for devices, lights, and presence lighting mappings.\n- `.env`: Contains the environment variables for the ISAPI event stream URL, username, and password.\n\n## Example\n\nAn example of handling a motion detection event:\n\n```python\nlc = LightControl(DEVICES, LIGHTS)\npl = PresenceLighting(lc, PRESENCE_LIGHTING_MAPPING)\ntest_event = {\n    \"eventType\": \"VMD\",\n    \"channelID\": 1,\n    \"dateTime\": \"1970-01-01T12:00:00\",\n    # ...\n}\npl.handle_event(test_event)\n```\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n## Contact\n\nFor any questions or feedback, please contact me at mail@ayushmanmuduli.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayshmnmm%2Flightsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fayshmnmm%2Flightsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fayshmnmm%2Flightsy/lists"}