# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['cozify', 'cozify.test']

package_data = \
{'': ['*']}

install_requires = \
['absl-py>=1.0.0,<2.0.0', 'requests>=2.27.1,<3.0.0']

setup_kwargs = {
    'name': 'cozify',
    'version': '0.2.31',
    'description': 'Unofficial Python3 API bindings for the (unpublished) Cozify API.',
    'long_description': 'python-cozify\n=============\n\n|docs| |ci| |coverage| |pyversions| |gitter|\n\nUnofficial Python3 API bindings for the (unpublished) Cozify API.\nIncludes high-level helpers for easier use of the APIs,\nfor example an automatic authentication flow, and low-level 1:1 API functions.\n\n.. contents:: :local:\n\nInstallation\n------------\n\nPython3.8 is the current minimum supported version of Python.\nFor example Ubuntu 20.04 LTS is still supported out of the box, older versions may need a manual Python upgrade or PPA.\n\nThe recommended way is to install from PyPi:\n\n.. code:: console\n\n       sudo -H pip3 install cozify\n\nTo benefit from new features you\'ll need to update the library (pip does not auto-update):\n\n.. code:: console\n\n       sudo -H pip3 install -U cozify\n\nor if developing, clone the master branch of this repo (master stays at current release) and:\n\n.. code:: console\n\n       curl -sSL https://install.python-poetry.org | python -\n       poetry install\n\nTo develop python-cozify clone the devel branch and submit pull requests against the devel branch.\nNew releases are cut from the devel branch as needed.\n\nBasic usage\n-----------\nThese are merely some simple examples, for the full documentation see: `http://python-cozify.readthedocs.io/en/latest/`\n\nread devices by capability, print temperature data\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    from cozify import hub\n    devices = hub.devices(capabilities=hub.capability.TEMPERATURE)\n    for id, dev in devices.items():\n      print(\'{0}: {1}C\'.format(dev[\'name\'], dev[\'state\'][\'temperature\']))\n\nonly authenticate\n~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    from cozify import cloud\n    cloud.authenticate()\n    # authenticate() is interactive and usually triggered automatically\n    # authentication data is stored in ~/.config/python-cozify/python-cozify.cfg\n\nauthenticate with a non-default state storage\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n    from cozify import cloud, config\n    config.setStatePath(\'/tmp/testing-state.cfg\')\n    cloud.authenticate()\n    # authentication and other useful data is now stored in the defined location instead of ~/.config/python-cozify/python-cozify.cfg\n    # you could also use the environment variable XDG_CONFIG_HOME to override where config files are stored\n\nOn Capabilities\n---------------\nThe most practical way to "find" devices for operating on is currently to filter the devices list by their capabilties. The\nmost up to date list of recognized capabilities can be seen at `cozify/hub.py <cozify/hub.py#L21>`_\n\nIf the capability you need is not yet supported, open a bug to get it added. One way to compare your live hub device\'s capabilities\nto those implemented is running the util/capabilities_list.py tool. It will list implemented and gathered capabilities from your live environment.\nTo get all of your previously unknown capabilities implemented, just copy-paste the full output of the utility into a new bug.\n\nIn short capabilities are tags assigned to devices by Cozify that mostly guarantee the data related to that capability will be in the same format and structure.\nFor example the capabilities based example code in this document filters all the devices that claim to support temperature and reads their name and temperature state.\nMultiple capabilities can be given in a filter by providing a list of capabilities. By default any capability in the list can match (OR filter) but it can be flipped to AND mode\nwhere every capability must be present on a device for it to qualify. For example, if you only want multi-sensors that support both temperature and humidity monitoring you could define a filter as:\n\n.. code:: python\n\n    devices = hub.devices(capabilities=[ hub.capability.TEMPERATURE, hub.capability.HUMIDITY ], and_filter=True)\n\nKeeping authentication valid\n----------------------------\nIf the cloud token expires, the only option to get a new one is an interactive prompt for an OTP.\nSince most applications will want to avoid that as much as possible there are a few tips to keep a valid token alive.\nAt the time of writing tokens are valid for 28 days during which they can be seamlessly refreshed.\n\nIn most cases it isn\'t necessary to directly call cloud.refresh() if you\'re already using cloud.ping() to test token validity.\ncloud.ping() will also perform a refresh check after a successful ping unless explicitly told not to do so.\n\nTo refresh a token you can call as often as you want:\n\n.. code:: python\n\n    cloud.refresh()\n\nBy default keys older than a day will be re-requested and otherwise no refresh is performed. The refresh can be forced:\n\n.. code:: python\n\n    cloud.refresh(force=True)\n\nAnd the expiry duration can be altered (also when calling cloud.ping()):\n\n.. code:: python\n\n    cloud.refresh(expiry=datetime.timedelta(days=20))\n    # or\n    cloud.ping(autorefresh=True, expiry=datetime.timedelta(days=20))\n\nWorking Remotely\n----------------\nBy default queries to the hub are attempted via local LAN. Also by default "remoteness" autodetection is on and thus\nif it is determined during cloud.authentication() or a hub.ping() call that you seem to not be in the same network, the state is flipped.\nBoth the remote state and autodetection can be overriden in most if not all funcions by the boolean keyword arguments \'remote\' and \'autoremote\'. They can also be queried or permanently changed by the hub.remote() and hub.autoremote() functions.\n\nUsing Multiple Hubs\n-------------------\nEverything has been designed to support multiple hubs registered to the same Cozify Cloud account. All hub operations can be targeted by setting the keyword argument \'hub_id\' or \'hub_name\'. The developers do not as of yet have access to multiple hubs so proper testing of multi functionality has not been performed. If you run into trouble, please open bugs so things can be improved.\n\nThe remote state of hubs is kept separately so there should be no issues calling your home hub locally but operating on a summer cottage hub remotely at the same time.\n\nEnconding Pitfalls\n------------------\nThe hub provides data encoded as a utf-8 json string. Python-cozify transforms this into a Python dictionary\nwhere string values are kept as unicode strings. Normally this isn\'t an issue, as long as your system supports utf-8.\nIf not, you will run into trouble printing for example device names with non-ascii characters:\n\n    UnicodeEncodeError: \'ascii\' codec can\'t encode character \'\\xe4\' in position 34: ordinal not in range(128)\n\nThe solution is to change your system locale to support utf-8. How this is done is however system dependant.\nAs a first test try temporarily overriding your locale:\n\n.. code:: console\n\n    LC_ALL=\'en_US.utf8\' python3 program.py\n\nSample projects\n---------------\n\n-  `github.com/Artanicus/cozify-temp <https://github.com/Artanicus/cozify-temp>`__\n   - Store Multisensor data into InfluxDB\n-  Take a look at the util/ directory for some crude small tools using the library that have been useful during development.\n-  File an issue to get your project added here\n\nDevelopment\n-----------\nTo develop python-cozify clone the devel branch and submit pull requests against the devel branch.\nNew releases are cut from the devel branch as needed.\n\nTests\n~~~~~\npytest is used for unit tests.\n\n-  Certain tests are marked as "live" tests and require an active authentication state and a real hub to query against. Live tests are non-destructive.\n-  Some tests are marked as "destructive" and will cause changes such as a light being turned on or tokens getting invalidated on purpose.\n-  A few tests are marked as "remote" and are only expected to succeed when testing remotely, i.e. outside the LAN of the hub.\n-  A few tests are marked as "mbtest" and will only work if a MonteBank server is available. If a non-local instance is desired, provide a .env file with MBTEST_HOST set.\n-  Most tests are marked as "logic" and do not require anything external. If no set is defined, only logic tests are run.\n\nDuring development you can run the test suite right from the source directory:\n\n.. code:: console\n\n    pytest\n    # or run only live tests:\n    pytest -m live\n    # run everything except destructive * MonteBank tests:\n    pytest -m "not destructive and not mbtest"\n\nTo run the test suite on an already installed python-cozify (defining a set is mandatory, otherwise ALL sets are run including destructive):\n\n.. code:: console\n\n    pytest -v -m logic --pyargs cozify\n\n\nRoadmap, aka. Current Limitations\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n-  Authentication flow has been improved quite a bit but it would benefit a lot from real-world feedback.\n-  For now there are only read calls. Next up is implementing ~all hub calls at the raw level and then wrapping them for ease of use. If there\'s something you want to use sooner than later file an issue so it can get prioritized!\n-  Device model is non-existant and the old implementations are bad and deprecated. Active work ongoing to filter by capability at a low level first, then perhaps a more object oriented model on top of that.\n\n\n.. |docs| image:: https://readthedocs.org/projects/python-cozify/badge/?version=latest\n  :target: http://python-cozify.readthedocs.io/en/latest/?badge=latest\n  :alt: Documentation Status\n\n.. |ci| image:: https://travis-ci.com/Artanicus/python-cozify.svg?branch=master\n  :target: https://travis-ci.com/Artanicus/python-cozify\n  :alt: Build Status\n\n.. |coverage| image:: https://codecov.io/gh/Artanicus/python-cozify/branch/master/graph/badge.svg\n  :target: https://codecov.io/gh/Artanicus/python-cozify\n  :alt: Coverage Status\n\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/cozify.svg\n  :alt: PyPI - Python Version\n\n.. |gitter| image:: https://badges.gitter.im/python-cozify/Lobby.svg\n  :alt: Join the chat at https://gitter.im/python-cozify/Lobby\n  :target: https://gitter.im/python-cozify/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge\n',
    'author': 'Artanicus',
    'author_email': 'artanicus@nocturnal.fi',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/Artanicus/python-cozify',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
