Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P043] Add support for %sunrise% and %sunset% based time-values #4903

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
afc3214
[P043] Add support for %sunrise% and %sunset% based time-values
tonhuisman Dec 7, 2023
0b95025
[TimeCalc] Fix parse errors
tonhuisman Dec 9, 2023
028fc6c
[Text input] Add `datalist` support, manually cherry picked from P123 PR
tonhuisman Dec 9, 2023
f62038a
[Text input] Implement `datalist` support
tonhuisman Dec 9, 2023
70b0679
[P043] Add selection list (datalist) support for input time string
tonhuisman Dec 9, 2023
56d97c6
[P043] Rework Day,Time inputs, add configurable Day,Time count
tonhuisman Dec 10, 2023
8112d06
[P043] Change Value input layout to be on same line as the Day,Time i…
tonhuisman Dec 11, 2023
8539527
[P043] Add option for On/Off value input
tonhuisman Dec 12, 2023
edcae4d
[P043] Add 'config' command support and get config value support
tonhuisman Dec 16, 2023
ce73e4c
[P043] Add documentation
tonhuisman Dec 16, 2023
20962f0
[Build] Disable some failing build envs
tonhuisman Dec 17, 2023
e28cac3
[Docs] Add P043 to commands and events reference pages
tonhuisman Dec 17, 2023
49d420b
[P043] Fix simple Yes/No behavior like GPIO mode
tonhuisman Dec 19, 2023
f091f1f
[P043] Update documentation
tonhuisman Dec 19, 2023
deb7cf3
Merge branch 'mega' of https://github.com/letscontrolit/ESPEasy into …
tonhuisman Dec 28, 2023
8713131
[Build] Remove RTTTL from `normal_IRext_no_rx` build for size, add so…
tonhuisman Dec 28, 2023
ed90c1c
[P043] Exclude some code that won't work for PLUGIN_BUILD_MINIMAL_OTA…
tonhuisman Dec 28, 2023
f79c3c0
Merge branch 'mega' into feature/P043-support-sunrise-and-sunset-in-s…
TD-er Dec 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 70 additions & 10 deletions docs/source/Plugin/P043.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. include:: ../Plugin/_plugin_substitutions_p04x.repl
.. include:: ../Plugin/_plugin_substitutions_p04x.repl
.. _P043_page:

|P043_typename|
Expand All @@ -21,27 +21,87 @@ Maintainer: |P043_maintainer|

Used libraries: |P043_usedlibraries|

Supported hardware
------------------

|P043_usedby|

.. Commands available
.. ^^^^^^^^^^^^^^^^^^
Description
-----------

Every minute the set schedule will be checked for a match, and if a value for a scheduled time is set, the GPIO will be set to that state (On/Off) when configured, or when no GPIO is configured and the value is not 0 or empty, an event is generated with the field number that caused the trigger, and another event with the set value if the Number Output Values is set to Dual or higher.

Configuration
-------------

.. image:: P043_DeviceConfiguration.png

* **Name**: Required by ESPEasy, must be unique among the list of available devices/tasks.

* **Enabled**: The device can be disabled or enabled. When not enabled the device should not use any resources.

Sensor
^^^^^^

* **GPIO -> Clock event** Select a GPIO that will get the stated as configured for the Day,Time. When a GPIO is configured, the allowed valies for a scheduled time will be empty, Off and On only.

Device Settings
^^^^^^^^^^^^^^^

* **Nr. of Day,Time fields**: Select a number between 1 and 16 for the number of Day,Time fields to be available. Will be applied after the page is submitted. (Default: 8)

* **Value input On/Off only**: When checked, the selection for Value will be for On/Off (or empty) only, to avoid misconfiguration for less experienced users, and the Output variable response the same as if a GPIO was selected. The default is unchecked.

.. image:: P043_GPIO_Enabled.png

* **Day,Time X**: Select the Day and Time that should be checked. For Limited builds the day and time have to be entered manually, for other builds, the Day can be selected from a combobox, and the time can be selected from a predefined list and set to a desired time.

For Day, the available options are All, Sun, Mon, Tue, Wed, Thu, Fri, Sat, Wrk (workday), Wkd (weekend).

.. .. include:: P043_commands.repl
.. image:: P043_DayOptions.png

.. Events
.. ~~~~~~
For time, besides the 24h HH:MM notation, there can also be chosen to use ``%sunrise%`` or ``%sunset%``, optionally with an offset in hours, minutes or seconds like ``%sunrise-1h%`` or ``%sunset+30m%``.

.. .. include:: P043_events.repl
.. image:: P043_TimeOptions.png

Output Configuration
^^^^^^^^^^^^^^^^^^^^

* **Number Output Values**: Select Single (default), Dual, Triple or Quad. The Triple and Quad options aren't actually used in this plugin.

Data Acquisition
^^^^^^^^^^^^^^^^

This group of settings, **Single event with all values** and **Send to Controller** settings are standard available configuration items. Send to Controller is only visible when one or more Controllers are configured.

Values
^^^^^^

The default names for the values are named ``Output``, and get a numeric suffix for the Dual, Triple and Quad configuration.

Commands available
^^^^^^^^^^^^^^^^^^

.. include:: P043_commands.repl

Events
~~~~~~

.. include:: P043_events.repl

Get Config Values
^^^^^^^^^^^^^^^^^

