Estimation of a value
=====================

A model is able to estimate a concentration of a carbon dioxide or humidity in certain time.

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`.

CO2
---

The estimation of a concentration of a carbon dioxide is based on a calculation of a line direction using
several values that have been recently measured.

The example of an estimation of a carbon dioxide concentration in certain time follows.


.. literalinclude:: ../../examples2/0301_estimate/co2_estimate.py
   :language: python

It is necessary to set clients that can communicate with a remote server using the function ``setup_clients``.
Estimation is performed on the basis of data measured during a given time interval. Time that defines
end of a time interval is stored in the variable ``actual_time``. The sensor used to gather data is stored
in the variable ``devs``. Estimation of a carbon dioxide concentration in certain time is performed by
the function ``estimate_co2`` and the result is stored in the variable ``notification``.
All configuration parameters are saved in the configuration file ``config.ini``
that is described in the section :ref:`installation.config_file`.

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

* **current_value** - current value of CO2 [ppm],
* **es_level** - a value of a carbon dioxide concentration that will be probably reached in ``es_time`` [ppm],
* **es_time** - a time when an estimation of a carbon dioxide concentration will be performed [s],
* **estimate_time** - a time when an upper limit of a given level of the concentration will be reached [min],
* **level** - a level of the concentration whose upper limit will be used to compute the ``es_time``,

  * **0** --  0 - 499 - decreased concentration,
  * **1** --  500 - 1499 - optimal concentration,
  * **2** -- 1500 - 2499 - increased concentration,
  * **3** -- 2500 - 3999 - high concentration,
  * **4** -- 4000 - too high concentration,

* **level_value** - a value of ``level`` [ppm],
* **type** - a notification type.

The example of a notification follows.

.. literalinclude:: ../../examples2/0301_estimate/co2_notification.doc.json
   :language: json

The example of a command that can be used to estimate a carbon dioxide concentration in certain time is below.

.. code-block:: bash

   python examples2/0301_estimate/co2_estimate.py


Temperature and humidity
------------------------

The estimation of humidity is based on a calculation of a line direction using
several values that have been recently measured.

The example of an estimation of humidity in certain time follows.

.. literalinclude:: ../../examples2/0301_estimate/t_h_estimate.py
   :language: python

It is necessary to set clients that can communicate with a remote server using the function ``setup_clients``.
Estimation is performed on the basis of data measured during a given time interval. Time that defines
end of a time interval is stored in the variable ``actual_time``. The sensors used to gather data are stored
in the variable ``devs``. Estimation of humidity in certain time is performed by
the function ``estimate_t_h`` and the result is stored in the variable ``notification``.
All configuration parameters are saved in the configuration file ``config.ini``
that is described in the section :ref:`installation.config_file`.

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

* **current_value** - current value of humidity [%],
* **es_level** - a value of humidity that will be probably reached in ``es_time`` [%],
* **es_time** - a time when an estimation of humidity will be performed [s],
* **estimate_time** - a time when an upper limit of a given level of the humidity will be reached [min],
* **level** - a level of the humidity whose upper limit will be used to compute the ``es_time``,

  * **0** --  0% - 29% - too low humidity,
  * **1** -- 30% - 39% - decreased humidity,
  * **2** -- 40% - 59% - optimal humidity,
  * **3** -- 60% - 69% - increased humidity,
  * **4** -- 70% - 100% - too high humidity,

* **level_value** - a value of ``level`` [%],
* **type** - a notification type.


The example of a notification follows.

.. literalinclude:: ../../examples2/0301_estimate/t_h_notification.doc.json
   :language: json

The example of a command that can be used to estimate humidity in certain time is below.

.. code-block:: bash

   python examples2/0301_estimate/t_h_estimate.py
