🏡 Open source home automation that puts local control and privacy first.
Find a file
Matthew Wegner 6bf42ad43d Added Search Configuration to IMAP Sensor (#19749)
* Added Search Configuration to IMAP Sensor

The IMAP sensor currently only counts unread emails in a folder.  By exposing the IMAP search parameter, the sensor can be used to count other results:

- All emails in an inbox
- Emails sent from an address
- Emails matching a subject
- Other advanced searches, especially with vendor-specific extensions.  Gmail in particular supports X-GM-RAW, which lets you use any Gmail search directly ("emails with X label older than 14 days with", etc)

For my use case, I just wanted total emails in a folder, to show an "X/Y" counter for total/unread.  I started work on a one-off script to throw the data in, but figured I'd try to extend Home Assistant more directly, especially since this IMAP sensor correctly handles servers that push data.  This is my first Home Assistant contribution, so apologies in advance if something is out of place!  It's a pretty minimal modification.

* Added Server Response Checking

Looks like no library exception is thrown, so check for response text before parsing out results (previous code just counts spaces, so an error actually returns a state value of 4).

* IMAP Warning -> Error, Count Initializes to None

IMAP search response parsing throws an error instead of a warning.

Email count initializes as None instead 0.

Email count is untouched in case of failure to parse response (i.e. if server is temporarily down or throwing errors, or maybe due to user updating their authentication/login/etc).

Fixed line length on error so it fits under 80 characters.

* Fixed Indent on Logger Error

Sorry about the churn!  Python is pretty far from my daily-use language.  (I did run this one through pep8, at least)
2019-01-19 21:37:02 +01:00
.github Add note to issue template regarding frontend issues (#19295) 2018-12-14 19:06:20 -05:00
docs Update developer doc links to developers.home-assistant.io (#16622) 2018-09-15 13:27:37 +02:00
homeassistant Added Search Configuration to IMAP Sensor (#19749) 2019-01-19 21:37:02 +01:00
script Add emulated_roku component (#17596) 2019-01-11 03:20:35 +01:00
tests Add verify_ssl to restful_command and switch.rest (#20199) (#20207) 2019-01-18 13:42:52 +01:00
virtualization Removed mkdir, If the WORKDIR doesn’t exist, it will be created. (#19892) 2019-01-10 07:18:59 +01:00
.coveragerc Add platform image_processing.qrcode (#20215) 2019-01-18 13:40:49 +01:00
.dockerignore Docker cleanup. (#8226) 2017-06-30 08:07:33 -07:00
.gitattributes Fix line endings [skipci] (#12333) 2018-02-11 23:07:28 -08:00
.gitignore Include Scripts/ directory to .gitignore - this is created by virtualenv on Windows (#18918) 2019-01-11 13:04:56 -08:00
.hound.yml Add .hound.yml 2016-11-13 11:34:09 -08:00
.ignore Include .ignore file for search utilities (#5290) 2017-01-16 22:52:53 -08:00
.readthedocs.yml Rename readthedocs file (#17718) 2018-10-23 17:39:17 +02:00
.travis.yml Try to fix coveralls unstable result (#15800) 2018-08-06 10:51:37 +02:00
CLA.md Update LICENSE.md and CLA.md to reflect the new Apache 2.0 license 2017-01-28 12:12:34 -08:00
CODE_OF_CONDUCT.md Add organization docs 2017-01-22 16:21:20 -08:00
CODEOWNERS Set ehendrix23 as owner for harmony platform (#20203) 2019-01-17 19:35:45 -07:00
CONTRIBUTING.md Update developer doc links to developers.home-assistant.io (#16622) 2018-09-15 13:27:37 +02:00
Dockerfile Removed mkdir, If the WORKDIR doesn’t exist, it will be created. (#19892) 2019-01-10 07:18:59 +01:00
LICENSE.md Update license to official GitHub template (#16470) 2018-09-07 10:11:51 +02:00
MANIFEST.in Consolidate frontend (#9915) 2017-10-24 19:36:27 -07:00
mypy.ini Disable assuming Optional type for values with None default (#16029) 2018-08-17 20:22:49 +02:00
pylintrc Add unnecessary-pass for pylint-update (#18985) 2018-12-04 10:45:16 +01:00
README.rst Remove reviewed by hound. That's not worth a badge. 2018-12-18 11:06:30 +01:00
requirements_all.txt Tibber Pulse for homes without subscriptions (#20246) 2019-01-19 10:23:22 -08:00
requirements_docs.txt Upgrade Sphinx to 1.8.3 (#19580) 2018-12-27 08:26:37 +01:00
requirements_test.txt Upgrade pytest to 4.1.1 (#20088) 2019-01-14 10:05:24 +02:00
requirements_test_all.txt Improve Sonos discovery (#20196) 2019-01-18 13:43:48 +01:00
setup.cfg Add Python 3.7 classifier (#16645) 2018-09-24 11:11:24 +02:00
setup.py Upgrade aiohttp to 3.5.3 (#19957) 2019-01-16 14:23:46 -08:00
tox.ini Add more type hints to helpers (#18350) 2018-11-11 17:39:50 +01:00

Home Assistant |Build Status| |Coverage Status| |Chat Status|
=================================================================================

Home Assistant is a home automation platform running on Python 3. It is able to track and control all devices at home and offer a platform for automating control.

To get started:

.. code:: bash

    python3 -m pip install homeassistant
    hass --open-ui

Check out `home-assistant.io <https://home-assistant.io>`__ for `a
demo <https://home-assistant.io/demo/>`__, `installation instructions <https://home-assistant.io/getting-started/>`__,
`tutorials <https://home-assistant.io/getting-started/automation-2/>`__ and `documentation <https://home-assistant.io/docs/>`__.

|screenshot-states|

Featured integrations
---------------------

|screenshot-components|

The system is built using a modular approach so support for other devices or actions can be implemented easily. See also the `section on architecture <https://developers.home-assistant.io/docs/en/architecture_index.html>`__ and the `section on creating your own
components <https://developers.home-assistant.io/docs/en/creating_component_index.html>`__.

If you run into issues while using Home Assistant or during development
of a component, check the `Home Assistant help section <https://home-assistant.io/help/>`__ of our website for further help and information.

.. |Build Status| image:: https://travis-ci.org/home-assistant/home-assistant.svg?branch=master
   :target: https://travis-ci.org/home-assistant/home-assistant
.. |Coverage Status| image:: https://img.shields.io/coveralls/home-assistant/home-assistant.svg
   :target: https://coveralls.io/r/home-assistant/home-assistant?branch=master
.. |Chat Status| image:: https://img.shields.io/discord/330944238910963714.svg
   :target: https://discord.gg/c5DvZ4e
.. |screenshot-states| image:: https://raw.github.com/home-assistant/home-assistant/master/docs/screenshots.png
   :target: https://home-assistant.io/demo/
.. |screenshot-components| image:: https://raw.github.com/home-assistant/home-assistant/dev/docs/screenshot-components.png
   :target: https://home-assistant.io/components/