homeassistant ============= .. py:module:: homeassistant .. autoapi-nested-parse:: Data source reading entity states from the Home Assistant REST API. Attributes ---------- .. autoapisummary:: homeassistant.CATALOG_DOMAINS Classes ------- .. autoapisummary:: homeassistant.HomeAssistantSource Functions --------- .. autoapisummary:: homeassistant.parse_catalog homeassistant.parse_state Module Contents --------------- .. py:data:: CATALOG_DOMAINS :value: ('sensor', 'binary_sensor', 'weather', 'climate', 'cover', 'lock', 'person', 'device_tracker',... .. py:function:: parse_catalog(text) Catalog entries from the rendered template, sorted by name. .. py:function:: parse_state(state) Convert a Home Assistant state string to int, float, str or None. .. py:class:: HomeAssistantSource(http_get, base_url, token, entities, http_post=None) Reads the configured entities, one REST request each. `http_get(url, headers)` returns (status, parsed JSON or None) and raises OSError when the server cannot be reached; `http_post(url, headers, payload)` sends JSON and returns (status, text or None). `entities` maps reading keys to entity IDs, e.g. {"office_temperature": "sensor.arbeitszimmer_temperatur"}. .. py:method:: read() Read all configured entities. With `http_post` this is one template request (much faster on the board), otherwise one GET per entity. :returns: A reading per configured key, in the format of `datasource`. :raises OSError: If Home Assistant cannot be reached. .. py:method:: catalog() List what can be shown on a tile. :returns: `[{"id", "name", "unit", "style"}]`, see `datasource`. :raises OSError: If Home Assistant cannot be reached. .. py:method:: alerts(ids) Return the active alerts among `ids`, in one request. :param ids: Entity IDs to check. :returns: Active alerts in the format of `alerts`. :raises OSError: If Home Assistant cannot be reached.