{"id":15086055,"url":"https://github.com/home-assistant/micropython-home-assistant","last_synced_at":"2025-10-05T15:31:43.609Z","repository":{"id":50932350,"uuid":"52746107","full_name":"home-assistant/micropython-home-assistant","owner":"home-assistant","description":":snake: Home Assistant client for MicroPython","archived":true,"fork":false,"pushed_at":"2017-01-28T20:13:57.000Z","size":16,"stargazers_count":56,"open_issues_count":0,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-09-30T19:01:19.380Z","etag":null,"topics":["framework","home-assistant","micropython"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/home-assistant.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-28T21:46:46.000Z","updated_at":"2024-08-13T13:06:29.000Z","dependencies_parsed_at":"2022-09-13T08:31:49.382Z","dependency_job_id":null,"html_url":"https://github.com/home-assistant/micropython-home-assistant","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/home-assistant%2Fmicropython-home-assistant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/home-assistant%2Fmicropython-home-assistant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/home-assistant%2Fmicropython-home-assistant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/home-assistant%2Fmicropython-home-assistant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/home-assistant","download_url":"https://codeload.github.com/home-assistant/micropython-home-assistant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235411688,"owners_count":18986065,"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":["framework","home-assistant","micropython"],"created_at":"2024-09-25T07:05:18.412Z","updated_at":"2025-10-05T15:31:38.302Z","avatar_url":"https://github.com/home-assistant.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"MicroPython Home Assistant\n==========================\n\nCommunicate with your Home Assistant instance from MicroPython. Developed for and tested with MicroPython on the ESP8266.\n\nEmbeds a slightly patched version of `micropython http-client \u003chttps://github.com/balloob/micropython-http-client\u003e`_.\n\nUsage instructions\n------------------\n\nThis has been tested to work with the alpha version of MicroPython for ESP8266 distributed among the backers of their KickStarter. Follow the instructions in their e-mail to get your ESP8266 up and running with their alpha version.\n\nThe alpha version does not have a filesystem so you'll have to copy/paste the code into the REPL. Press `ctrl+E` to put the REPL into paste-mode. Press `ctrl+d` to end paste-mode and process pasted code.\n\nCopy the contents of `__init__.py \u003chttps://github.com/balloob/micropython-home-assistant/blob/master/homeassistant/__init__.py\u003e`_ to the REPL. You can copy all constants at once but copy the classes and methods at root level one by one.\n\nYou're now all set and can follow the example below.\n\nAPI\n---\n\nConstructor:\n\n- ``HomeAssistant(host_url, api_password=None, timeout=None)``\n\nMethods:\n\n- ``states()``\n- ``is_state(entity_id, state)``\n- ``get_state(entity_id)``\n- ``set_state(entity_id, state, attributes=None)``\n- ``fire_event(event_name, event_data=None)``\n- ``call_service(domain, service, service_data=None)``\n\n.. code-block:: python\n\n    from homeassistant import HomeAssistant\n    hass = HomeAssistant('http://127.0.0.1:8123', 'my_password')\n    states = hass.states()\n    state = states[0]\n    print(\"State %s is %s\" % (state['entity_id'], state['state']))\n    print(\"Test if state is still the same: %s\" %\n          hass.is_state(state['entity_id'], state['state']))\n\n    new_state = hass.set_state('sensor.temperature', '10',\n                               {'unit_of_measurement': '%'})\n    verify_state = hass.get_state('sensor.temperature')\n    print(new_state)\n    print(verify_state)\n    print(new_state == verify_state)\n\n    hass.fire_event('some_event', {'hello': 'world'})\n\n    hass.call_service('switch', 'turn_on', {'entity_id': 'switch.ac'})\n\nDiscovery\n---------\n\nThis currently only works on the Unix MicroPython version.\n\nIt is able to automatically detect a running instance of Home Assistant on the network if the server is running the experimental `discoverable \u003chttps://github.com/balloob/home-assistant/blob/discoverable/homeassistant/components/discoverable.py\u003e`_ component.\n\nBy default the Home Assistant server will not expose it's password. In this case to get a working instance you have to pass a password to ``get_instance('my password')``.\n\n.. code-block:: python\n\n    from homeassistant.discovery import get_instance\n\n    hass = get_instance()\n\nNotes\n-----\n\n- SSL certificates are not being verified.\n- Not all micropython implementations support timeout. It defaults to 5 seconds\n  if supported. It can be overwritten by passing in a second argument to the\n  ``HomeAssistant`` constructor.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhome-assistant%2Fmicropython-home-assistant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhome-assistant%2Fmicropython-home-assistant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhome-assistant%2Fmicropython-home-assistant/lists"}