When to ventilate in summer
============================

The goal is to determine if the ventilation is useful to decrease the temperature in a room in given time in summer.

The configuration parameters in the examples below can be changed
in the configuration file ``config.ini``
that is described in section :ref:`installation.config_file`.

.. literalinclude:: ../../examples2/0303_when_to_ventilate/run.py
   :language: python

It is necessary to set clients that can communicate with a remote server using the function ``setup_clients``.
Current time is stored in the variable ``actual_time``. Latitude and longitude that enable to get weather data
according to a sensor position are stored in the variable ``lat`` and ``lon``. The API key allows to get weather data
and it is obtained by the function ``wunderground_api_key``. The sensor used to gather data is stored
in the variable ``devs``. The determination if the ventilation is useful in current time is performed by
the function ``when_ventilate_summer`` and the result is stored in the variable ``notification``.

An output of the determination is a notification that contains basic information described in the section
:ref:`Notifications <notification.notification>` and the following information:

* **temp_in** - indoor temperature,
* **temp_out** - outside temperature,
* **type** - what quantity is used for prediction,
* **ventilate** - if the ventilation is useful,

 * **0** - ventilation is useless, the outside temperature is higher than the indoor temperature,
 * **1** - ventilation will be probably useless, the outside temperature is similar to indoor temperature,
 * **2** - ventilation is useful, the outside temperature is lower than the indoor temperature.

The example of a notification follows.

.. literalinclude:: ../../examples2/0303_when_to_ventilate/notification.doc.json
   :language: json

The example of a command that can be used to determine if ventilation is useful to decrease the temperature in a room
in the summer months is below.

.. code-block:: bash

   python examples2/0303_when_to_ventilate/run.py
