{"id":15022078,"url":"https://github.com/freshlybrewedcode/pymee","last_synced_at":"2025-04-12T06:07:00.389Z","repository":{"id":62581662,"uuid":"306020096","full_name":"FreshlyBrewedCode/pymee","owner":"FreshlyBrewedCode","description":"a python library to interact with homee","archived":false,"fork":false,"pushed_at":"2024-08-25T20:47:17.000Z","size":132,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-12T06:06:45.860Z","etag":null,"topics":["home-automation","homeassistant","homee","pypi","python-library"],"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/FreshlyBrewedCode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2020-10-21T12:39:14.000Z","updated_at":"2024-08-25T20:47:19.000Z","dependencies_parsed_at":"2022-11-03T21:21:10.969Z","dependency_job_id":"c101187c-88fb-4158-9651-d8dd82f5e8d1","html_url":"https://github.com/FreshlyBrewedCode/pymee","commit_stats":{"total_commits":64,"total_committers":5,"mean_commits":12.8,"dds":0.265625,"last_synced_commit":"3a8132fb344119ce0d6a3364beb9defc9694c1d7"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreshlyBrewedCode%2Fpymee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreshlyBrewedCode%2Fpymee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreshlyBrewedCode%2Fpymee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreshlyBrewedCode%2Fpymee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreshlyBrewedCode","download_url":"https://codeload.github.com/FreshlyBrewedCode/pymee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525144,"owners_count":21118618,"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":["home-automation","homeassistant","homee","pypi","python-library"],"created_at":"2024-09-24T19:57:25.604Z","updated_at":"2025-04-12T06:07:00.366Z","avatar_url":"https://github.com/FreshlyBrewedCode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pymee\n\n![PyPI](https://img.shields.io/pypi/v/pymee?style=for-the-badge)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pymee?color=blue\u0026logo=python\u0026logoColor=yellow\u0026style=for-the-badge)\n![GitHub last commit](https://img.shields.io/github/last-commit/FreshlyBrewedCode/pymee?style=for-the-badge)\n\n\u003e pymee is the backbone of the [Home Assistant homee integration](https://github.com/FreshlyBrewedCode/hacs-homee).\n\npymee is an unofficial python library for interacting with the [homee](https://hom.ee) smart home/home automation platform. It uses the [websockets](https://github.com/aaugustin/websockets) library to connect to a local homee cube and maintains a list of nodes (devices), attributes, groups, users and more that are updated whenever new data arrives from homee.\n\nLarge parts of this library are directly ported from the awesome [homeeApi](https://github.com/stfnhmplr/homee-api) javascript library.\n\n## Installation\n\nInstall from [PyPI](https://pypi.org/project/pymee/):\n\n```\npip install pymee\n```\n\n## Usage\n\n### Getting started\n\npymee should be used with `asyncio`:\n\n```python\nfrom pymee import Homee\nimport asyncio\nimport logging\n\n# Set debug level so we get verbose logs\nlogging.getLogger().setLevel(logging.DEBUG)\n\n# Define a simple async entry point function\nasync def main():\n    # Create an instance of Homee\n    homee = Homee(\"\u003cHOMEE IP\u003e\", \"\u003cUSERNAME\u003e\", \"\u003cPASSWORD\u003e\")\n\n    # Connect and start listening on a new task\n    homeeTask = asyncio.create_task(homee.run())\n\n    # Wait until the connection is live and all data has been received\n    await homee.wait_until_connected()\n\n    # Do something here...\n\n    # Close the connection and wait until we are disconnected\n    homee.disconnect()\n    await homee.wait_until_disconnected()\n\n# Start our entry point function\nasyncio.run(main())\n```\n\n### Access devices and attributes\n\nDevices are represented as \"nodes\" in the api. All nodes are available in the list `Homee.nodes` and are represented by the `HomeeNode` class.\nEach node has a list of attributes accessible from `HomeeNode.attributes`. The attributes on a node represent the different attributes on a device, i.e. if a light is turned on or the target temperature of a thermostat. Attributes can be identified by the `HomeeAttribute.type` property. You can compare the type with the values from `pymee.const.AttributeType` to figure out what each attribute represents. The value can be accessed with the `HomeeAttribute.current_value` property.\n\nIf you need to change the value of an attribute you can use `Homee.set_value()`:\n\n```python\n# Get some node, for example using get_node_by_id\nnode = homee.get_node_by_id(5)\n\n# Turn on the device. You need to pass the id of the node and the attribute as well as the value.\n# Using get_attribute_by_type you can quickly find the desired attribute.\nawait homee.set_value(node.id, node.get_attribute_by_type(AttributeType.ON_OFF).id, 1)\n```\n\n### Receiving updates\n\nThe `Homee` class can be inherited to receive events:\n\n```python\nclass MyHomee(Homee):\n    # Called once the websocket connection has been established.\n    async def on_connected(self):\n        pass\n\n    # Called after the websocket connection has been closed.\n    async def on_disconnected(self):\n        pass\n\n    # Called after an error has occurred.\n    async def on_error(self, error: str):\n        pass\n\n    # Called when the websocket receives a message.\n    # The message is automatically parsed from json into a dictionary.\n    async def on_message(self, msg: dict):\n        pass\n\n    # Called when an 'attribute' message was received and an attribute was updated.\n    # Contains the parsed json attribute data and the corresponding node instance.\n    async def on_attribute_updated(self, attribute_data: dict, node: HomeeNode):\n        pass\n```\n\nYou can also add a listener to specific nodes to receive attribute updates:\n\n```python\n# A listener is just a function that takes a node and an attribute\ndef my_node_handler(node: HomeeNode, attribute: HomeeAttribute):\n    logging.info(f\"Attribute {attribute.id} of node {node.name} was updated!\")\n\nnode = homee.get_node_by_id(5)\n\n# Adding the listener will return a function that can be called to remove the listener again\nremove_listener = node.add_on_changed_listener(my_node_handler)\n\n# If you don't need the listener anymore...\nremove_listener()\n```\n\nTo manually request updates from Homee, you can use the following functions:\n\n```python\nhomee.update_node(self, nodeId: int)\n\"\"\"Request current data for a node.\"\"\"\n\nhomee.update_attribute(self, nodeId: int, attributeId: int)\n\"\"\"Request current data for an attribute\"\"\"\n```\n\n### More examples\n\nExample implementation that dumps all info into a json file and logs whenever a light is turned on or off:\n\n```python\nfrom pymee.const import NodeProfile, AttributeType\nfrom pymee.model import HomeeAttribute\n\nclass JsonHomee(Homee):\n    async def on_message(self, msg: dict):\n        # Homee sends an \"all\" message at the beginning of each connection\n        # or after 'GET:all' was send.\n        if list(msg)[0] == \"all\":\n            f = open(\"homee.json\", \"w\")\n            f.write(json.dumps(msg))\n            f.close()\n\n    async def on_attribute_updated(self, attribute_data, node):\n        # Wrap the attribute data with the HomeeAttribute class for easier access\n        attribute = HomeeAttribute(attribute_data)\n\n        # We only care for changes\n        if attribute.current_value == attribute.target_value:\n            return\n\n        # Check node profile (the type of device) and attribute type\n        if (\n            node.profile == NodeProfile.DIMMABLE_EXTENDED_COLOR_LIGHT\n            and attribute.type == AttributeType.ON_OFF\n        ):\n            self._log(\n                f\"[Light] {node.name} turned {'on' if attribute.target_value == 1 else 'off'}\"\n            )\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshlybrewedcode%2Fpymee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreshlybrewedcode%2Fpymee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreshlybrewedcode%2Fpymee/lists"}