{"id":13499843,"url":"https://github.com/hidaris/thingtalk","last_synced_at":"2026-01-17T08:43:09.523Z","repository":{"id":48803171,"uuid":"244914010","full_name":"hidaris/thingtalk","owner":"hidaris","description":"WebThings framework.","archived":false,"fork":false,"pushed_at":"2022-11-25T07:48:48.000Z","size":578,"stargazers_count":20,"open_issues_count":7,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-01-13T15:53:55.250Z","etag":null,"topics":["asyncio","fastapi","iot","web-of-things","webthings"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hidaris.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}},"created_at":"2020-03-04T13:57:14.000Z","updated_at":"2025-10-04T01:11:17.000Z","dependencies_parsed_at":"2023-01-23T09:31:22.039Z","dependency_job_id":null,"html_url":"https://github.com/hidaris/thingtalk","commit_stats":null,"previous_names":["hidaris/aiowebthing"],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/hidaris/thingtalk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidaris%2Fthingtalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidaris%2Fthingtalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidaris%2Fthingtalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidaris%2Fthingtalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hidaris","download_url":"https://codeload.github.com/hidaris/thingtalk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hidaris%2Fthingtalk/sbom","scorecard":{"id":464084,"data":{"date":"2025-08-11","repo":{"name":"github.com/hidaris/thingtalk","commit":"ac9d2fe70ab56556a59a8174d45810f5665f992f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/hidaris/thingtalk/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/hidaris/thingtalk/publish.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/hidaris/thingtalk/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/hidaris/thingtalk/test.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/publish.yml:31","Warn: pipCommand not pinned by hash: .github/workflows/test.yml:25","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: Mozilla Public License 2.0: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-19T11:58:33.163Z","repository_id":48803171,"created_at":"2025-08-19T11:58:33.163Z","updated_at":"2025-08-19T11:58:33.163Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504409,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["asyncio","fastapi","iot","web-of-things","webthings"],"created_at":"2024-07-31T22:00:43.927Z","updated_at":"2026-01-17T08:43:09.503Z","avatar_url":"https://github.com/hidaris.png","language":"Python","funding_links":[],"categories":["Section"],"sub_categories":["Libraries"],"readme":"\u003ch1 align=\"center\"\u003eProject ThingTalk\u003c/h1\u003e\n\n\u003ch2 align=\"center\"\u003eThing as a Service\u003c/h2\u003e\n\n[![pypi-v](https://img.shields.io/pypi/v/thingtalk.svg)](https://pypi.python.org/pypi/thingtalk)\n[![python](https://img.shields.io/pypi/pyversions/thingtalk.svg)](https://github.com/hidaris/thingtalk)\n\n## What is `thingtalk` ?\n`thingtalk` is a library for the Web of Things protocol in Python Asyncio. This library is derived of webthing-python project (supporting Tornado) but adapted for fastapi (based on Uvicorn for better performance).\n\n### additional features\n1. additional_routes -- list of additional routes add to the server\n2. additional_middlewares -- list of additional middlewares add to the server\n3. additional_on_startup -- list of additional starup event handlers add to the server\n4. additional_on_shutdown -- list of additional shutdown event handlers add to the server\n5. thing.sync_property -- Sync a property value from cloud or mqtt broker etc, property set value with no action disclaim.\n6. thing.property_action -- addional action sync the property change to device. \n6. property.set_value(value, with_action=True) -- if with_action is True, Value instance should emit `update`, else `sync`\n7. Add the property change observer to notify the Thing about a property change or do some additional action:\n\n```python\nself.value.on(\"update\", lambda _: self.thing.property_notify(self))\nself.value.on(\"sync\", lambda _: self.thing.property_notify(self))\nself.value.on(\"update\", lambda _: self.thing.property_action(self))\n```\n   \n\n\n## Installation\nthingtalk can be installed via pip, as such:\n\n`$ pip install thingtalk`\n\n## Running the Sample\n`$ wget\nhttps://raw.githubusercontent.com/hidaris/thingtalk/master/example/test.py`\n\n`$ uvicorn test:app --reload`\n\nThis starts a server and lets you search for it from your gateway through mDNS. To add it to your gateway, navigate to the Things page in the gateway's UI and click the + icon at the bottom right. If both are on the same network, the example thing will automatically appear.\n\n## Example Implementation\nIn this code-walkthrough we will set up a dimmable light and a humidity sensor (both using fake data, of course). Both working examples can be found in here.\n\nDimmable Light\nImagine you have a dimmable light that you want to expose via the web of things API. The light can be turned on/off and the brightness can be set from 0% to 100%. Besides the name, description, and type, a Light is required to expose two properties:\n\non: the state of the light, whether it is turned on or off\nSetting this property via a PUT {\"on\": true/false} call to the REST API toggles\nthe light.\n\nbrightness: the brightness level of the light from 0-100%\nSetting this property via a PUT call to the REST API sets the brightness level of this light.\nFirst we create a new Thing:\n\n``` python\nfrom thingtalk import Thing, Property, Value\n\n\nclass Light(Thing):\n    type = ['OnOffSwitch', 'Light'],\n    description = 'A web connected lamp'\n    \n    super().__init__(\n        'urn:dev:ops:my-lamp-1234',\n        'My Lamp',\n    )\n```\nNow we can add the required properties.\n\nThe on property reports and sets the on/off state of the light. For this, we need to have a Value object which holds the actual state and also a method to turn the light on/off. For our purposes, we just want to log the new state if the light is switched on/off.\n\n``` python\nasync def build(self):\n    on = Property(\n            'on',\n            Value(True, lambda v: print('On-State is now', v)),\n            metadata={\n                '@type': 'OnOffProperty',\n                'title': 'On/Off',\n                'type': 'boolean',\n                'description': 'Whether the lamp is turned on',\n        })\n    await self.add_property(on)\n```\n\nThe brightness property reports the brightness level of the light and sets the level. Like before, instead of actually setting the level of a light, we just log the level.\n\n``` python\nbrightness = Property(\n         'brightness',\n        Value(50, lambda v: print('Brightness is now', v)),\n        metadata={\n            '@type': 'BrightnessProperty',\n            'title': 'Brightness',\n            'type': 'number',\n            'description': 'The level of light from 0-100',\n            'minimum': 0,\n            'maximum': 100,\n            'unit': 'percent',\n        })\nawait self.add_property(brightness)\n```\n\nNow we can add our newly created thing to the server and start it:\n\n``` python\n# If adding more than one thing, use MultipleThings() with a name.\n# In the single thing case, the thing's name will be broadcast.\nwith background_thread_loop() as loop:\n    app = WebThingServer(loop, Light).create()\n```\n\nThis will start the server, making the light available via the WoT REST API and announcing it as a discoverable resource on your local network via mDNS.\n\nSensor\nLet's now also connect a humidity sensor to the server we set up for our light.\n\nA MultiLevelSensor (a sensor that returns a level instead of just on/off) has one required property (besides the name, type, and optional description): level. We want to monitor this property and get notified if the value changes.\n\nFirst we create a new Thing:\n\n```python\nfrom thingtalk import Thing, Property, Value\n\nclass Light(Thing):\n    type = ['MultiLevelSensor'],\n    description = 'A web connected humidity sensor'\n    \n    super().__init__(\n        'urn:dev:ops:my-humidity-sensor-1234',\n        'My Humidity Sensor',\n    )\n```\n\nThen we create and add the appropriate property:\n\nlevel: tells us what the sensor is actually reading\n\nContrary to the light, the value cannot be set via an API call, as it wouldn't make much sense, to SET what a sensor is reading. Therefore, we are creating a readOnly property.\n\n```python\nasync def build(self): \n    await self.add_property(\n        Property(\n            'level',\n            Value(0.0),\n            metadata={\n                '@type': 'LevelProperty',\n                'title': 'Humidity',\n                'type': 'number',\n                'description': 'The current humidity in %',\n                'minimum': 0,\n                'maximum': 100,\n                'unit': 'percent',\n                'readOnly': True,\n            }))\n    return self\n```\n\n\nNow we have a sensor that constantly reports 0%. To make it usable, we need a thread or some kind of input when the sensor has a new reading available. For this purpose we start a thread that queries the physical sensor every few seconds. For our purposes, it just calls a fake method.\n\n```python\nself.sensor_update_task = \\\n    get_event_loop().create_task(self.update_level())\n\nasync def update_level(self):\n    try:\n        while True:\n            await sleep(3)\n            new_level = self.read_from_gpio()\n            logging.debug('setting new humidity level: %s', new_level)\n            await self.level.notify_of_external_update(new_level)\n    except CancelledError:\n        pass\n```\n\nThis will update our Value object with the sensor readings via the self.level.notify_of_external_update(read_from_gpio()) call. The Value object now notifies the property and the thing that the value has changed, which in turn notifies all websocket listeners.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhidaris%2Fthingtalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhidaris%2Fthingtalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhidaris%2Fthingtalk/lists"}