{"id":21917489,"url":"https://github.com/clusterm/google-assistant-smart-home","last_synced_at":"2025-08-01T12:07:43.869Z","repository":{"id":69562594,"uuid":"266359031","full_name":"ClusterM/google-assistant-smart-home","owner":"ClusterM","description":"Simple Python framework to control your DIY smart home devices using Google Assistant","archived":false,"fork":false,"pushed_at":"2024-02-20T18:51:58.000Z","size":20,"stargazers_count":81,"open_issues_count":5,"forks_count":23,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-16T02:06:10.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ClusterM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["ClusterM"],"custom":["https://www.buymeacoffee.com/cluster","https://boosty.to/cluster"]}},"created_at":"2020-05-23T14:59:08.000Z","updated_at":"2025-01-25T15:55:01.000Z","dependencies_parsed_at":"2023-05-16T08:15:39.297Z","dependency_job_id":null,"html_url":"https://github.com/ClusterM/google-assistant-smart-home","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClusterM%2Fgoogle-assistant-smart-home","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClusterM%2Fgoogle-assistant-smart-home/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClusterM%2Fgoogle-assistant-smart-home/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ClusterM%2Fgoogle-assistant-smart-home/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ClusterM","download_url":"https://codeload.github.com/ClusterM/google-assistant-smart-home/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249666977,"owners_count":21308157,"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-28T19:32:57.538Z","updated_at":"2025-04-19T09:47:59.633Z","avatar_url":"https://github.com/ClusterM.png","language":"Python","funding_links":["https://github.com/sponsors/ClusterM","https://www.buymeacoffee.com/cluster","https://boosty.to/cluster"],"categories":[],"sub_categories":[],"readme":"# google-assistant-smart-home\nSimple Python framework to control your DIY smart home devices using Google Assistant\n\n## Requirements\n* Web server (you can use some single-board computer like Raspberry Pi)\n* Domain name\n* SSL certificate for HTTPS (you can use free certificate from Let's Entrypt)\n* This project is based on Flask, so you need Python 3.x.x and Flask to be installed\n\n## How to install\n* Checkout project somewhere on your server\n* Edit __google_home.wsgi__ and change path to project directory\n* Deploy project to your web server using WSGI, don't forget to allow authorization header\n* Go to https://console.actions.google.com/ and create new project, select \"smart home\" type\n* Open \"Develop\"-\u003e\"Invocation\" and type name of your project\n* Open \"Develop\"-\u003e\"Actions\" and type fulfillment URL: https://_your-domain-name_/\n* Open \"Develop\"-\u003e\"Account linking\" and type\n\nClient ID: some ID, just remember it for now\n\nClient secret: some password, remember it too and keep it secret\n\nAuthorization URL: https://_your-domain-name_/auth/\n\nToken URL: https://_your-domain-name_/token/\n\n* Open https://console.cloud.google.com -\u003e \"APIs \u0026 Services\" -\u003e \"ENABLE APIS AND SERVICES\" -\u003e \"HomeGraph API\" -\u003e \"Manage\" -\u003e \"Credentials\" -\u003e \"Credentials in APIs \u0026 Services\" -\u003e \"CREATE CREDENTIALS\" -\u003e \"API Key\", store it somewhere\n* Edit __config.py__ and fill __CLIENT_ID__, __CLIENT_SECRET__ and __API_KEY__ with your credentials, also change __USERS_DIRECTORY__, __TOKENS_DIRECTORY__, and __DEVICES_DIRECTORY__ to your __users__, __tokens__ and __devices__ paths\n* It's recommended to __chmod go-rwx tokens users__\n\n## How to use\n* Create file _username_.json in __users__ directory and write json config for user with password and list of available devices:\n```json\n{\n    \"password\": \"test\",\n    \"devices\": [\n        \"pc\"\n    ]\n}\n```\n\n* Create file _device-name_.json in __devices__ directory and write json config for device using Google guides: https://developers.google.com/assistant/smarthome/concepts/devices-traits\n\nExample for simple on-off device:\n```json\n{\n    \"type\": \"action.devices.types.SWITCH\",\n    \"traits\": [\n        \"action.devices.traits.OnOff\"\n    ],\n    \"name\": {\n        \"name\": \"PC\",\n        \"defaultNames\": [\n          \"PC\",\n          \"Computer\"\n        ],\n        \"nicknames\": [\n          \"PC\",\n          \"Computer\"\n        ]\n    },\n    \"willReportState\": false,\n    \"roomHint\": \"My room\",\n    \"deviceInfo\": {\n        \"manufacturer\": \"Cluster\",\n        \"model\": \"1\",\n        \"hwVersion\": \"1\",\n        \"swVersion\": \"1\"\n    }\n}\n```\n* Create file _device-name_.py in __devices__ directory and write python script with two methods: *device-name*_query(custom_data) and *device-name*_command(custom_data, command, params)\n\nExample script to turn on/off PC:\n```python\nimport subprocess\n\ndef pc_query(custom_data):\n    p = subprocess.run([\"ping\", \"-c\", \"1\", \"192.168.0.2\"], stdout=subprocess.PIPE)\n    state = p.returncode == 0\n    return {\"on\": state, \"online\": True}\n\ndef pc_action(custom_data, command, params):\n    if command == \"action.devices.commands.OnOff\":\n        if params['on']:\n            subprocess.run([\"wakeonlan\", \"-i\", \"192.168.0.255\", \"00:11:22:33:44:55\"])\n        else:\n            subprocess.run([\"sh\", \"-c\", \"echo shutdown -h | ssh clust@192.168.0.2\"])\n        return {\"status\": \"SUCCESS\", \"states\": {\"on\": params['on'], \"online\": True}}\n    else:\n        return {\"status\": \"ERROR\"}\n\n```\nQuery fuction must return device status object, and action function must return action result. Please read traits documentation for more info: https://developers.google.com/assistant/smarthome/traits.\n\n* Open Google Home app on your phone and link it with your project\n* Done! You can control your devices using voice commands or Google Home app\n* Run __sync.py__ script when you need to update devices list\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclusterm%2Fgoogle-assistant-smart-home","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclusterm%2Fgoogle-assistant-smart-home","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclusterm%2Fgoogle-assistant-smart-home/lists"}