Get Config Values retrieves values or settings from the sensor or plugin, and can be used in Rules, Display plugins, Formula's etc. The square brackets **are** part of the variable. Replace ``<taskname>`` by the **Name** of the task.

.. include:: P043_config_values.repl

Change log
----------

.. versionchanged:: 2.0
...

|added| 2023-12-16:
Selectors for Day and Time, ``%sunrise%`` and ``%sunset%`` support, ``config`` command and get config values.

|added|
Major overhaul for 2.0 release.

Expand Down
Binary file added docs/source/Plugin/P043_DayOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P043_DeviceConfiguration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P043_GPIO_Enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/Plugin/P043_TimeOptions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions docs/source/Plugin/P043_commands.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.. csv-table::
:header: "Command Syntax", "Extra information"
:widths: 30, 20

"
| ``config,task,<taskName>,SetTime,<timeIndex>,<timeString>[,<value>]``

Change the configuration of the plugin for the timeIndex provided:

``config,task``: The Config command to change a setting for a task. Not case-sensitive.

``<taskName>``: The name of the task to be changed.

``SetTime``: Literal command-text recognized by the plugin to set the time and optional value. Not case-sensitive.

``<timeIndex>``: The Day,Time fields *number* as shown in the UI. Has to be within the allowed range 1..Nr. of Day,Time field setting.

``<timeString>``: A time string as can be entered in the UI, a day (All,Sun, Mon,Tue,Wed,Thu,Fri,Sat,Wrk (workday),Wkd (weekend)) and a time (HH:MM or %Sunrise%/%Sunset%). When configuring for sunrise of sunset, an offset in hours, minutes or seconds can be provided by using ``%sunrise-1h%`` or ``%sunset+30m%`` etc. To avoid the sunrise or sunset time of today to be inserted, instead of ``%`` a ``$`` must be used! If an invalid ``<timeString>`` is provided, ``All,00:00`` will be stored!

``<value>``: The value to be set. If a GPIO is configured or the setting 'Value input On/Off only' is enabled, a 0 will configure Off and 1 will configure On. When not using a GPIO or the 'Value input On/Off only' setting is unchecked, the value will be stored as provided. When having value 0 set, **no event will be generated** when this time is triggered!
","
This (generic) command allows to update the configuration.

.. warning:: Every time this command is used, the configuration is saved to flash storage. When changing this often, the flash memory may wear out quickly!



Example command to use, when using ``%Sunrise%``/``%Sunset%``:

- ``config,task,Clock,settime,1,Wrk,$sunrise-1h$,1``

Will be stored like ``Wrk,%sunrise-1h%`` in Day,Time field 1, and Value set to 1, or ``On`` when having a GPIO configured or **Value input On/Off only** enabled.
"
23 changes: 23 additions & 0 deletions docs/source/Plugin/P043_config_values.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.. csv-table::
:header: "Config value", "Information"
:widths: 20, 30

"
``[<taskname>#GetTimeX]``
","
Returns the configured Day,Time string for line X (Range: 1..Nr. of Day,Time fields), as shown in the UI.

Examples:

- ``All,06:00``
- ``Wrk,%sunset-1h%``
"
"
``[<taskname>#GetValueX]``
","
Returns the configured value for line X (Range: 1..Nr. of Day,Time fields), with a twist:

If a GPIO is configured, or the setting 'Value input On/Off only' is checked, a 0 is returned for Off and 1 for On (the stored value is actualy 1 higher)

When no GPIO is configured and the setting 'Value input On/Off only' is unchecked, the shown value is returned.
"
14 changes: 14 additions & 0 deletions docs/source/Plugin/P043_events.repl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. csv-table::
:header: "Event", "Example"
:widths: 30, 20

"
``clock#Output`` The value provided with this event is the field (1..Nr. of Day,Time fields) that was triggered.

``clock#Output2`` When the 'Number Output Values' is set to Dual, Triple or Quad, and a GPIO is configured or 'Value input On/Off only' is checked the On (1) or Off (0) value is included as an event argument (``%eventvalue1%``).

If no GPIO is configured and 'Value input On/Off only' is unchecked, the configured value is provided as ``%eventvalue1%``.

Events are only generated if the value is not set to 0 or empty.
","
"
6 changes: 3 additions & 3 deletions docs/source/Reference/Command.rst
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ P038 :ref:`P038_page`
.. .. include:: ../Plugin/P042_commands.repl


.. P043 :ref:`P043_page`
.. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
P043 :ref:`P043_page`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. .. include:: ../Plugin/P043_commands.repl
.. include:: ../Plugin/P043_commands.repl


.. P044 :ref:`P044_page`
Expand Down
6 changes: 3 additions & 3 deletions docs/source/Reference/Events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ P037 :ref:`P037_page`
.. .. include:: ../Plugin/P042_events.repl


.. P043 :ref:`P043_page`
.. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
P043 :ref:`P043_page`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. .. include:: ../Plugin/P043_events.repl
.. include:: ../Plugin/P043_events.repl


.. P044 :ref:`P044_page`
Expand Down
2 changes: 1 addition & 1 deletion platformio_esp82xx_envs.ini
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ build_flags = ${normal_ir_extended_no_rx.build_flags}
${esp8266_4M2M.build_flags}
${limited_build_size.build_flags}
-DLIMIT_BUILD_SIZE
-DKEEP_RTTTL
; -DKEEP_RTTTL
extra_scripts = ${esp8266_4M2M.extra_scripts}
pre:tools/pio/ir_build_check.py

Expand Down
Loading