From 965d9bb4e82feddfc9fdc5236e321dc58b31b760 Mon Sep 17 00:00:00 2001 From: tonhuisman Date: Sun, 2 Aug 2020 22:33:20 +0200 Subject: [PATCH 01/47] [Docs] Updated commands reference --- docs/source/Plugin/P000_commands.repl | 92 ++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/docs/source/Plugin/P000_commands.repl b/docs/source/Plugin/P000_commands.repl index 55c49e498..91be344fb 100644 --- a/docs/source/Plugin/P000_commands.repl +++ b/docs/source/Plugin/P000_commands.repl @@ -30,6 +30,12 @@ Example output: ``Allowed IP range : 192.168.10.0 - 192.168.10.255``" " + Background"," + :red:`Internal`"," + Process background tasks. + + ``Background``" + " Build"," :red:`Internal`"," Get or set build information. This will not be stored, so only valid until reboot. @@ -86,7 +92,7 @@ * ``Datetime,2020-02-29`` - set node time '2020-02-29 00:00:00' * ``Datetime`` - get current node time - Time source will be set to ``Manual_set`` until the time will be updated via another source. (e.g. GPS or NTP) + Time source will be set to ``Manual_set`` until the time will be updated via another source. (e.g. GPS or NTP)" " Debug"," :red:`Internal`"," @@ -201,6 +207,12 @@ ``LogEntry,``" " + LogPortStatus"," + :red:`Internal`"," + Display status information about all ports + + ``LogPortStatus``" + " meminfo"," :red:`Internal`"," Will send summary of struct sizes to the serial port. @@ -303,6 +315,16 @@ ``Settings``" " + Subnet"," + :red:`Internal`"," + Get or set the network subnet setting + + ``Subnet`` + + Example output: ``Subnet:255.255.255.0(DHCP)`` + + ``Subnet,255.255.255.0``" + " Subscribe"," :green:`Rules`"," Subscribes to a specific topic using MQTT broker service @@ -347,6 +369,24 @@ ``TaskValueSet,,,``" " + TaskValueSetAndRun"," + :green:`Rules`"," + Set values on a **Dummy Task** (device) and execute a TaskRun on it + + ``TaskValueSetAndRun,,,``" + " + TimerPause"," + :green:`Rules`"," + Pause a timer + + ``TimerPause,``" + " + TimerResume"," + :green:`Rules`"," + Resume a paused timer + + ``TimerResume,``" + " TimerSet"," :green:`Rules`"," Start a timed event @@ -355,12 +395,56 @@ ``TimerSet,,0`` disables the timer" " + TimeZone"," + :red:`Internal`"," + Get or set the TimeZone + + ``TimeZone`` + + Example output: ``TimeZone:60`` + + ``TimeZone,``" + " + UdpPort"," + :red:`Internal`"," + Set the udp port + + ``UdpPort,``" + " + UdpTest"," + :red:`Internal`"," + Send a test message to an udp port, for number of times + + ``UdpTest,,``" + " Unit"," :red:`Internal`"," Set the unit number ``Unit,``" " + UseNTP"," + :red:`Internal`"," + Get or set the status of NTP (Network Time Protocol) + + ``UseNTP`` + + Example output: ``UseNTP:true`` + + ``UseNTP,<0/1>``" + " + WdConfig"," + :red:`Internal`"," + Configure I2C device (Wire Device) + + ``WdConfig,
,,``" + " + WdRead"," + :red:`Internal`"," + Read from I2C device (Wire Device) + + ``WdRead,
,``" + " WifiAPKey"," :red:`Internal`"," Change AP WPA key @@ -414,6 +498,12 @@ Change SSID to connect as secondry WiFi ``WifiSSID2,``" + " + WifiSTAMode"," + :red:`Internal`"," + Force the unit into STA mode. + + ``WifiSTAMode``" From 0629084b4708d9d679543c160c9bad6ce59ee503 Mon Sep 17 00:00:00 2001 From: tonhuisman Date: Mon, 3 Aug 2020 10:54:57 +0200 Subject: [PATCH 02/47] [Docs] Fixed some typos and Sphinx syntax errors --- docs/source/Controller/C013.rst | 12 ++++++------ docs/source/Plugin/P000_commands.repl | 4 ++-- docs/source/Plugin/P093.rst | 2 +- docs/source/Reference/RTC.rst | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/source/Controller/C013.rst b/docs/source/Controller/C013.rst index f1d807630..4cead80df 100644 --- a/docs/source/Controller/C013.rst +++ b/docs/source/Controller/C013.rst @@ -163,10 +163,10 @@ Of each known node the following data is kept: The key to index this ``NodeStruct`` is the nodes unit number. ASCII Data -~~~~~~~~~~ +^^^^^^^^^^^^^^^^ Command Message -*************** +^^^^^^^^^^^^^^^^ First byte is not 0xFF. @@ -181,7 +181,7 @@ As can be seen, no checks for size, and it is just expected to be a valid ESPeas Also no check to see if the command is supported by the receiving end and no feedback to the sender. Binary Data -~~~~~~~~~~~ +^^^^^^^^^^^^^^^^ Binary data is marked with the first byte 0xFF. @@ -207,7 +207,7 @@ Message types supported, determined by the 2nd byte: * 5: Sensor data Sysinfo Message -*************** +^^^^^^^^^^^^^^^^ There are 2 types of Sysinfo messages, a standard and an extended message. The extended message starts with the same information as the standard one. @@ -234,7 +234,7 @@ The node type is defined as: * 81 = "Nano Easy" Sensor Info message -******************* +^^^^^^^^^^^^^^^^^^^^ Sensor Info messages are just a description of a shared sensor. It contains some information to setup a new sensor on the receiving end. @@ -258,7 +258,7 @@ These messages are just a serialized byte stream of ``struct C013_SensorInfoStru Sensor Data message -******************* +^^^^^^^^^^^^^^^^^^^^ These messages are just a serialized byte stream of ``struct C013_SensorDataStruct`` . diff --git a/docs/source/Plugin/P000_commands.repl b/docs/source/Plugin/P000_commands.repl index 91be344fb..48ddff51d 100644 --- a/docs/source/Plugin/P000_commands.repl +++ b/docs/source/Plugin/P000_commands.repl @@ -435,13 +435,13 @@ " WdConfig"," :red:`Internal`"," - Configure I2C device (Wire Device) + Configure external Watchdog device ``WdConfig,
,,``" " WdRead"," :red:`Internal`"," - Read from I2C device (Wire Device) + Read from external Watchdog device ``WdRead,
,``" " diff --git a/docs/source/Plugin/P093.rst b/docs/source/Plugin/P093.rst index dc3710482..f64b78d09 100644 --- a/docs/source/Plugin/P093.rst +++ b/docs/source/Plugin/P093.rst @@ -89,7 +89,7 @@ Commands .. Events .. ~~~~~~ -.. include:: P093_events.repl +.. This file is missing. (remove up to 'include' when fixed) include:: P093_events.repl Example ------- diff --git a/docs/source/Reference/RTC.rst b/docs/source/Reference/RTC.rst index 1c7629165..9b7dca611 100644 --- a/docs/source/Reference/RTC.rst +++ b/docs/source/Reference/RTC.rst @@ -4,7 +4,7 @@ RTC Reference The ESP microprocessors we use, have some special memory which will retain its information as long as the node remains powered. Espressif calls this _RTC_ RAM and thus we're using the same term for it. -The name may be a bit strange, as RTC usually refers to _Real Time Clock_. +The name may be a bit strange, as RTC usually refers to *Real Time Clock*. Currently we only support RTC functions on the ESP8266 and ESP8285. ESP32 does also have RTC memory, but that's organised a bit different. From e86736a423866ff69f348acac3a199c7339d1c8c Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Tue, 4 Aug 2020 13:16:55 +0200 Subject: [PATCH 03/47] [docs] Fix table for P095 --- docs/source/Plugin/P095_commands.repl | 118 +++++++++++++------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/docs/source/Plugin/P095_commands.repl b/docs/source/Plugin/P095_commands.repl index e0aac87e0..0333daf36 100644 --- a/docs/source/Plugin/P095_commands.repl +++ b/docs/source/Plugin/P095_commands.repl @@ -1,69 +1,69 @@ .. csv-table:: - :header: "Command", "Extra information" - :widths: 20, 30 + :header: "Command", "Extra information" + :widths: 20, 30 - " - ``TFTCMD,`` - "," - Control the screen (on, off, clear,..) + " + ``TFTCMD,`` + "," + Control the screen (on, off, clear,..) - Examples: + Examples: - - ``tftcmd,on`` Switch display on. - - ``tftcmd,off`` Switch display off. - - ``tftcmd,clear`` Clear whole display. - - ``tftcmd,clear,green`` Clear whole display with green color. - - ``tftcmd,inv,1`` Invert the dispaly (value:0 normal display, 1 inverted display) - - ``tftcmd,rot,2`` Rotate display (value from 0 to 3 inclusive) - " - " - ``TFT,,....`` - "," - Draw line, rect, circle, triangle and text - - Subcommands: - - - ``tft,txt,`` Write simple text (use last position, color and size) - - ``tft,txp,,`` Set text position (move the cursor) - - ``tft,txc,,`` Set text color (background is transparent if not provided - - ``tft,txs,`` Set text size - - ``tft,txtfull,,,,,,`` Write text with all options - - ``tft,l,,,<2>,,`` Draw a simple line - - ``tft,lh,,,`` Draw an horizontal line (width = Line width in pixels (positive = right of first point, negative = point of first corner). - - ``tft,lv,,,`` Draw a vertical line (height= Line height in pixels (positive = below first point, negative = above first point). - - ``tft,r,,,,,`` Draw a rectangle - - ``tft,rf,,,,,,`` Draw a filled rectangle - - ``tft,c,,,,`` Draw a circle - - ``tft,cf,,,,,`` Draw a filled circle - - ``tft,t,,,,,,,| Draw a triangle - - ``tft,tf,,,,,,,,`` Draw a filled triangle - - ``tft,rr,,,,,,`` Draw a round rectangle - - ``tft,rrf,,,,,,,`` Draw a filled round rectangle - - ``tft,px,,,`` Print a single pixel - - ``tft,font, `` Switch to font - SEVENSEG24, SEVENSEG18, FREESANS, DEFAULT + - ``tftcmd,on`` Switch display on. + - ``tftcmd,off`` Switch display off. + - ``tftcmd,clear`` Clear whole display. + - ``tftcmd,clear,green`` Clear whole display with green color. + - ``tftcmd,inv,1`` Invert the dispaly (value:0 normal display, 1 inverted display) + - ``tftcmd,rot,2`` Rotate display (value from 0 to 3 inclusive) + " + " + ``TFT,,....`` + "," + Draw line, rect, circle, triangle and text + + Subcommands: + + - ``tft,txt,`` Write simple text (use last position, color and size) + - ``tft,txp,,`` Set text position (move the cursor) + - ``tft,txc,,`` Set text color (background is transparent if not provided + - ``tft,txs,`` Set text size + - ``tft,txtfull,,,,,,`` Write text with all options + - ``tft,l,,,<2>,,`` Draw a simple line + - ``tft,lh,,,`` Draw an horizontal line (width = Line width in pixels (positive = right of first point, negative = point of first corner). + - ``tft,lv,,,`` Draw a vertical line (height= Line height in pixels (positive = below first point, negative = above first point). + - ``tft,r,,,,,`` Draw a rectangle + - ``tft,rf,,,,,,`` Draw a filled rectangle + - ``tft,c,,,,`` Draw a circle + - ``tft,cf,,,,,`` Draw a filled circle + - ``tft,t,,,,,,,`` Draw a triangle + - ``tft,tf,,,,,,,,`` Draw a filled triangle + - ``tft,rr,,,,,,`` Draw a round rectangle + - ``tft,rrf,,,,,,,`` Draw a filled round rectangle + - ``tft,px,,,`` Print a single pixel + - ``tft,font,`` Switch to font - SEVENSEG24, SEVENSEG18, FREESANS, DEFAULT + " - Examples: +Examples: - Write Text : - ``tft,txtfull,0,0,HelloWorld`` - - Write Text another place: - ``tft,txtfull,100,40,HelloWorld`` +Write Text : + ``tft,txtfull,0,0,HelloWorld`` - Write bigger Text : - ``tft,txtfull,0,0,3,HelloWorld`` +Write Text another place: + ``tft,txtfull,100,40,HelloWorld`` - Write RED Text : - ``tft,txtfull,0,0,3,HelloWorld`` +Write bigger Text : + ``tft,txtfull,0,0,3,HelloWorld`` - Write RED Text (size is 1): - ``tft,txtfull,0,0,1,RED,HelloWorld`` +Write RED Text : + ``tft,txtfull,0,0,3,HelloWorld`` - Write RED Text on YELLOW background (size is 1): - ``tft,txtfull,0,0,1,RED,YELLOW,HelloWorld`` - - Select font : - ``tft,font,SEVENSEG24`` - ``tft,txtfull,0,0,1,RED,17.0 `` - " - \ No newline at end of file +Write RED Text (size is 1): + ``tft,txtfull,0,0,1,RED,HelloWorld`` + +Write RED Text on YELLOW background (size is 1): + ``tft,txtfull,0,0,1,RED,YELLOW,HelloWorld`` + +Select font : + +- ``tft,font,SEVENSEG24`` +- ``tft,txtfull,0,0,1,RED,17.0`` From bede949bef4b6949d87cee4d62389357ee8f14c0 Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Tue, 4 Aug 2020 13:18:36 +0200 Subject: [PATCH 04/47] [docs] Replace code-block:: html with code-block:: none The HTML parser does not parse our own rules which is where it is used. So until we have a rules highlighter, we use the ``none`` highlighter. --- docs/source/Controller/C014.rst | 2 +- docs/source/Plugin/P000_Buzzer_RTTTL.rst | 10 +- docs/source/Plugin/P000_Level_converter.rst | 4 +- .../Plugin/P000_Piezo_element_RTTTL.rst | 10 +- docs/source/Plugin/P000_Relay.rst | 4 +- docs/source/Plugin/P000_Servo_motor.rst | 4 +- docs/source/Plugin/P000_Speaker_RTTTL.rst | 10 +- docs/source/Plugin/P000_commands.repl | 10 +- docs/source/Plugin/P000_events.repl | 38 +-- docs/source/Plugin/P001_Door_switch.rst | 6 +- docs/source/Plugin/P001_PIR_sensor.rst | 6 +- docs/source/Plugin/P001_Switch.rst | 6 +- docs/source/Plugin/P002_ESP82XX_internal.rst | 4 +- docs/source/Plugin/P002_PCF8591.rst | 6 +- .../Plugin/P002_Photosensitive_resistor.rst | 6 +- docs/source/Plugin/P003_LJ12A3.rst | 4 +- docs/source/Plugin/P003_TCR5000.rst | 6 +- docs/source/Plugin/P003_YFS401.rst | 6 +- docs/source/Plugin/P004_DS18b20.rst | 6 +- docs/source/Plugin/P005_DHT11_DHT22.rst | 6 +- docs/source/Plugin/P006_BMP085.rst | 6 +- docs/source/Plugin/P006_BMP180.rst | 6 +- docs/source/Plugin/P008_Wiegand-26.rst | 6 +- docs/source/Plugin/P009_MCP23017.rst | 6 +- docs/source/Plugin/P010_BH1750.rst | 6 +- docs/source/Plugin/P012_LCD.rst | 6 +- docs/source/Plugin/P013_HC-SR04.rst | 30 +- docs/source/Plugin/P013_RCW-0001.rst | 6 +- docs/source/Plugin/P013_US-100.rst | 6 +- docs/source/Plugin/P014_SI7021_HTU21D.rst | 6 +- docs/source/Plugin/P015_TSL2561.rst | 6 +- docs/source/Plugin/P017_PN532.rst | 6 +- docs/source/Plugin/P018_GP2Y10.rst | 6 +- docs/source/Plugin/P019_PCF8574.rst | 6 +- docs/source/Plugin/P022_PCA9685.rst | 6 +- docs/source/Plugin/P023_OLED.rst | 6 +- docs/source/Plugin/P024_MLX90614.rst | 6 +- docs/source/Plugin/P025_ADS1115.rst | 6 +- docs/source/Plugin/P027_INA219.rst | 6 +- docs/source/Plugin/P028_BME280.rst | 6 +- docs/source/Plugin/P030_BMP280.rst | 6 +- docs/source/Plugin/P031_SHT1X.rst | 6 +- docs/source/Plugin/P032_MS5611.rst | 6 +- docs/source/Plugin/P034_DHT12.rst | 6 +- docs/source/Plugin/P035_IR_transmitter.rst | 6 +- docs/source/Plugin/P045_MPU6050.rst | 6 +- docs/source/Plugin/P046_Ventus_W266.rst | 8 +- .../Plugin/P047_Soil_moisture_sensor.rst | 6 +- .../Plugin/P048_Adafruit_Motor_Shield_v2.rst | 6 +- docs/source/Plugin/P049_MH-Z19.rst | 6 +- docs/source/Plugin/P050_TCS34725.rst | 6 +- docs/source/Plugin/P051_AM2320.rst | 6 +- docs/source/Plugin/P052_S11.rst | 4 +- docs/source/Plugin/P052_S8.rst | 6 +- docs/source/Plugin/P052_tSense_K70.rst | 6 +- docs/source/Plugin/P053_PMSx003.rst | 6 +- docs/source/Plugin/P059_Rotary_Encoder.rst | 6 +- docs/source/Plugin/P063_TTP229-B.rst | 6 +- docs/source/Plugin/P065_DFPlayer_Mini.rst | 6 +- docs/source/Plugin/P065_YX5300.rst | 6 +- docs/source/Plugin/P073_7_Segment.rst | 6 +- docs/source/Plugin/P075_Nextion.rst | 6 +- docs/source/Plugin/P081.rst | 4 +- docs/source/Plugin/P081_events.repl | 2 +- docs/source/Plugin/P082_Neo-6M.rst | 4 +- docs/source/Plugin/P082_Neo-7M.rst | 4 +- docs/source/Plugin/P082_Neo-M8n.rst | 4 +- docs/source/Plugin/P082_events.repl | 6 +- docs/source/Plugin/P086_Homie.rst | 2 +- docs/source/Plugin/P097_events.repl | 6 +- docs/source/Plugin/_plugin_hardware.template | 4 +- docs/source/Rules/Rules.rst | 296 +++++++++--------- 72 files changed, 381 insertions(+), 381 deletions(-) diff --git a/docs/source/Controller/C014.rst b/docs/source/Controller/C014.rst index 9662e9c37..3fbb1ea15 100644 --- a/docs/source/Controller/C014.rst +++ b/docs/source/Controller/C014.rst @@ -79,7 +79,7 @@ Setup - ``homie/%sysname%/$nodes`` enumerating all devices will be sent as final message of the auto-discover header. - The final event log should look like this: -.. code-block:: html +.. code-block:: none 5584 : EVENT: MQTT#Connected 5754 : C014 : autodiscover information of 4 Devices and 6 Nodes sent with no errors! (26 messages) diff --git a/docs/source/Plugin/P000_Buzzer_RTTTL.rst b/docs/source/Plugin/P000_Buzzer_RTTTL.rst index a3ac8a226..11c0d77da 100644 --- a/docs/source/Plugin/P000_Buzzer_RTTTL.rst +++ b/docs/source/Plugin/P000_Buzzer_RTTTL.rst @@ -22,7 +22,7 @@ RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more " After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set: -.. code-block:: html +.. code-block:: none @@ -35,7 +35,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP Buzzer GPIO <--> I/O @@ -55,7 +55,7 @@ Rules examples From ESP Easy v2.0.0 its possible to play melodies via `RTTTL `_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases): -.. code-block:: html +.. code-block:: none http:///control?cmd=rtttl,14:d=4,o=5,b=112:8a,8a,a,8a,8a,a,8a,8c6,8f.,16g,2a,8a-,8a-,8a-.,16a-,8a-,8a,8a.,16a,8a,8g,8g,8a,g,c6 @@ -65,7 +65,7 @@ You can also use these from rules. We use it to let our alarm system give feedba To make a boot-sound on startup, create a rule like this: -.. code-block:: html +.. code-block:: none On System#Boot do rtttl,14:d=10,o=6,b=180,c,e,g @@ -75,7 +75,7 @@ To make a boot-sound on startup, create a rule like this: Besides RTTTL it's also possible to play a single tone on a pin, via a buzzer, speaker or piezo element: -.. code-block:: html +.. code-block:: none http:///control?cmd=tone,14,1300,200 diff --git a/docs/source/Plugin/P000_Level_converter.rst b/docs/source/Plugin/P000_Level_converter.rst index 9695e8086..77e64641d 100644 --- a/docs/source/Plugin/P000_Level_converter.rst +++ b/docs/source/Plugin/P000_Level_converter.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P000_Level_converter_page: Level converter @@ -43,7 +43,7 @@ Wiring A direct connection by mistake from 5V to a GPIO may fry your ESP! Handle level-shifters with some care. The used FET transistors are somewhat sensible against electrostatic discharge. Use a anti-static mat. -.. code-block:: html +.. code-block:: none ESP Level converter Connected hardware GPIO (X) <--> 3A, LV1, A1 etc. <--> 5A, HV1, B2 etc. diff --git a/docs/source/Plugin/P000_Piezo_element_RTTTL.rst b/docs/source/Plugin/P000_Piezo_element_RTTTL.rst index 1c3daaa17..cd28215a0 100644 --- a/docs/source/Plugin/P000_Piezo_element_RTTTL.rst +++ b/docs/source/Plugin/P000_Piezo_element_RTTTL.rst @@ -22,7 +22,7 @@ RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more " After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set: -.. code-block:: html +.. code-block:: none @@ -35,7 +35,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP Piezo GPIO <--> Positive (red) @@ -52,7 +52,7 @@ Rules examples From ESP Easy v2.0.0 its possible to play melodies via `RTTTL `_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases): -.. code-block:: html +.. code-block:: none http:///control?cmd=rtttl,14:d=4,o=5,b=112:8a,8a,a,8a,8a,a,8a,8c6,8f.,16g,2a,8a-,8a-,8a-.,16a-,8a-,8a,8a.,16a,8a,8g,8g,8a,g,c6 @@ -62,7 +62,7 @@ You can also use these from rules. We use it to let our alarm system give feedba To make a boot-sound on startup, create a rule like this: -.. code-block:: html +.. code-block:: none On System#Boot do rtttl,14:d=10,o=6,b=180,c,e,g @@ -72,7 +72,7 @@ To make a boot-sound on startup, create a rule like this: Besides RTTTL it's also possible to play a single tone on a pin, via a buzzer, speaker or piezo element: -.. code-block:: html +.. code-block:: none http:///control?cmd=tone,14,1300,200 diff --git a/docs/source/Plugin/P000_Relay.rst b/docs/source/Plugin/P000_Relay.rst index 25829d3a0..5208426db 100644 --- a/docs/source/Plugin/P000_Relay.rst +++ b/docs/source/Plugin/P000_Relay.rst @@ -179,7 +179,7 @@ have to be figured into your project. It is also possible to use a small SSR to Wiring ------ -.. code-block:: html +.. code-block:: none ESP Relay (board) GPIO (X) <--> IN1 @@ -204,7 +204,7 @@ find more information on how to do this. Rules examples -------------- -.. code-block:: html +.. code-block:: none On Switch#State Do if [Switch#State]=1 diff --git a/docs/source/Plugin/P000_Servo_motor.rst b/docs/source/Plugin/P000_Servo_motor.rst index 5a7cfb410..8f813e3d1 100644 --- a/docs/source/Plugin/P000_Servo_motor.rst +++ b/docs/source/Plugin/P000_Servo_motor.rst @@ -29,7 +29,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP Servo GPIO (X) <--> S (signal) @@ -48,7 +48,7 @@ find more information on how to do this. Rules examples -------------- -.. code-block:: html +.. code-block:: none On Switch#State Do if [Switch#State]=1 diff --git a/docs/source/Plugin/P000_Speaker_RTTTL.rst b/docs/source/Plugin/P000_Speaker_RTTTL.rst index d4fbad20d..67c860fda 100644 --- a/docs/source/Plugin/P000_Speaker_RTTTL.rst +++ b/docs/source/Plugin/P000_Speaker_RTTTL.rst @@ -22,7 +22,7 @@ RTTTL (Ring Tone [Text] Transfer Language) was developed by Nokia to play more " After that the actual tune is then created using standard notes (a, b, c, d, e, f, and g), before the note the duration is set, after the note the octave is set: -.. code-block:: html +.. code-block:: none @@ -35,7 +35,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP Speaker GPIO <--> Positive (red) @@ -52,7 +52,7 @@ Rules examples From ESP Easy v2.0.0 its possible to play melodies via `RTTTL `_ (don't forget to remove the spaces and replace # with -, this might be fixed in future releases): -.. code-block:: html +.. code-block:: none http:///control?cmd=rtttl,14:d=4,o=5,b=112:8a,8a,a,8a,8a,a,8a,8c6,8f.,16g,2a,8a-,8a-,8a-.,16a-,8a-,8a,8a.,16a,8a,8g,8g,8a,g,c6 @@ -62,7 +62,7 @@ You can also use these from rules. We use it to let our alarm system give feedba To make a boot-sound on startup, create a rule like this: -.. code-block:: html +.. code-block:: none On System#Boot do rtttl,14:d=10,o=6,b=180,c,e,g @@ -72,7 +72,7 @@ To make a boot-sound on startup, create a rule like this: Besides RTTTL it's also possible to play a single tone on a pin, via a buzzer, speaker or piezo element: -.. code-block:: html +.. code-block:: none http:///control?cmd=tone,14,1300,200 diff --git a/docs/source/Plugin/P000_commands.repl b/docs/source/Plugin/P000_commands.repl index 48ddff51d..3ed59d198 100644 --- a/docs/source/Plugin/P000_commands.repl +++ b/docs/source/Plugin/P000_commands.repl @@ -170,7 +170,7 @@ Example output: - .. code-block:: html + .. code-block:: none 4500043 : Info : Command: i2cscanner I2C : Found 0x3c @@ -221,7 +221,7 @@ Example output: - .. code-block:: html + .. code-block:: none 4306250 : Info : Command: meminfo SecurityStruct | 593 @@ -531,7 +531,7 @@ Try to use AsyncEvents where possible, to keep rules processing times low. **Rules example** - .. code-block:: html + .. code-block:: none on SingleEvent do Publish,%sysname%/Info,A single event has been triggered! @@ -544,7 +544,7 @@ Try to use AsyncEvents where possible, to keep rules processing times low. **Rules example** - .. code-block:: html + .. code-block:: none on SingleValue do Publish,%sysname%/Info,An event has been sent (%eventvalue%)! @@ -558,7 +558,7 @@ Try to use AsyncEvents where possible, to keep rules processing times low. **Rules example** - .. code-block:: html + .. code-block:: none on Multi do if %eventvalue4%=99 diff --git a/docs/source/Plugin/P000_events.repl b/docs/source/Plugin/P000_events.repl index 8b8c5d45b..6a661d132 100644 --- a/docs/source/Plugin/P000_events.repl +++ b/docs/source/Plugin/P000_events.repl @@ -7,7 +7,7 @@ As described already, each task can produced one or more events, one for each measured value. You should not name your devices and value names so that the combination equals to any of the below listed system events! "," - .. code-block:: html + .. code-block:: none on DHT11Outside#Temperature>20 do GPIO,2,1 @@ -19,7 +19,7 @@ Triggered after power on. "," - .. code-block:: html + .. code-block:: none on System#Wake do GPIO,15,1 @@ -31,7 +31,7 @@ Triggered at boot time. "," - .. code-block:: html + .. code-block:: none on System#Boot do GPIO,2,1 @@ -44,7 +44,7 @@ Triggered just before the ESP goes to deep sleep. "," - .. code-block:: html + .. code-block:: none on System#Sleep do GPIO,2,0 @@ -56,7 +56,7 @@ Triggered when the ESP has connected to broker. "," - .. code-block:: html + .. code-block:: none on MQTT#Connected do Publish,%sysname%/status,First message! @@ -68,7 +68,7 @@ Triggered when the ESP has disconnected from the broker. "," - .. code-block:: html + .. code-block:: none on MQTT#Disconnected do Reboot @@ -80,7 +80,7 @@ Triggered when the ESP has connected to broker (the MQTT Import plugin uses a separate connection than the generic one). "," - .. code-block:: html + .. code-block:: none on MQTTimport#Connected do Publish,%sysname%/status,MQTT Import is now operational @@ -92,7 +92,7 @@ Triggered when the ESP has disconnected from the broker (the MQTT Import plugin uses a separate connection than the generic one). "," - .. code-block:: html + .. code-block:: none on MQTTimport#Disconnected do Reboot @@ -104,7 +104,7 @@ Triggered when the ESP has connected to Wi-Fi. "," - .. code-block:: html + .. code-block:: none on WiFi#Connected do SendToHTTP,url.com,80,/report.php?hash=123abc456&t=[temp2#out] @@ -116,7 +116,7 @@ Triggered when the ESP has changed to access point, will also trigger first time the unit connects to the Wi-Fi. "," - .. code-block:: html + .. code-block:: none on WiFi#ChangedAccesspoint do Publish,%sysname%/status,AP changed @@ -129,7 +129,7 @@ This has been added in build mega-20190910 "," - .. code-block:: html + .. code-block:: none on WiFi#ChangedWiFichannel do Publish,%sysname%/status,channel changed @@ -143,7 +143,7 @@ N.B. Sending a publish command may not be very useful on this event, since this will mainly happen when there is no WiFi connection. "," - .. code-block:: html + .. code-block:: none on WiFi#APmodeEnabled do ... // Some command @@ -156,7 +156,7 @@ This can happen some time (default 60 seconds) after a WiFi connection has been made. Or disabled using some command. "," - .. code-block:: html + .. code-block:: none on WiFi#APmodeDisabled do Publish,%sysname%/status,AP disabled @@ -168,7 +168,7 @@ Triggered when (someone) has tried to login to a ESP unit with admin password enabled, but have failed to enter correct password. "," - .. code-block:: html + .. code-block:: none on Login#Failed do Publish,%sysname%/warning,Intruder alert! @@ -180,7 +180,7 @@ Triggered the first time (after boot) NTP is updating the unit. "," - .. code-block:: html + .. code-block:: none on Time#Initialized do Publish,%sysname%/Time,%systime% @@ -192,7 +192,7 @@ Triggered when the time is set by an update from NTP. "," - .. code-block:: html + .. code-block:: none on Time#Set do Publish,%sysname%/Time,%systime% @@ -205,7 +205,7 @@ As described already, triggered when a rules timer ends (setting a timer to 0 will disable the timer). "," - .. code-block:: html + .. code-block:: none on Rules#Timer=1 do GPIO,2,1 @@ -217,7 +217,7 @@ Triggered every minute with day and time like: Mon,12:30 or Tue,14:45. You can define triggers on specific days or all days using 'All' for days indicator. You can also use wildcards in the time setting like All,**:00 to run every hour. "," - .. code-block:: html + .. code-block:: none on Clock#Time=All,12:00 do //will run once a day at noon GPIO,2,1 @@ -237,7 +237,7 @@ If the command 'Monitor' is used to monitor a given pin you will receive an event for that GPIO as soon as it's state changes. As seen in the example you can always use the square brackets together with the task/value name of ``Plugin#GPIO#Pinstate#N`` to get the state, but to trigger events you need to add the monitor command (preferably at boot). "," - .. code-block:: html + .. code-block:: none on System#Boot do Monitor GPIO,15 diff --git a/docs/source/Plugin/P001_Door_switch.rst b/docs/source/Plugin/P001_Door_switch.rst index d4684df18..731803b69 100644 --- a/docs/source/Plugin/P001_Door_switch.rst +++ b/docs/source/Plugin/P001_Door_switch.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P001_Door_switch_page: Door switch @@ -25,7 +25,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP Door switch GPIO (X) <--> Signal @@ -111,7 +111,7 @@ Indicators/values (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on Door#State=1 do timerSet,1,1 diff --git a/docs/source/Plugin/P001_PIR_sensor.rst b/docs/source/Plugin/P001_PIR_sensor.rst index 3d2356f74..f1039485b 100644 --- a/docs/source/Plugin/P001_PIR_sensor.rst +++ b/docs/source/Plugin/P001_PIR_sensor.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P001_PIR_sensor_page: PIR sensor @@ -31,7 +31,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP PIR GPIO (X) <--> I/O or OUT @@ -117,7 +117,7 @@ Indicators/values (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on Motion#Detection=1 do timerSet,1,1 diff --git a/docs/source/Plugin/P001_Switch.rst b/docs/source/Plugin/P001_Switch.rst index f21726b6a..25d251447 100644 --- a/docs/source/Plugin/P001_Switch.rst +++ b/docs/source/Plugin/P001_Switch.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P001_Switch_page: Switch @@ -24,7 +24,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP Switch/button GPIO (X) <--> Signal @@ -128,7 +128,7 @@ Indicators/values (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on Switch#State do if [Switch#State]=3 diff --git a/docs/source/Plugin/P002_ESP82XX_internal.rst b/docs/source/Plugin/P002_ESP82XX_internal.rst index 170b8b783..f4aec11e0 100644 --- a/docs/source/Plugin/P002_ESP82XX_internal.rst +++ b/docs/source/Plugin/P002_ESP82XX_internal.rst @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P002_PCF8591.rst b/docs/source/Plugin/P002_PCF8591.rst index 0c4087234..ba455d43e 100644 --- a/docs/source/Plugin/P002_PCF8591.rst +++ b/docs/source/Plugin/P002_PCF8591.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P002_PCF8591_page: PCF8591 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P002_Photosensitive_resistor.rst b/docs/source/Plugin/P002_Photosensitive_resistor.rst index f177bd5a0..672c4a68f 100644 --- a/docs/source/Plugin/P002_Photosensitive_resistor.rst +++ b/docs/source/Plugin/P002_Photosensitive_resistor.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P002_Photosensitive_resistor_page: Photosensitive resistor @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P003_LJ12A3.rst b/docs/source/Plugin/P003_LJ12A3.rst index 4046fcc63..cb6b5ebd5 100644 --- a/docs/source/Plugin/P003_LJ12A3.rst +++ b/docs/source/Plugin/P003_LJ12A3.rst @@ -28,7 +28,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP LJ12A3 GPIO (14) <--> Signal (black) @@ -125,7 +125,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none On WaterMeter#mL Do If [WaterMeter#mL]=0 diff --git a/docs/source/Plugin/P003_TCR5000.rst b/docs/source/Plugin/P003_TCR5000.rst index e9f9c6487..f24d63512 100644 --- a/docs/source/Plugin/P003_TCR5000.rst +++ b/docs/source/Plugin/P003_TCR5000.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P003_TCR5000_page: TCR5000 @@ -25,7 +25,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP TCR5000 GPIO (14) <--> S @@ -97,7 +97,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none On PowerMeter#W Do If [PowerMeter#W]>1500 diff --git a/docs/source/Plugin/P003_YFS401.rst b/docs/source/Plugin/P003_YFS401.rst index eef9fde94..7b744242b 100644 --- a/docs/source/Plugin/P003_YFS401.rst +++ b/docs/source/Plugin/P003_YFS401.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P003_YFS401_page: YFS401 @@ -27,7 +27,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP YFS401 GPIO (14) <--> Signal (yellow) @@ -104,7 +104,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none On WaterMeter#mL Do If [WaterMeter#mL]=0 diff --git a/docs/source/Plugin/P004_DS18b20.rst b/docs/source/Plugin/P004_DS18b20.rst index 1ff49ee3c..7c24362b1 100644 --- a/docs/source/Plugin/P004_DS18b20.rst +++ b/docs/source/Plugin/P004_DS18b20.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P004_DS18b20_page: DS18b20 @@ -32,7 +32,7 @@ Wiring .. image:: P004_DS18b20_5.jpg -.. code-block:: html +.. code-block:: none ESP DS18b20 GPIO (14) <--> 1-wire/D (yellow) @@ -106,7 +106,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none On Temp1#Celsius Do If [Temp1#Celsius]>37 diff --git a/docs/source/Plugin/P005_DHT11_DHT22.rst b/docs/source/Plugin/P005_DHT11_DHT22.rst index f4e7dbb40..395ad28f2 100644 --- a/docs/source/Plugin/P005_DHT11_DHT22.rst +++ b/docs/source/Plugin/P005_DHT11_DHT22.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P005_DHT11_DHT22_page: DHT11/DHT22 @@ -35,7 +35,7 @@ DHT11 (blue) DHT22 (white) -.. code-block:: html +.. code-block:: none ESP DHT11/DHT22 GPIO (X) <--> Data (2nd pin) @@ -89,7 +89,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none On DHT#Celsius Do If [DHT#Celsius]>-15 diff --git a/docs/source/Plugin/P006_BMP085.rst b/docs/source/Plugin/P006_BMP085.rst index 758212b7a..7a153feba 100644 --- a/docs/source/Plugin/P006_BMP085.rst +++ b/docs/source/Plugin/P006_BMP085.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P006_BMP085_page: BMP085 @@ -20,7 +20,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP BMP085 GPIO (4) <--> DA (SDA) @@ -73,7 +73,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on BMP#hPa do if BMP#hPa>999 diff --git a/docs/source/Plugin/P006_BMP180.rst b/docs/source/Plugin/P006_BMP180.rst index 74d047f66..158696ae3 100644 --- a/docs/source/Plugin/P006_BMP180.rst +++ b/docs/source/Plugin/P006_BMP180.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P006_BMP180_page: BMP180 @@ -20,7 +20,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP BMP180 GPIO (4) <--> DA (SDA) @@ -73,7 +73,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on BMP#hPa do if BMP#hPa>999 diff --git a/docs/source/Plugin/P008_Wiegand-26.rst b/docs/source/Plugin/P008_Wiegand-26.rst index 4c1f19550..609732373 100644 --- a/docs/source/Plugin/P008_Wiegand-26.rst +++ b/docs/source/Plugin/P008_Wiegand-26.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P008_Wiegand-26_page: Wiegand-26 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P009_MCP23017.rst b/docs/source/Plugin/P009_MCP23017.rst index 1644e84fc..89aab2628 100644 --- a/docs/source/Plugin/P009_MCP23017.rst +++ b/docs/source/Plugin/P009_MCP23017.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p00x.repl +.. include:: ../Plugin/_plugin_substitutions_p00x.repl .. _P009_MCP23017_page: MCP23017 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P010_BH1750.rst b/docs/source/Plugin/P010_BH1750.rst index 78920a91f..b1a0adbe3 100644 --- a/docs/source/Plugin/P010_BH1750.rst +++ b/docs/source/Plugin/P010_BH1750.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P010_BH1750_page: BH1750 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P012_LCD.rst b/docs/source/Plugin/P012_LCD.rst index f244eb79d..05884dcec 100644 --- a/docs/source/Plugin/P012_LCD.rst +++ b/docs/source/Plugin/P012_LCD.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P012_LCD_page: LCD @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P013_HC-SR04.rst b/docs/source/Plugin/P013_HC-SR04.rst index a1c467568..d00a57f99 100644 --- a/docs/source/Plugin/P013_HC-SR04.rst +++ b/docs/source/Plugin/P013_HC-SR04.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P013_HC-SR04_page: HC-SR04 @@ -26,15 +26,15 @@ Wiring The HC-SR04 must be run on 5V. Running it with 3.3V will show very weak results or nothing at all. -.. code-block:: html +.. code-block:: none - ESP HC-SR04 - GPIO (X) <--> Trigger - GPIO (X) <--> Echo (voltage divider!) - - Power - 5.0V <--> VCC - GND <--> GND + ESP HC-SR04 + GPIO (X) <--> Trigger + GPIO (X) <--> Echo (voltage divider!) + + Power + 5.0V <--> VCC + GND <--> GND .. warning:: Do not connect 5V directly to the ESP! Read more about :ref:`P000_Level_converter_page`. @@ -89,14 +89,14 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: on HCSR04#distance do - if [HCSR04#distance]<50 and [HCSR04#distance]>45 - GPIO,14,1 //light up LED to show that you're at the correct position - else - GPIO,14,0 - endif + if [HCSR04#distance]<50 and [HCSR04#distance]>45 + GPIO,14,1 //light up LED to show that you're at the correct position + else + GPIO,14,0 + endif endon .. Commands available diff --git a/docs/source/Plugin/P013_RCW-0001.rst b/docs/source/Plugin/P013_RCW-0001.rst index 53eabcbcd..715539758 100644 --- a/docs/source/Plugin/P013_RCW-0001.rst +++ b/docs/source/Plugin/P013_RCW-0001.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P013_RCW-0001_page: RCW-0001 @@ -26,7 +26,7 @@ Wiring The RCW-0001 must be run on 5V. Running it with 3.3V will show very weak results or nothing at all. -.. code-block:: html +.. code-block:: none ESP RCW-0001 GPIO (X) <--> Trigger @@ -89,7 +89,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: on RCW0001#distance do if [RCW0001#distance]<50 and [RCW0001#distance]>45 diff --git a/docs/source/Plugin/P013_US-100.rst b/docs/source/Plugin/P013_US-100.rst index d99cff0f9..b2594f805 100644 --- a/docs/source/Plugin/P013_US-100.rst +++ b/docs/source/Plugin/P013_US-100.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P013_US-100_page: US-100 @@ -26,7 +26,7 @@ Wiring The US-100 must be run on 5V. Running it with 3.3V will show very weak results or nothing at all. -.. code-block:: html +.. code-block:: none ESP US-100 GPIO (X) <--> Trigger @@ -89,7 +89,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: on US100#distance do if [US100#distance]<50 and [US100#distance]>45 diff --git a/docs/source/Plugin/P014_SI7021_HTU21D.rst b/docs/source/Plugin/P014_SI7021_HTU21D.rst index bced501ef..1e14966e2 100644 --- a/docs/source/Plugin/P014_SI7021_HTU21D.rst +++ b/docs/source/Plugin/P014_SI7021_HTU21D.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P014_SI7021_HTU21D_page: SI7021/HTU21D @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P015_TSL2561.rst b/docs/source/Plugin/P015_TSL2561.rst index 2c370ef50..9f91f2593 100644 --- a/docs/source/Plugin/P015_TSL2561.rst +++ b/docs/source/Plugin/P015_TSL2561.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P015_TSL2561_page: TSL2561 @@ -31,7 +31,7 @@ Wiring .. image:: P015_TSL2561_2.jpg -.. code-block:: html +.. code-block:: none ESP TSL2561 GPIO (5) <--> SCL @@ -94,7 +94,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on Light#VI_Lux do if Light#VI_Lux>100 diff --git a/docs/source/Plugin/P017_PN532.rst b/docs/source/Plugin/P017_PN532.rst index f27745ac2..dc27c1ca6 100644 --- a/docs/source/Plugin/P017_PN532.rst +++ b/docs/source/Plugin/P017_PN532.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P017_PN532_page: PN532 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P018_GP2Y10.rst b/docs/source/Plugin/P018_GP2Y10.rst index 341d6b87f..1039d7b80 100644 --- a/docs/source/Plugin/P018_GP2Y10.rst +++ b/docs/source/Plugin/P018_GP2Y10.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P018_GP2Y10_page: GP2Y10 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P019_PCF8574.rst b/docs/source/Plugin/P019_PCF8574.rst index fe66509eb..a7f1b91bb 100644 --- a/docs/source/Plugin/P019_PCF8574.rst +++ b/docs/source/Plugin/P019_PCF8574.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p01x.repl +.. include:: ../Plugin/_plugin_substitutions_p01x.repl .. _P019_PCF8574_page: PCF8574 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P022_PCA9685.rst b/docs/source/Plugin/P022_PCA9685.rst index 4d07cb39e..a1bb62f83 100644 --- a/docs/source/Plugin/P022_PCA9685.rst +++ b/docs/source/Plugin/P022_PCA9685.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P022_PCA9685_page: PCA9685 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P023_OLED.rst b/docs/source/Plugin/P023_OLED.rst index f002df965..48ffc1db0 100644 --- a/docs/source/Plugin/P023_OLED.rst +++ b/docs/source/Plugin/P023_OLED.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P023_OLED_page: OLED @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P024_MLX90614.rst b/docs/source/Plugin/P024_MLX90614.rst index 3cc5ab4cc..bc85d57c7 100644 --- a/docs/source/Plugin/P024_MLX90614.rst +++ b/docs/source/Plugin/P024_MLX90614.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P024_MLX90614_page: MLX90614 @@ -21,7 +21,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP MLX90614 GPIO (4) <--> SDA @@ -71,7 +71,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on Temp#C do if [Temp#C]>300 diff --git a/docs/source/Plugin/P025_ADS1115.rst b/docs/source/Plugin/P025_ADS1115.rst index 11303f6c9..ec730736c 100644 --- a/docs/source/Plugin/P025_ADS1115.rst +++ b/docs/source/Plugin/P025_ADS1115.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P025_ADS1115_page: ADS1115 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P027_INA219.rst b/docs/source/Plugin/P027_INA219.rst index fcbf8eed7..4b1991746 100644 --- a/docs/source/Plugin/P027_INA219.rst +++ b/docs/source/Plugin/P027_INA219.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P027_INA219_page: INA219 @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P028_BME280.rst b/docs/source/Plugin/P028_BME280.rst index ebc539608..58a4e20b0 100644 --- a/docs/source/Plugin/P028_BME280.rst +++ b/docs/source/Plugin/P028_BME280.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p02x.repl +.. include:: ../Plugin/_plugin_substitutions_p02x.repl .. _P028_BME280_page: BME280 @@ -24,7 +24,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP BME280 GPIO (4) <--> SDA @@ -75,7 +75,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on BME#hPa do if BME#hPa>999 diff --git a/docs/source/Plugin/P030_BMP280.rst b/docs/source/Plugin/P030_BMP280.rst index 8f6e58801..467592d48 100644 --- a/docs/source/Plugin/P030_BMP280.rst +++ b/docs/source/Plugin/P030_BMP280.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p03x.repl +.. include:: ../Plugin/_plugin_substitutions_p03x.repl .. _P030_BMP280_page: BMP280 @@ -23,7 +23,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP BMP280 GPIO (4) <--> SDI (SDA) @@ -77,7 +77,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on BMP#hPa do if BMP#hPa>999 diff --git a/docs/source/Plugin/P031_SHT1X.rst b/docs/source/Plugin/P031_SHT1X.rst index 40923d120..77ee233d8 100644 --- a/docs/source/Plugin/P031_SHT1X.rst +++ b/docs/source/Plugin/P031_SHT1X.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p03x.repl +.. include:: ../Plugin/_plugin_substitutions_p03x.repl .. _P031_SHT1X_page: SHT1X @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -52,7 +52,7 @@ With a delay of 10, on the same node, the clock signal is about 40 kHz. Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P032_MS5611.rst b/docs/source/Plugin/P032_MS5611.rst index 057bbec09..7616bbd0e 100644 --- a/docs/source/Plugin/P032_MS5611.rst +++ b/docs/source/Plugin/P032_MS5611.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p03x.repl +.. include:: ../Plugin/_plugin_substitutions_p03x.repl .. _P032_MS5611_page: MS5611 @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P034_DHT12.rst b/docs/source/Plugin/P034_DHT12.rst index 75b1ff0be..1cf2e3044 100644 --- a/docs/source/Plugin/P034_DHT12.rst +++ b/docs/source/Plugin/P034_DHT12.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p03x.repl +.. include:: ../Plugin/_plugin_substitutions_p03x.repl .. _P034_DHT12_page: DHT12 @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P035_IR_transmitter.rst b/docs/source/Plugin/P035_IR_transmitter.rst index b57c4e404..6fb7c1464 100644 --- a/docs/source/Plugin/P035_IR_transmitter.rst +++ b/docs/source/Plugin/P035_IR_transmitter.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p03x.repl +.. include:: ../Plugin/_plugin_substitutions_p03x.repl .. _P035_IR_transmitter_page: IR transmitter @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P045_MPU6050.rst b/docs/source/Plugin/P045_MPU6050.rst index aa079aea2..c9a79ca26 100644 --- a/docs/source/Plugin/P045_MPU6050.rst +++ b/docs/source/Plugin/P045_MPU6050.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p04x.repl +.. include:: ../Plugin/_plugin_substitutions_p04x.repl .. _P045_MPU6050_page: MPU6050 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P046_Ventus_W266.rst b/docs/source/Plugin/P046_Ventus_W266.rst index 50b49d131..9ca4f8a2d 100644 --- a/docs/source/Plugin/P046_Ventus_W266.rst +++ b/docs/source/Plugin/P046_Ventus_W266.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p04x.repl +.. include:: ../Plugin/_plugin_substitutions_p04x.repl .. _P046_Ventus_W266_page: Ventus W266 @@ -42,7 +42,7 @@ Specifications (indoor unit): of the normal builds. If you want to compile ESP Easy with this plugin enabled you can set the following line in your platformio.ini: - .. code-block:: html + .. code-block:: none [platformio] env_default = hard_Ventus_W266 @@ -70,7 +70,7 @@ Wiring .. image:: P046_Ventus_W266_2.jpg -.. code-block:: html +.. code-block:: none ESP Ventus GPIO (4) <--> MOSI @@ -169,7 +169,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on VentusW266#UV do if [VentusW266#UV]>9 diff --git a/docs/source/Plugin/P047_Soil_moisture_sensor.rst b/docs/source/Plugin/P047_Soil_moisture_sensor.rst index 7fe9f20d1..239822f9e 100644 --- a/docs/source/Plugin/P047_Soil_moisture_sensor.rst +++ b/docs/source/Plugin/P047_Soil_moisture_sensor.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p04x.repl +.. include:: ../Plugin/_plugin_substitutions_p04x.repl .. _P047_Soil_moisture_sensor_page: Soil moisture sensor @@ -22,7 +22,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -42,7 +42,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P048_Adafruit_Motor_Shield_v2.rst b/docs/source/Plugin/P048_Adafruit_Motor_Shield_v2.rst index 8ae786b48..f077b9a10 100644 --- a/docs/source/Plugin/P048_Adafruit_Motor_Shield_v2.rst +++ b/docs/source/Plugin/P048_Adafruit_Motor_Shield_v2.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p04x.repl +.. include:: ../Plugin/_plugin_substitutions_p04x.repl .. _P048_Adafruit_Motor_Shield_v2_page: Adafruit Motor Shield v2 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P049_MH-Z19.rst b/docs/source/Plugin/P049_MH-Z19.rst index 4c6790324..f60c17592 100644 --- a/docs/source/Plugin/P049_MH-Z19.rst +++ b/docs/source/Plugin/P049_MH-Z19.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p04x.repl +.. include:: ../Plugin/_plugin_substitutions_p04x.repl .. _P049_MH-Z19_page: MH-Z19 @@ -22,7 +22,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -42,7 +42,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P050_TCS34725.rst b/docs/source/Plugin/P050_TCS34725.rst index 2d23e11a1..a4aebe38a 100644 --- a/docs/source/Plugin/P050_TCS34725.rst +++ b/docs/source/Plugin/P050_TCS34725.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P050_TCS34725_page: TCS34725 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P051_AM2320.rst b/docs/source/Plugin/P051_AM2320.rst index 1111987ac..9da70752f 100644 --- a/docs/source/Plugin/P051_AM2320.rst +++ b/docs/source/Plugin/P051_AM2320.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P051_AM2320_page: AM2320 @@ -21,7 +21,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -41,7 +41,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P052_S11.rst b/docs/source/Plugin/P052_S11.rst index f4a294817..b1041b4d3 100644 --- a/docs/source/Plugin/P052_S11.rst +++ b/docs/source/Plugin/P052_S11.rst @@ -28,7 +28,7 @@ Wiring Circuit wiring (S11 seen from top, with the 5 holes left and the 4 holes right): -.. code-block:: html +.. code-block:: none ESP S11 (UART) GPIO (14) <--> TX (5th hole of the 5 holes) @@ -106,7 +106,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on CO2#Level do if [CO2#Level]>2000 diff --git a/docs/source/Plugin/P052_S8.rst b/docs/source/Plugin/P052_S8.rst index 5f79afd56..f9239ddba 100644 --- a/docs/source/Plugin/P052_S8.rst +++ b/docs/source/Plugin/P052_S8.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P052_S8_page: S8 @@ -28,7 +28,7 @@ Wiring Circuit wiring (S8 seen from PCB side, with the 5 vias down and the 4 vias up): -.. code-block:: html +.. code-block:: none ESP S8 GPIO (7) <--> TX (3rd via [middle] of the 5 vias) @@ -95,7 +95,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on CO2#Level do if [CO2#Level]>2000 diff --git a/docs/source/Plugin/P052_tSense_K70.rst b/docs/source/Plugin/P052_tSense_K70.rst index fed48c56d..b70fb6110 100644 --- a/docs/source/Plugin/P052_tSense_K70.rst +++ b/docs/source/Plugin/P052_tSense_K70.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P052_tSense_K70_page: tSense (K70) @@ -36,7 +36,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP tSense GPIO (7) <--> TX (see pictures further down) @@ -140,7 +140,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on CO2#Level do if [CO2#Level]>2000 diff --git a/docs/source/Plugin/P053_PMSx003.rst b/docs/source/Plugin/P053_PMSx003.rst index 6b1b355ae..11adc4593 100644 --- a/docs/source/Plugin/P053_PMSx003.rst +++ b/docs/source/Plugin/P053_PMSx003.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P053_PMSx003_page: PMSx003 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P059_Rotary_Encoder.rst b/docs/source/Plugin/P059_Rotary_Encoder.rst index 689009c45..5b6dea882 100644 --- a/docs/source/Plugin/P059_Rotary_Encoder.rst +++ b/docs/source/Plugin/P059_Rotary_Encoder.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p05x.repl +.. include:: ../Plugin/_plugin_substitutions_p05x.repl .. _P059_Rotary_Encoder_page: Rotary Encoder @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P063_TTP229-B.rst b/docs/source/Plugin/P063_TTP229-B.rst index 379dc07b7..c13b4efc3 100644 --- a/docs/source/Plugin/P063_TTP229-B.rst +++ b/docs/source/Plugin/P063_TTP229-B.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p06x.repl +.. include:: ../Plugin/_plugin_substitutions_p06x.repl .. _P063_TTP229-B_page: TTP229-B @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P065_DFPlayer_Mini.rst b/docs/source/Plugin/P065_DFPlayer_Mini.rst index 369b87667..a147534e4 100644 --- a/docs/source/Plugin/P065_DFPlayer_Mini.rst +++ b/docs/source/Plugin/P065_DFPlayer_Mini.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p06x.repl +.. include:: ../Plugin/_plugin_substitutions_p06x.repl .. _P065_DFPlayer_Mini_page: DFPlayer Mini @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P065_YX5300.rst b/docs/source/Plugin/P065_YX5300.rst index 441cb3c3b..c85cd6fd4 100644 --- a/docs/source/Plugin/P065_YX5300.rst +++ b/docs/source/Plugin/P065_YX5300.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p06x.repl +.. include:: ../Plugin/_plugin_substitutions_p06x.repl .. _P065_YX5300_page: YX5300 @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P073_7_Segment.rst b/docs/source/Plugin/P073_7_Segment.rst index 2852e1788..148cf3d0a 100644 --- a/docs/source/Plugin/P073_7_Segment.rst +++ b/docs/source/Plugin/P073_7_Segment.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p07x.repl +.. include:: ../Plugin/_plugin_substitutions_p07x.repl .. _P073_7_Segment_page: 7 Segment @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P075_Nextion.rst b/docs/source/Plugin/P075_Nextion.rst index 9346a0b97..2d819fdde 100644 --- a/docs/source/Plugin/P075_Nextion.rst +++ b/docs/source/Plugin/P075_Nextion.rst @@ -1,4 +1,4 @@ -.. include:: ../Plugin/_plugin_substitutions_p07x.repl +.. include:: ../Plugin/_plugin_substitutions_p07x.repl .. _P075_Nextion_page: Nextion @@ -20,7 +20,7 @@ Wiring ------ -.. code-block:: html +.. code-block:: none ESP S8 GPIO (X) <--> TX @@ -40,7 +40,7 @@ Setup Rules examples -------------- -.. code-block:: html +.. code-block:: none //Code below... diff --git a/docs/source/Plugin/P081.rst b/docs/source/Plugin/P081.rst index d1088d7df..232f6a703 100644 --- a/docs/source/Plugin/P081.rst +++ b/docs/source/Plugin/P081.rst @@ -46,7 +46,7 @@ The extra argument handles seconds. See also `Wikipedia - Cron `_ for more detailed information. -.. code-block:: html +.. code-block:: none ┌───────────── seconds (0 - 59) │ ┌───────────── minute (0 - 59) @@ -76,7 +76,7 @@ Examples of supported expressions Expression, input date, next date: -.. code-block:: html +.. code-block:: none "*/15 * 1-4 * * *", "2012-07-01_09:53:50", "2012-07-02_01:00:00" "0 */2 1-4 * * *", "2012-07-01_09:00:00", "2012-07-02_01:00:00" diff --git a/docs/source/Plugin/P081_events.repl b/docs/source/Plugin/P081_events.repl index d427bad2e..785b04053 100644 --- a/docs/source/Plugin/P081_events.repl +++ b/docs/source/Plugin/P081_events.repl @@ -7,7 +7,7 @@ Will trigger when the cron expression of task named ``foo`` matches the current time. "," - .. code-block:: html + .. code-block:: none on Cron#foo do GPIO,2,1 //LED on diff --git a/docs/source/Plugin/P082_Neo-6M.rst b/docs/source/Plugin/P082_Neo-6M.rst index 9b8498b18..4e2f1f1dd 100644 --- a/docs/source/Plugin/P082_Neo-6M.rst +++ b/docs/source/Plugin/P082_Neo-6M.rst @@ -27,7 +27,7 @@ The TX channel from the ESP to the GPS is not needed for this plugin. The used baudrate is 9600 bps. -.. code-block:: html +.. code-block:: none ESP Neo-6M (HW Serial0) GPIO (3/RX/RX0/D9) <--> TXD @@ -102,7 +102,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on GeoPos#Speed do if [GeoPos#Speed]>50 diff --git a/docs/source/Plugin/P082_Neo-7M.rst b/docs/source/Plugin/P082_Neo-7M.rst index b638cb149..3b13e522a 100644 --- a/docs/source/Plugin/P082_Neo-7M.rst +++ b/docs/source/Plugin/P082_Neo-7M.rst @@ -28,7 +28,7 @@ The TX channel from the ESP to the GPS is not needed for this plugin. The used baudrate is 9600 bps. -.. code-block:: html +.. code-block:: none ESP Neo-7M (HW Serial0) GPIO (3/RX/RX0/D9) <--> TXD @@ -103,7 +103,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on GeoPos#Speed do if [GeoPos#Speed]>50 diff --git a/docs/source/Plugin/P082_Neo-M8n.rst b/docs/source/Plugin/P082_Neo-M8n.rst index 736ace675..eb0487e88 100644 --- a/docs/source/Plugin/P082_Neo-M8n.rst +++ b/docs/source/Plugin/P082_Neo-M8n.rst @@ -30,7 +30,7 @@ The TX channel from the ESP to the GPS is not needed for this plugin. The used baudrate is 9600 bps. -.. code-block:: html +.. code-block:: none ESP Neo-M8n (HW Serial0) GPIO (3/RX/RX0/D9) <--> TXD @@ -105,7 +105,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on GeoPos#Speed do if [GeoPos#Speed]>50 diff --git a/docs/source/Plugin/P082_events.repl b/docs/source/Plugin/P082_events.repl index cf3a256be..ce0acea12 100644 --- a/docs/source/Plugin/P082_events.repl +++ b/docs/source/Plugin/P082_events.repl @@ -7,7 +7,7 @@ Will trigger when the GPS unit got a good position from the satellites. "," - .. code-block:: html + .. code-block:: none on GPS#GotFix do GPIO,2,1 //LED on @@ -19,7 +19,7 @@ Will trigger when the GPS unit is not having a good position from the satellites. "," - .. code-block:: html + .. code-block:: none on GPS#LostFix do GPIO,2,0 //LED off @@ -32,7 +32,7 @@ This means the total travel distance can be more if the GPS does not move in a straight line. "," - .. code-block:: html + .. code-block:: none on GPS#travelled do LogEntry,'Travelled %eventvalue% meter' diff --git a/docs/source/Plugin/P086_Homie.rst b/docs/source/Plugin/P086_Homie.rst index cbc33f847..9e9f2d7a0 100644 --- a/docs/source/Plugin/P086_Homie.rst +++ b/docs/source/Plugin/P086_Homie.rst @@ -41,7 +41,7 @@ For some controllers or dataset types it is not necessary to acknowledge the new Example Rules for every value / event type ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. code-block:: html +.. code-block:: none // The "homie controller" schedules the event defined in the plug-in. // Does NOT store string values or arrays in the "homie receiver" plug-in. diff --git a/docs/source/Plugin/P097_events.repl b/docs/source/Plugin/P097_events.repl index 992cb218f..eb5522b57 100644 --- a/docs/source/Plugin/P097_events.repl +++ b/docs/source/Plugin/P097_events.repl @@ -8,7 +8,7 @@ The regular events like in every other task. Only difference here is that you may have an event either when the touch pad is touched, released or both. "," - .. code-block:: html + .. code-block:: none on touch#Touch do GPIO,2,1 //LED on @@ -21,7 +21,7 @@ When enabled, this event will be sent on release of the touch pad. The event variable is the time in msec the pad had been touched. "," - .. code-block:: html + .. code-block:: none on touch#Duration do LogEntry,'Touch Duration %eventvalue% ms' @@ -29,7 +29,7 @@ Example in the log: - .. code-block:: html + .. code-block:: none 6553261 : Info : Touch : ADC2 ch5 (T5): 10 6553338 : Info : EVENT: touch#Touch=10.00 diff --git a/docs/source/Plugin/_plugin_hardware.template b/docs/source/Plugin/_plugin_hardware.template index e6dbb0395..963fd061d 100644 --- a/docs/source/Plugin/_plugin_hardware.template +++ b/docs/source/Plugin/_plugin_hardware.template @@ -20,7 +20,7 @@ Specifications: Wiring ------ -.. code-block:: html +.. code-block:: none ESP UNIT GPIO (X) <--> A @@ -73,7 +73,7 @@ Indicators (recommended settings) Rules examples -------------- -.. code-block:: html +.. code-block:: none on TASK#VALUE do if [TASK#VALUE]>999 diff --git a/docs/source/Rules/Rules.rst b/docs/source/Rules/Rules.rst index 3c59ab3a2..4588c7957 100644 --- a/docs/source/Rules/Rules.rst +++ b/docs/source/Rules/Rules.rst @@ -51,79 +51,79 @@ Syntax The syntax of a rule can be single line: -.. code-block:: html +.. code-block:: none - on do endon + on do endon or multi-line (need to be closed with an "endon"): -.. code-block:: html +.. code-block:: none - on do - - - - endon + on do + + + + endon IF/ELSE - IF/ELSEIF/ELSE ------------------------ Also simple if ... else ... statements are possible: -.. code-block:: html +.. code-block:: none - on do - if - - - else - - endif - endon + on do + if + + + else + + endif + endon If the "else" part is not needed it can be removed: -.. code-block:: html +.. code-block:: none - on do - if - - - endif - endon + on do + if + + + endif + endon Also more complex if ... elseif ... else statements are possible (multiple elseif's can be used) -.. code-block:: html +.. code-block:: none - on do - if - - - elseif - - - else - - endif - endon + on do + if + + + elseif + + + else + + endif + endon Again, if the "else" part is not needed it can be removed: -.. code-block:: html +.. code-block:: none - on do - if - - - elseif - - - elseif - - - endif - endon + on do + if + + + elseif + + + elseif + + + endif + endon AND/OR ------ @@ -135,55 +135,55 @@ consumption of stack space (IRAM). Depending on plug-ins in use this might lead to unpredictable, unreliable behavior, advice is not to exceed 3 levels of nesting. -.. code-block:: html +.. code-block:: none - on do - if - event, - endif - endon - - on do - if - - endif - endon + on do + if + event, + endif + endon + + on do + if + + endif + endon As of mega-201803.. we have the possibility to use AND/OR: -.. code-block:: html +.. code-block:: none - on test do - if [test#a]=0 or [test#b]=0 or [test#c]=0 - event,ok - else - event,not_ok - endif - endon - - on test2 do - if [test#a]=1 and [test#b]=1 and [test#c]=1 - event,ok - else - event,not_ok - endif - endon - - on test3 do - if [test#a]=1 and [test#b]=1 or [test#c]=0 - event,ok - else - event,not_ok - endif - endon - - on test4 do - if [test#a]=0 - event,ok - else - event,not_ok - endif - endon + on test do + if [test#a]=0 or [test#b]=0 or [test#c]=0 + event,ok + else + event,not_ok + endif + endon + + on test2 do + if [test#a]=1 and [test#b]=1 and [test#c]=1 + event,ok + else + event,not_ok + endif + endon + + on test3 do + if [test#a]=1 and [test#b]=1 or [test#c]=0 + event,ok + else + event,not_ok + endif + endon + + on test4 do + if [test#a]=0 + event,ok + else + event,not_ok + endif + endon Up to two AND/OR can be used per if statement, that means that you can test three float values and if the statement is true/false corresponding action will take place. @@ -191,13 +191,13 @@ three float values and if the statement is true/false corresponding action will Trigger ------- -.. code-block:: html +.. code-block:: none The trigger can be an device value being changed: -.. code-block:: html +.. code-block:: none DeviceName#ValueName @@ -206,13 +206,13 @@ Operator (inequality function) Or a inequality function: -.. code-block:: html +.. code-block:: none DeviceName#ValueName Where the "inequality function" is a simple check: -.. code-block:: html +.. code-block:: none equal (=) to less (<) than @@ -240,14 +240,14 @@ boot/reboot/time/sleep etc. of the unit: Test ---- -.. code-block:: html +.. code-block:: none As described in the trigger section the test is a check done by checking if the DeviceName#ValueName is meeting a criteria: -.. code-block:: html +.. code-block:: none [DeviceName#ValueName] @@ -257,7 +257,7 @@ DeviceName#ValueName is closed by (square) brackets "[" and "]". Action ------ -.. code-block:: html +.. code-block:: none @@ -272,7 +272,7 @@ Comment If you want you can add comments to any row in your rules code. Just remember to add them after the code and always begin with "//": -.. code-block:: html +.. code-block:: none on do //If this happens then do that... if @@ -356,13 +356,13 @@ In order to allow the comma or space in a parameter, you can wrap the parameter There are multiple quotes available for this, to be able to use "the other quote" in your parameter. For example in JSON, you need the double quote for string like values or keys. -.. code-block:: html +.. code-block:: none Publish domoticz/in,{"idx":26,"nvalue":0,"svalue":"[AQ#TVOC]"} This can be fixed by wrapping the last parameter with single quotes like this: -.. code-block:: html +.. code-block:: none Publish domoticz/in,'{"idx":26,"nvalue":0,"svalue":"[AQ#TVOC]"}' @@ -459,7 +459,7 @@ The position arguments are the same as in Arduino ``String::substring`` , meanin For example: -.. code-block:: html +.. code-block:: none on DS-1#Temperature do logentry,{substring:0:1:%eventvalue%} @@ -470,7 +470,7 @@ For example: The ``%eventvalue%`` may contain the value "23.06" The output in the log will then be: -.. code-block:: html +.. code-block:: none 1512372 : Info : EVENT: DS-1#Temperature=23.06 1512404 : Info : ACT : logentry,2 @@ -488,13 +488,13 @@ N.B. it is also possible to concatenate these and refer to ``{taskname#varname}` For example (bit useless example, just for illustrative purposes): -.. code-block:: html +.. code-block:: none on DS-1#Temperature do logentry,{substring:0:2:{strtol:16:{substring:0:2:[DS-1#Temperature]}{substring:3:5:[DS-1#Temperature]}}} endon -.. code-block:: html +.. code-block:: none 221313 : Info : EVENT: DS-1#Temperature=22.13 221346 : Info : parse_string_commands cmd: substring:0:2:22.13 -> 22 @@ -515,14 +515,14 @@ Usage: ``{strtol:16:}`` to convert HEX (base 16) into an integer value. Example of extracting sub strings from a value and interpreting as if they were HEX values: -.. code-block:: html +.. code-block:: none on DS-1#Temperature do logentry,{strtol:16:%eventvalue%} logentry,{strtol:16:{substring:3:5:%eventvalue%}} endon -.. code-block:: html +.. code-block:: none 1987550 : Info : EVENT: DS-1#Temperature=24.12 1987586 : Info : ACT : logentry,36 @@ -566,7 +566,7 @@ Last but not least the fraction is not correct, it needs to be divided by 256 (a Complete rule used to parse this and set a variable in a dummy device: -.. code-block:: html +.. code-block:: none // Room temperature on !Serial#T1018* do @@ -583,7 +583,7 @@ Usage: ``{ord:}`` For example: -.. code-block:: html +.. code-block:: none on DS-1#Temperature do logentry,{ord:A} // ASCII value of 'A' @@ -591,7 +591,7 @@ For example: endon -.. code-block:: html +.. code-block:: none 2982455 : Info : EVENT: DS-1#Temperature=23.12 2982487 : Info : ACT : logentry,65 @@ -626,7 +626,7 @@ Regarding spaces in names it is recommended to NOT use them as it makes bug testing rules a lot harder. Spaces between chunks of code is possible to make the code more readable: -.. code-block:: html +.. code-block:: none [DeviceName#ValueName]< //These work... [DeviceName#ValueName] < //the same... @@ -647,14 +647,14 @@ TaskValueSet Dummy Device is a single way to store and read value on variable. Just create Generic - Dummy Device and variables inside it. -.. code-block:: html +.. code-block:: none TaskValueSet,TASKnr,VARnr,Value This example for two switches that toggle one device (LED and Relay on GPIO 13 and 16). -.. code-block:: html +.. code-block:: none on sw1#state do if [dummy#var1]=0 @@ -688,7 +688,7 @@ For the Unix time there are now 2 variables included: Here some example used to store the Unix time in the dummy plugin to keep track of actions. The values stored in the Dummy variables will be kept and restored on a crash/reboot as long as the ESP remains powered. -.. code-block:: html +.. code-block:: none if [DT#YMD]=0 and %unixday%>0 taskvalueset,7,1,%unixday%-1 @@ -715,7 +715,7 @@ the '=' sign, up to four values are possible). Sample rules section: -.. code-block:: html +.. code-block:: none on remoteTimerControl do timerSet,1,%eventvalue% @@ -723,7 +723,7 @@ Sample rules section: Now send this command to the ESP: -.. code-block:: html +.. code-block:: none http:///control?cmd=event,remoteTimerControl=5 @@ -740,7 +740,7 @@ the value of the Dummy device as condition in if-statement within rules. Multiple event values: -.. code-block:: html +.. code-block:: none on ToggleGPIO do GPIO,%eventvalue1%,%eventvalue2% @@ -748,7 +748,7 @@ Multiple event values: You could then use the command "ToggleGPIO" with dynamic GPIO numbers and state. -.. code-block:: html +.. code-block:: none http:///control?cmd=event,ToggleGPIO=12,1 @@ -757,7 +757,7 @@ Internal variables A really great feature to use is the 16 internal variables. You set them like this: -.. code-block:: html +.. code-block:: none Let,, @@ -774,7 +774,7 @@ remove the jumpiness with hardware you might want to add a filter in the softwar A **10 value average**: -.. code-block:: html +.. code-block:: none On Temp#Value Do Let,10,[VAR#9] @@ -798,7 +798,7 @@ value instead of the sensor value. Another filter could be to just use the previous value and **dilute** the new value with that one: -.. code-block:: html +.. code-block:: none On Temp#Value Do Let,2,[VAR#1] @@ -809,7 +809,7 @@ Another filter could be to just use the previous value and **dilute** the new va Yet another filter could be to add the new value to a **summarized average**: -.. code-block:: html +.. code-block:: none On Temp#Value Do Let,1,[Temp#Value] @@ -823,7 +823,7 @@ one suits your actual scenario the best. PIR and LDR ----------- -.. code-block:: html +.. code-block:: none On PIR#State do if [LDR#Light]<500 @@ -836,7 +836,7 @@ PIR and LDR In other words: If the PIR switch is set (to either 1 or 0) and if the light value < 500, then set GPIO port 16 of the ESP. -.. code-block:: html +.. code-block:: none on PIR#State=1 do if [LDR#Light]<500 @@ -849,7 +849,7 @@ Now the event is only triggered when the PIR switches on. SR04 and LDR ------------ -.. code-block:: html +.. code-block:: none on SR04#range<100 do if [ldr#lux]<500 @@ -867,7 +867,7 @@ Timer There are 8 timers (1-8) you can use: -.. code-block:: html +.. code-block:: none On System#Boot do //When the ESP boots, do servo,1,12,0 @@ -891,7 +891,7 @@ Starting/stopping repeating timers with events To disable an existing timer, set it to 0. This is useful to make repeating timers for things like alarms or warnings: -.. code-block:: html +.. code-block:: none //start the warning signal when we receive a start_warning event: On start_warning do @@ -915,7 +915,7 @@ timers for things like alarms or warnings: To start or stop the warning signal use http: -.. code-block:: html +.. code-block:: none http:///control?cmd=event,start_warning http:///control?cmd=event,stop_warning @@ -925,14 +925,14 @@ HTTP call When you enter this first command with the correct IP address in the URL of your browser: -.. code-block:: html +.. code-block:: none http:///control?cmd=event,startwatering http:///control?cmd=event,stopwatering And have this rule in the addressed ESP: -.. code-block:: html +.. code-block:: none On startwatering do gpio,12,1 //start watering (open valve) @@ -966,7 +966,7 @@ SendTo: SendTo , Imagine you have two ESP Easy modules, ESP#1 and ESP#2 In the Rules section of ESP#1 you have this: -.. code-block:: html +.. code-block:: none on demoEvent do sendTo,2,event,startwatering //(to use the previous example.) @@ -976,7 +976,7 @@ And ESP#2 has the rules according to the previous example (givemesomewater) If you then enter this with the correct IP address in the URL of your browser: -.. code-block:: html +.. code-block:: none http:///control?cmd=event,demoEvent @@ -984,7 +984,7 @@ Then ESP#1 shall send the event 'startwatering ' to ESP#2. It is also possible to directly order GPIO changes, like: -.. code-block:: html +.. code-block:: none on demoEvent do sendTo,2,GPIO,2,1 @@ -993,7 +993,7 @@ It is also possible to directly order GPIO changes, like: Publish -.. code-block:: html +.. code-block:: none Publish,, @@ -1004,7 +1004,7 @@ Time With Rules you can also start or stop actions on a given day and time, or even on every day. -.. code-block:: html +.. code-block:: none On Clock#Time=All,18:25 do // every day at 18:25 hours do ... gpio,14,0 @@ -1012,7 +1012,7 @@ With Rules you can also start or stop actions on a given day and time, or even o Or for a specific day: -.. code-block:: html +.. code-block:: none On Clock#Time=Sun,18:25 do // for Sunday, but All, Sun, Mon, Tue, Wed, Thu, Fri, Sat will do. gpio,14,0 @@ -1021,7 +1021,7 @@ Or for a specific day: It is also possible to use the system value %systime% in rules conditions to make things happen during certain hours of the day: -.. code-block:: html +.. code-block:: none On Pir#State=1 do If %systime% < 07:00:00 @@ -1041,7 +1041,7 @@ SendToHTTP To send a message to another device, like a command to switch on a light to Domoticz -.. code-block:: html +.. code-block:: none On System#Boot do //When the ESP boots, do timerSet,1,10 //Set Timer 1 for the next event in 10 seconds @@ -1055,7 +1055,7 @@ Many users have reported problems with commands being truncated, particularly when trying to send commands to Domoticz. It seems to be a parsing error. There is the following workaround: -.. code-block:: html +.. code-block:: none SendToHTTP 192.168.0.243,8080,/json.htm?type=param=switchlight&command&idx=174&switchcmd=On @@ -1071,7 +1071,7 @@ different i2c addresses. For dew point on the 'outside': -.. code-block:: html +.. code-block:: none on TempHumidityPressure_OUTSIDE#%RH do TaskValueSet,7,1,[TempHumidityPressure_OUTSIDE#°C]-(100-[TempHumidityPressure_OUTSIDE#%RH])/5 // "7" is the number of the task that the dummy device is on, "1" is its first value where we dump our result @@ -1084,7 +1084,7 @@ For dew point on the 'outside': For dew point on the 'inside': -.. code-block:: html +.. code-block:: none on TempHumidityPressure_INSIDE#%RH do TaskValueSet,7,2,[TempHumidityPressure_INSIDE#°C]-(100-[TempHumidityPressure_INSIDE#%RH])/5 // "7" is the number of the task that the dummy device is on, "2" is its second value where we dump our result @@ -1102,7 +1102,7 @@ Report IP every 30 seconds using MQTT This rule also work as a ping or heart beat of the unit. If it has not published a IP number for 30+ seconds the unit is experiencing problems. -.. code-block:: html +.. code-block:: none On System#Boot do //When the ESP boots, do Publish,%sysname%/IP,%ip% @@ -1125,7 +1125,7 @@ just as an example we want to publish these as custom messages with a unique IDX *MQTT* -.. code-block:: html +.. code-block:: none on INA219#Amps do Publish domoticz/in,{"idx":123456,"nvalue":0,"svalue":"[INA219#Amps]"} //Own made up IDX 123456 @@ -1138,7 +1138,7 @@ just as an example we want to publish these as custom messages with a unique IDX *HTTP* -.. code-block:: html +.. code-block:: none on INA219#Amps do SendToHTTP 192.168.1.2,8080,/json.htm?type=command¶m=udevice&idx=123456&nvalue=0&svalue=[INA219#Amps] //Own made up IDX 123456 @@ -1159,7 +1159,7 @@ Using a "normal switch" device which is in this example normally set to low (0) you can make one of two actions when pressed. If you either release the button in less than a second or press it for more than a second: -.. code-block:: html +.. code-block:: none on Button#State=1 do timerSet,1,1 @@ -1178,7 +1178,7 @@ Calculating water consumption Using the pulse counter you can calculate and act on waterflow and changes like this: -.. code-block:: html +.. code-block:: none On System#Boot do // When the ESP boots, do TaskValueSet,3,1,0 // TaskValueSet TASKnr,VARnr,Value, Reset the Liters counter to 0 From e2ef91088e5df30e7663702ed6028fc6c68b630f Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Sun, 9 Aug 2020 13:05:46 +0200 Subject: [PATCH 05/47] [Rules Timer] Use scheduler for rules timer This does remove the limit of number of timers. Also it makes scheduled intervals a lot more accurate. --- src/ESPEasy-Globals.cpp | 1 - src/ESPEasy-Globals.h | 15 --- src/ESPEasyRules.ino | 23 ---- src/ESPEasy_fdwdecl.h | 1 - src/src/Commands/Timer.cpp | 81 ++++--------- src/src/DataStructs/ESPEasyLimits.h | 2 +- src/src/Helpers/ESPEasy_checks.cpp | 1 - src/src/Helpers/PeriodicalActions.cpp | 3 - src/src/Helpers/Scheduler.cpp | 127 ++++++++++++++++++++- src/src/Helpers/Scheduler.h | 17 +++ src/src/Helpers/msecTimerHandlerStruct.cpp | 13 ++- src/src/Helpers/msecTimerHandlerStruct.h | 3 + 12 files changed, 177 insertions(+), 110 deletions(-) diff --git a/src/ESPEasy-Globals.cpp b/src/ESPEasy-Globals.cpp index 6b6949e5e..1e2fb5f80 100644 --- a/src/ESPEasy-Globals.cpp +++ b/src/ESPEasy-Globals.cpp @@ -40,7 +40,6 @@ boolean printToWeb = false; String printWebString; boolean printToWebJSON = false; -rulesTimerStatus RulesTimer[RULES_TIMER_MAX]; msecTimerHandlerStruct msecTimerHandler; diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index 98cc52efc..46acc47c9 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -279,21 +279,6 @@ extern boolean printToWebJSON; struct RTC_cache_handler_struct; - -/*********************************************************************************************\ - * rulesTimerStruct -\*********************************************************************************************/ -struct rulesTimerStatus -{ - rulesTimerStatus() : timestamp(0), interval(0), paused(false) {} - - unsigned long timestamp; - unsigned int interval; //interval in milliseconds - bool paused; -}; - -extern rulesTimerStatus RulesTimer[RULES_TIMER_MAX]; - extern msecTimerHandlerStruct msecTimerHandler; extern unsigned long timer_gratuitous_arp_interval; diff --git a/src/ESPEasyRules.ino b/src/ESPEasyRules.ino index 49baecf02..4e7c2851f 100644 --- a/src/ESPEasyRules.ino +++ b/src/ESPEasyRules.ino @@ -1053,29 +1053,6 @@ bool conditionMatch(const String& check) { return result; } -/********************************************************************************************\ - Check rule timers - \*********************************************************************************************/ -void rulesTimers() { - if (!Settings.UseRules) { - return; - } - // FIXME TD-er: Maybe not use the timer struct, but add the timers to the scheduler? - - for (byte x = 0; x < RULES_TIMER_MAX; x++) { - if (!RulesTimer[x].paused && (RulesTimer[x].timestamp != 0L)) // timer active? - { - if (timeOutReached(RulesTimer[x].timestamp)) // timer finished? - { - RulesTimer[x].timestamp = 0L; // turn off this timer - String event = F("Rules#Timer="); - event += x + 1; - rulesProcessing(event); // TD-er: Do not add to the eventQueue, but execute right now. - } - } - } -} - /********************************************************************************************\ Generate rule events based on task refresh \*********************************************************************************************/ diff --git a/src/ESPEasy_fdwdecl.h b/src/ESPEasy_fdwdecl.h index 22d1b84e9..ae60d095c 100644 --- a/src/ESPEasy_fdwdecl.h +++ b/src/ESPEasy_fdwdecl.h @@ -161,7 +161,6 @@ uint32_t createKey(uint16_t pluginNumber, uint16_t portNumber); void sendGratuitousARP(); bool processNextEvent(); -void rulesTimers(); void delayedReboot(int rebootDelay); void sendSysInfoUDP(byte repeats); void refreshNodeList(); diff --git a/src/src/Commands/Timer.cpp b/src/src/Commands/Timer.cpp index f44b98c34..d397610ae 100644 --- a/src/src/Commands/Timer.cpp +++ b/src/src/Commands/Timer.cpp @@ -7,87 +7,48 @@ #include "../../ESPEasy-Globals.h" #include "../Helpers/ESPEasy_time_calc.h" +#include "../Helpers/Scheduler.h" String Command_Timer_Set(struct EventStruct *event, const char *Line) { - if ((event->Par1 >= 1) && (event->Par1 <= RULES_TIMER_MAX)) + if (event->Par2 >= 0) { - int timerId = event->Par1 - 1; - - if (event->Par2 > 0) - { - // start new timer - RulesTimer[timerId].interval = event->Par2 * 1000; - RulesTimer[timerId].paused = false; - RulesTimer[timerId].timestamp = millis() + (1000 * event->Par2); + // start new timer when interval > 0 + // Clear timer when interval == 0 + if (setRulesTimer( + event->Par2 * 1000, // interval + event->Par1, // timer index + false // isRecurring + )) + { + return return_command_success(); } - else - { - // disable existing timer - RulesTimer[timerId].interval = 0; - RulesTimer[timerId].paused = false; - RulesTimer[timerId].timestamp = 0L; - } - return return_command_success(); + } else { + addLog(LOG_LEVEL_ERROR, F("TIMER: time must be positive")); } - addLog(LOG_LEVEL_ERROR, F("TIMER: invalid timer number")); return return_command_failed(); } String Command_Timer_Pause(struct EventStruct *event, const char *Line) { - if ((event->Par1 >= 1) && (event->Par1 <= RULES_TIMER_MAX)) - { - int timerId = event->Par1 - 1; - - if (RulesTimer[timerId].paused == false) - { - long delta = timePassedSince(RulesTimer[timerId].timestamp); - - if ((RulesTimer[timerId].timestamp != 0L) && (delta < 0)) - { - String eventName = F("Rules#TimerPause="); - eventName += event->Par1; - rulesProcessing(eventName); // TD-er: Process right now - RulesTimer[timerId].paused = true; - RulesTimer[timerId].interval = -delta; // set remaind time - } - } - else - { - addLog(LOG_LEVEL_INFO, F("TIMER: already paused")); - } + if (pause_rules_timer(event->Par1)) { + String eventName = F("Rules#TimerPause="); + eventName += event->Par1; + rulesProcessing(eventName); // TD-er: Process right now return return_command_success(); } - addLog(LOG_LEVEL_ERROR, F("TIMER: invalid timer number")); return return_command_failed(); } String Command_Timer_Resume(struct EventStruct *event, const char *Line) { - if ((event->Par1 >= 1) && (event->Par1 <= RULES_TIMER_MAX)) - { - int timerId = event->Par1 - 1; - - if (RulesTimer[timerId].paused == true) - { - if ((RulesTimer[timerId].interval > 0) && (RulesTimer[timerId].timestamp != 0L)) - { - String eventName = F("Rules#TimerResume="); - eventName += event->Par1; - rulesProcessing(eventName); // TD-er: Process right now - RulesTimer[timerId].timestamp = millis() + (RulesTimer[timerId].interval); - RulesTimer[timerId].paused = false; - } - } - else - { - addLog(LOG_LEVEL_INFO, F("TIMER: already resumed")); - } + if (resume_rules_timer(event->Par1)) { + String eventName = F("Rules#TimerResume="); + eventName += event->Par1; + rulesProcessing(eventName); // TD-er: Process right now return return_command_success(); } - addLog(LOG_LEVEL_ERROR, F("TIMER: invalid timer number")); return return_command_failed(); } diff --git a/src/src/DataStructs/ESPEasyLimits.h b/src/src/DataStructs/ESPEasyLimits.h index 49436ca6a..c78843c28 100644 --- a/src/src/DataStructs/ESPEasyLimits.h +++ b/src/src/DataStructs/ESPEasyLimits.h @@ -102,7 +102,7 @@ // *********************************************************************** #ifndef RULES_TIMER_MAX - #define RULES_TIMER_MAX 8 + #define RULES_TIMER_MAX 256 #endif //#ifndef PINSTATE_TABLE_MAX //#define PINSTATE_TABLE_MAX 32 diff --git a/src/src/Helpers/ESPEasy_checks.cpp b/src/src/Helpers/ESPEasy_checks.cpp index a2f7982c9..6ca5df9a5 100644 --- a/src/src/Helpers/ESPEasy_checks.cpp +++ b/src/src/Helpers/ESPEasy_checks.cpp @@ -82,7 +82,6 @@ void run_compiletime_checks() { check_size(); check_size(); check_size(); - check_size(); check_size(); check_size(); check_size(); diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index a49a5fc48..b2ea40d5a 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -139,9 +139,6 @@ void runOncePerSecond() PluginCall(PLUGIN_ONCE_A_SECOND, 0, dummy); // unsigned long elapsed = micros() - start; - if (Settings.UseRules) - rulesTimers(); - if (SecuritySettings.Password[0] != 0) { diff --git a/src/src/Helpers/Scheduler.cpp b/src/src/Helpers/Scheduler.cpp index bb88b82ee..46981418c 100644 --- a/src/src/Helpers/Scheduler.cpp +++ b/src/src/Helpers/Scheduler.cpp @@ -23,7 +23,7 @@ #include "../../ESPEasy_plugindefs.h" #include "../../ESPEasy-Globals.h" -#define TIMER_ID_SHIFT 28 +#define TIMER_ID_SHIFT 28 // Must be decreased as soon as timers below reach 15 #define SYSTEM_EVENT_QUEUE 0 // Not really a timer. #define CONST_INTERVAL_TIMER 1 @@ -31,6 +31,7 @@ #define TASK_DEVICE_TIMER 3 #define GPIO_TIMER 4 #define PLUGIN_TIMER 5 +#define RULES_TIMER 6 @@ -83,6 +84,9 @@ String decodeSchedulerId(unsigned long mixed_id) { case GPIO_TIMER: result = F("GPIO"); break; + case RULES_TIMER: + result = F("Rules"); + break; } result += F(" timer, id: "); result += String(id); @@ -133,6 +137,9 @@ void handle_schedule() { case PLUGIN_TIMER: process_plugin_timer(id); break; + case RULES_TIMER: + process_rules_timer(id, timer); + break; case TASK_DEVICE_TIMER: process_task_device_timer(id, timer); break; @@ -450,6 +457,124 @@ void process_plugin_task_timer(unsigned long id) { STOP_TIMER(PROC_SYS_TIMER); } +/*********************************************************************************************\ +* Rules Timer +\*********************************************************************************************/ + +unsigned long createRulesTimerId(unsigned int timerIndex) { + const unsigned long mask = (1 << TIMER_ID_SHIFT) - 1; + const unsigned long mixed = timerIndex; + + return mixed & mask; +} + +bool checkRulesTimerIndex(unsigned int timerIndex) { + if (timerIndex > RULES_TIMER_MAX || timerIndex == 0) { + if (loglevelActiveFor(LOG_LEVEL_ERROR)) { + String log = F("TIMER: invalid timer number "); + log += timerIndex; + addLog(LOG_LEVEL_ERROR, log); + } + return false; + } + return true; +} + + +bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, bool isRecurring) { + if (!checkRulesTimerIndex(timerIndex)) return false; + + const unsigned long timerId = createRulesTimerId(timerIndex); + systemTimerStruct timer_data; + + timer_data.Par1 = isRecurring ? 1 : 0; + timer_data.Par2 = msecFromNow; // The interval + timer_data.Par3 = timerIndex; + timer_data.Par4 = 0; // msec till end when paused + timer_data.Par5 = 1; // Should be executed + + if (msecFromNow == 0) { + // Create a new timer which should be "scheduled" now to clear up any data + timer_data.Par1 = 0; // Do not reschedule + timer_data.Par5 = 0; // Do not execute + addLog(LOG_LEVEL_INFO, F("TIMER: disable timer")) + } + + systemTimers[timerId] = timer_data; + setTimer(RULES_TIMER, timerId, msecFromNow); + return true; +} + +void process_rules_timer(unsigned long id, unsigned long lasttimer) { + // Create a deep copy of the timer data as we may delete it from the map before sending the event. + const systemTimerStruct timer_data = systemTimers[id]; + + if (timer_data.Par4 != 0) { + // Timer is paused. + // Must keep this timer 'active' in the scheduler. + // Look for its state every second. + setNewTimerAt(id, millis() + 1000); + return; + } + + // Reschedule before sending the event, as it may get rescheduled in handling the timer event. + if (timer_data.Par1 == 1) { + // Recurring timer + unsigned long timer = lasttimer; + const unsigned long interval = timer_data.Par2; + setNextTimeInterval(timer, interval); + setNewTimerAt(getMixedId(RULES_TIMER, id), timer); + } else { + systemTimers.erase(id); + } + + if (timer_data.Par5 == 1) { + // Should be executed + if (Settings.UseRules) { + String event = F("Rules#Timer="); + event += timer_data.Par3; + rulesProcessing(event); // TD-er: Do not add to the eventQueue, but execute right now. + } + } +} + +bool pause_rules_timer(unsigned long timerIndex) { + if (!checkRulesTimerIndex(timerIndex)) return false; + const unsigned long timerId = createRulesTimerId(timerIndex); + unsigned long timer; + + if (msecTimerHandler.getTimerForId(timerId, timer)) { + if (systemTimers[timerId].Par4 == 0) { + // Store remainder of interval + const long timeLeft = timePassedSince(timer) * -1; + if (timeLeft > 0) { + systemTimers[timerId].Par4 = timeLeft; + return true; + } + } else { + addLog(LOG_LEVEL_INFO, F("TIMER: already paused")); + } + } + return false; +} + +bool resume_rules_timer(unsigned long timerIndex) { + if (!checkRulesTimerIndex(timerIndex)) return false; + const unsigned long timerId = createRulesTimerId(timerIndex); + unsigned long timer; + + if (msecTimerHandler.getTimerForId(timerId, timer)) { + if (systemTimers[timerId].Par4 != 0) { + // Reschedule timer with remainder of interval + setNewTimerAt(timerId, millis() + systemTimers[timerId].Par4); + systemTimers[timerId].Par4 = 0; + return true; + } + } + return false; +} + + /*********************************************************************************************\ * Plugin Timer \*********************************************************************************************/ diff --git a/src/src/Helpers/Scheduler.h b/src/src/Helpers/Scheduler.h index 82b0181e0..604403f16 100644 --- a/src/src/Helpers/Scheduler.h +++ b/src/src/Helpers/Scheduler.h @@ -60,6 +60,22 @@ void setPluginTaskTimer(unsigned long msecFromNow, taskIndex_t taskIndex, int Pa void process_plugin_task_timer(unsigned long id); + +/*********************************************************************************************\ +* Rules Timer +\*********************************************************************************************/ + +unsigned long createRulesTimerId(unsigned int timerIndex); + +bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, bool isRecurring); + +void process_rules_timer(unsigned long id, unsigned long lasttimer); + +bool pause_rules_timer(unsigned long timerIndex); + +bool resume_rules_timer(unsigned long timerIndex); + + /*********************************************************************************************\ * Plugin Timer \*********************************************************************************************/ @@ -76,6 +92,7 @@ void setPluginTimer(unsigned long msecFromNow, pluginID_t pluginID, int Par1, in void process_plugin_timer(unsigned long id); + /*********************************************************************************************\ * GPIO Timer * Special timer to handle timed GPIO actions diff --git a/src/src/Helpers/msecTimerHandlerStruct.cpp b/src/src/Helpers/msecTimerHandlerStruct.cpp index 31a86a9c2..d1b889b86 100644 --- a/src/src/Helpers/msecTimerHandlerStruct.cpp +++ b/src/src/Helpers/msecTimerHandlerStruct.cpp @@ -67,10 +67,15 @@ } - - - - + bool msecTimerHandlerStruct::getTimerForId(unsigned long id, unsigned long& timer) const { + for (auto it = _timer_ids.begin(); it != _timer_ids.end(); ++it) { + if (it->_id == id) { + timer = it->_timer; + return true; + } + } + return false; + } String msecTimerHandlerStruct::getQueueStats() { String result; diff --git a/src/src/Helpers/msecTimerHandlerStruct.h b/src/src/Helpers/msecTimerHandlerStruct.h index 77ba02a08..0fffa7ed9 100644 --- a/src/src/Helpers/msecTimerHandlerStruct.h +++ b/src/src/Helpers/msecTimerHandlerStruct.h @@ -19,6 +19,9 @@ struct msecTimerHandlerStruct { // Return 0 if no item has reached timeout moment. unsigned long getNextId(unsigned long& timer); + // Check if a give ID is scheduled and if so, return the set timer. + bool getTimerForId(unsigned long id, unsigned long& timer) const; + String getQueueStats(); void updateIdleTimeStats(); From 1184339cfca2a03df8c73771dc6b216e00b3455c Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Sun, 9 Aug 2020 16:04:17 +0200 Subject: [PATCH 06/47] [Timers] Make loop timers with fixed interval and nr of loops --- src/src/Commands/InternalCommands.cpp | 14 ++-- src/src/Commands/Timer.cpp | 66 +++++++++++++---- src/src/Commands/Timer.h | 3 + src/src/Globals/SystemTimers.h | 2 + src/src/Helpers/Scheduler.cpp | 93 +++++++++++++++--------- src/src/Helpers/Scheduler.h | 8 +- src/src/Helpers/msecTimerHandlerStruct.h | 1 + 7 files changed, 130 insertions(+), 57 deletions(-) diff --git a/src/src/Commands/InternalCommands.cpp b/src/src/Commands/InternalCommands.cpp index c040540f4..6959b0fca 100644 --- a/src/src/Commands/InternalCommands.cpp +++ b/src/src/Commands/InternalCommands.cpp @@ -206,9 +206,12 @@ bool executeInternalCommand(const char *cmd, struct EventStruct *event, const ch break; } case 'l': { - COMMAND_CASE( "let", Command_Rules_Let, 2); // Rules.h - COMMAND_CASE( "load", Command_Settings_Load, 0); // Settings.h - COMMAND_CASE( "logentry", Command_logentry, 1); // Diagnostic.h + COMMAND_CASE( "let", Command_Rules_Let, 2); // Rules.h + COMMAND_CASE( "load", Command_Settings_Load, 0); // Settings.h + COMMAND_CASE( "logentry", Command_logentry, 1); // Diagnostic.h + COMMAND_CASE( "looptimerset", Command_Loop_Timer_Set, 3); // Timers.h + COMMAND_CASE("looptimerset_ms", Command_Loop_Timer_Set_ms, 3); // Timers.h + #ifndef BUILD_NO_DIAGNOSTIC_COMMANDS COMMAND_CASE("logportstatus", Command_logPortStatus, 0); // Diagnostic.h COMMAND_CASE( "lowmem", Command_Lowmem, 0); // Diagnostic.h @@ -284,6 +287,7 @@ bool executeInternalCommand(const char *cmd, struct EventStruct *event, const ch COMMAND_CASE( "timerpause", Command_Timer_Pause, 1); // Timers.h COMMAND_CASE( "timerresume", Command_Timer_Resume, 1); // Timers.h COMMAND_CASE( "timerset", Command_Timer_Set, 2); // Timers.h + COMMAND_CASE( "timerset_ms", Command_Timer_Set_ms, 2); // Timers.h COMMAND_CASE( "timezone", Command_TimeZone, 1); // Time.h } break; @@ -404,10 +408,10 @@ bool ExecuteCommand(taskIndex_t taskIndex, EventValueSource::Enum source, const // Maybe ExecuteCommand can be scheduled? delay(0); - if (loglevelActiveFor(LOG_LEVEL_INFO)) { + if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { String log = F("Command: "); log += cmd; - addLog( LOG_LEVEL_INFO, log); + addLog(LOG_LEVEL_DEBUG, log); #ifndef BUILD_NO_DEBUG addLog(LOG_LEVEL_DEBUG, Line); // for debug purposes add the whole line. String parameters; diff --git a/src/src/Commands/Timer.cpp b/src/src/Commands/Timer.cpp index d397610ae..4e8488794 100644 --- a/src/src/Commands/Timer.cpp +++ b/src/src/Commands/Timer.cpp @@ -9,27 +9,67 @@ #include "../Helpers/ESPEasy_time_calc.h" #include "../Helpers/Scheduler.h" - -String Command_Timer_Set(struct EventStruct *event, const char *Line) -{ - if (event->Par2 >= 0) +String command_setRulesTimer(int msecFromNow, int timerIndex, int recurringCount) { + if (msecFromNow < 0) { - // start new timer when interval > 0 - // Clear timer when interval == 0 - if (setRulesTimer( - event->Par2 * 1000, // interval - event->Par1, // timer index - false // isRecurring - )) + addLog(LOG_LEVEL_ERROR, F("TIMER: time must be positive")); + } else { + // start new timer when msecFromNow > 0 + // Clear timer when msecFromNow == 0 + if (setRulesTimer(msecFromNow, timerIndex, recurringCount)) { return return_command_success(); } - } else { - addLog(LOG_LEVEL_ERROR, F("TIMER: time must be positive")); } return return_command_failed(); } +String Command_Timer_Set(struct EventStruct *event, const char *Line) +{ + return command_setRulesTimer( + event->Par2 * 1000, // msec from now + event->Par1, // timer index + 0 // recurringCount + ); +} + +String Command_Timer_Set_ms (struct EventStruct *event, const char* Line) +{ + return command_setRulesTimer( + event->Par2, // interval + event->Par1, // timer index + 0 // recurringCount + ); +} + +String Command_Loop_Timer_Set (struct EventStruct *event, const char* Line) +{ + int recurringCount = event->Par3; + if (recurringCount == 0) { + // if the optional 3rd parameter is not given, set it to "run always" + recurringCount = -1; + } + return command_setRulesTimer( + event->Par2 * 1000, // msec from now + event->Par1, // timer index + recurringCount + ); +} + +String Command_Loop_Timer_Set_ms (struct EventStruct *event, const char* Line) +{ + int recurringCount = event->Par3; + if (recurringCount == 0) { + // if the optional 3rd parameter is not given, set it to "run always" + recurringCount = -1; + } + return command_setRulesTimer( + event->Par2, // interval + event->Par1, // timer index + recurringCount + ); +} + String Command_Timer_Pause(struct EventStruct *event, const char *Line) { if (pause_rules_timer(event->Par1)) { diff --git a/src/src/Commands/Timer.h b/src/src/Commands/Timer.h index faa13e5a7..abeaea753 100644 --- a/src/src/Commands/Timer.h +++ b/src/src/Commands/Timer.h @@ -4,6 +4,9 @@ class String; String Command_Timer_Set (struct EventStruct *event, const char* Line); +String Command_Timer_Set_ms (struct EventStruct *event, const char* Line); +String Command_Loop_Timer_Set (struct EventStruct *event, const char* Line); +String Command_Loop_Timer_Set_ms (struct EventStruct *event, const char* Line); String Command_Timer_Pause (struct EventStruct *event, const char* Line); String Command_Timer_Resume (struct EventStruct *event, const char* Line); String Command_Delay (struct EventStruct *event, const char* Line); diff --git a/src/src/Globals/SystemTimers.h b/src/src/Globals/SystemTimers.h index 1e2cf82a2..cf7dfbddb 100644 --- a/src/src/Globals/SystemTimers.h +++ b/src/src/Globals/SystemTimers.h @@ -5,6 +5,8 @@ #include +// Map mixed timer ID to system timer struct. +// N.B. Must use Mixed timer ID, similar to how it is handled in the scheduler. extern std::map systemTimers; #endif // GLOBALS_SYSTEMTIMERS_H \ No newline at end of file diff --git a/src/src/Helpers/Scheduler.cpp b/src/src/Helpers/Scheduler.cpp index 46981418c..c740a7d56 100644 --- a/src/src/Helpers/Scheduler.cpp +++ b/src/src/Helpers/Scheduler.cpp @@ -38,10 +38,6 @@ /*********************************************************************************************\ * Generic Timer functions. \*********************************************************************************************/ -void setTimer(unsigned long timerType, unsigned long id, unsigned long msecFromNow) { - setNewTimerAt(getMixedId(timerType, id), millis() + msecFromNow); -} - void setNewTimerAt(unsigned long id, unsigned long timer) { START_TIMER; msecTimerHandler.registerAt(id, timer); @@ -409,7 +405,8 @@ void setPluginTaskTimer(unsigned long msecFromNow, taskIndex_t taskIndex, int Pa const deviceIndex_t deviceIndex = getDeviceIndex_from_TaskIndex(taskIndex); if (!validDeviceIndex(deviceIndex)) return; - const unsigned long systemTimerId = createPluginTaskTimerId(deviceIndex, Par1); + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, createPluginTaskTimerId(deviceIndex, Par1)); + systemTimerStruct timer_data; timer_data.TaskIndex = taskIndex; @@ -418,13 +415,15 @@ void setPluginTaskTimer(unsigned long msecFromNow, taskIndex_t taskIndex, int Pa timer_data.Par3 = Par3; timer_data.Par4 = Par4; timer_data.Par5 = Par5; - systemTimers[systemTimerId] = timer_data; - setTimer(PLUGIN_TASK_TIMER, systemTimerId, msecFromNow); + systemTimers[mixedTimerId] = timer_data; + setNewTimerAt(mixedTimerId, millis() + msecFromNow); } void process_plugin_task_timer(unsigned long id) { START_TIMER; - const systemTimerStruct timer_data = systemTimers[id]; + + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, id); + const systemTimerStruct timer_data = systemTimers[mixedTimerId]; struct EventStruct TempEvent; TempEvent.TaskIndex = timer_data.TaskIndex; TempEvent.BaseVarIndex = timer_data.TaskIndex * VARS_PER_TASK; @@ -447,7 +446,7 @@ void process_plugin_task_timer(unsigned long id) { log += id; addLog(LOG_LEVEL_INFO, log); */ - systemTimers.erase(id); + systemTimers.erase(mixedTimerId); if (validDeviceIndex(deviceIndex) && validUserVarIndex(TempEvent.BaseVarIndex)) { TempEvent.sensorType = Device[deviceIndex].VType; @@ -481,17 +480,22 @@ bool checkRulesTimerIndex(unsigned int timerIndex) { } -bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, bool isRecurring) { +bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, int recurringCount) { if (!checkRulesTimerIndex(timerIndex)) return false; - const unsigned long timerId = createRulesTimerId(timerIndex); + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, createRulesTimerId(timerIndex)); systemTimerStruct timer_data; - timer_data.Par1 = isRecurring ? 1 : 0; + timer_data.Par1 = recurringCount; timer_data.Par2 = msecFromNow; // The interval timer_data.Par3 = timerIndex; timer_data.Par4 = 0; // msec till end when paused - timer_data.Par5 = 1; // Should be executed + timer_data.Par5 = 1; // Execute when > 0, doubles also as counter for loops + + if (recurringCount > 0) { + // Will run with Par1 == 0, so must subtract one when setting the value. + timer_data.Par1--; + } if (msecFromNow == 0) { // Create a new timer which should be "scheduled" now to clear up any data @@ -500,39 +504,51 @@ bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, bool isRe addLog(LOG_LEVEL_INFO, F("TIMER: disable timer")) } - systemTimers[timerId] = timer_data; - setTimer(RULES_TIMER, timerId, msecFromNow); + systemTimers[mixedTimerId] = timer_data; + setNewTimerAt(mixedTimerId, millis() + msecFromNow); return true; } void process_rules_timer(unsigned long id, unsigned long lasttimer) { // Create a deep copy of the timer data as we may delete it from the map before sending the event. - const systemTimerStruct timer_data = systemTimers[id]; + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, id); + const systemTimerStruct timer_data = systemTimers[mixedTimerId]; if (timer_data.Par4 != 0) { // Timer is paused. // Must keep this timer 'active' in the scheduler. // Look for its state every second. - setNewTimerAt(id, millis() + 1000); + setNewTimerAt(mixedTimerId, millis() + 1000); return; } // Reschedule before sending the event, as it may get rescheduled in handling the timer event. - if (timer_data.Par1 == 1) { + if (timer_data.Par1 != 0) { // Recurring timer unsigned long timer = lasttimer; const unsigned long interval = timer_data.Par2; setNextTimeInterval(timer, interval); - setNewTimerAt(getMixedId(RULES_TIMER, id), timer); + setNewTimerAt(mixedTimerId, timer); + if (timer_data.Par1 > 0) { + // This is a timer with a limited number of runs, so decrease its value. + systemTimers[mixedTimerId].Par1--; + } + if (timer_data.Par5 > 0) { + // This one should be executed, so increase the count. + systemTimers[mixedTimerId].Par5++; + } } else { - systemTimers.erase(id); + systemTimers.erase(mixedTimerId); } - if (timer_data.Par5 == 1) { + if (timer_data.Par5 > 0) { // Should be executed if (Settings.UseRules) { String event = F("Rules#Timer="); event += timer_data.Par3; + // Add count as 2nd eventvalue + event += ','; + event += timer_data.Par5; rulesProcessing(event); // TD-er: Do not add to the eventQueue, but execute right now. } } @@ -540,36 +556,40 @@ void process_rules_timer(unsigned long id, unsigned long lasttimer) { bool pause_rules_timer(unsigned long timerIndex) { if (!checkRulesTimerIndex(timerIndex)) return false; - const unsigned long timerId = createRulesTimerId(timerIndex); + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, createRulesTimerId(timerIndex)); unsigned long timer; - if (msecTimerHandler.getTimerForId(timerId, timer)) { - if (systemTimers[timerId].Par4 == 0) { + if (msecTimerHandler.getTimerForId(mixedTimerId, timer)) { + if (systemTimers[mixedTimerId].Par4 == 0) { // Store remainder of interval const long timeLeft = timePassedSince(timer) * -1; if (timeLeft > 0) { - systemTimers[timerId].Par4 = timeLeft; + systemTimers[mixedTimerId].Par4 = timeLeft; return true; } } else { addLog(LOG_LEVEL_INFO, F("TIMER: already paused")); } + } else { + addLog(LOG_LEVEL_ERROR, F("TIMER: No existing timer")); } return false; } bool resume_rules_timer(unsigned long timerIndex) { if (!checkRulesTimerIndex(timerIndex)) return false; - const unsigned long timerId = createRulesTimerId(timerIndex); + const unsigned long mixedTimerId = getMixedId(RULES_TIMER, createRulesTimerId(timerIndex)); unsigned long timer; - if (msecTimerHandler.getTimerForId(timerId, timer)) { - if (systemTimers[timerId].Par4 != 0) { + if (msecTimerHandler.getTimerForId(mixedTimerId, timer)) { + if (systemTimers[mixedTimerId].Par4 != 0) { // Reschedule timer with remainder of interval - setNewTimerAt(timerId, millis() + systemTimers[timerId].Par4); - systemTimers[timerId].Par4 = 0; + setNewTimerAt(mixedTimerId, millis() + systemTimers[mixedTimerId].Par4); + systemTimers[mixedTimerId].Par4 = 0; return true; } + } else { + addLog(LOG_LEVEL_ERROR, F("TIMER: No existing timer")); } return false; } @@ -599,7 +619,7 @@ void setPluginTimer(unsigned long msecFromNow, pluginID_t pluginID, int Par1, in const deviceIndex_t deviceIndex = getDeviceIndex(pluginID); if (!validDeviceIndex(deviceIndex)) return; - const unsigned long systemTimerId = createPluginTimerId(deviceIndex, Par1); + const unsigned long mixedTimerId = getMixedId(PLUGIN_TIMER, createPluginTimerId(deviceIndex, Par1)); systemTimerStruct timer_data; //timer_data.TaskIndex = deviceIndex; @@ -608,13 +628,14 @@ void setPluginTimer(unsigned long msecFromNow, pluginID_t pluginID, int Par1, in timer_data.Par3 = Par3; timer_data.Par4 = Par4; timer_data.Par5 = Par5; - systemTimers[systemTimerId] = timer_data; - setTimer(PLUGIN_TIMER, systemTimerId, msecFromNow); + systemTimers[mixedTimerId] = timer_data; + setNewTimerAt(mixedTimerId, millis() + msecFromNow); } void process_plugin_timer(unsigned long id) { START_TIMER; - const systemTimerStruct timer_data = systemTimers[id]; + const unsigned long mixedTimerId = getMixedId(PLUGIN_TIMER, id); + const systemTimerStruct timer_data = systemTimers[mixedTimerId]; struct EventStruct TempEvent; // TempEvent.TaskIndex = timer_data.TaskIndex; @@ -640,7 +661,7 @@ void process_plugin_timer(unsigned long id) { log += id; addLog(LOG_LEVEL_INFO, log); */ - systemTimers.erase(id); + systemTimers.erase(mixedTimerId); if (validDeviceIndex(deviceIndex)) { String dummy; @@ -665,7 +686,7 @@ void setGPIOTimer(unsigned long msecFromNow, int Par1, int Par2, int Par3, int P // Par1 & Par2 form a unique key const unsigned long systemTimerId = createGPIOTimerId(Par1, Par2); - setTimer(GPIO_TIMER, systemTimerId, msecFromNow); + setNewTimerAt(getMixedId(GPIO_TIMER, systemTimerId), millis() + msecFromNow); } void process_gpio_timer(unsigned long id) { diff --git a/src/src/Helpers/Scheduler.h b/src/src/Helpers/Scheduler.h index 604403f16..6409d1ebb 100644 --- a/src/src/Helpers/Scheduler.h +++ b/src/src/Helpers/Scheduler.h @@ -9,8 +9,6 @@ /*********************************************************************************************\ * Generic Timer functions. \*********************************************************************************************/ -void setTimer(unsigned long timerType, unsigned long id, unsigned long msecFromNow); - void setNewTimerAt(unsigned long id, unsigned long timer); // Mix timer type int with an ID describing the scheduled job. @@ -67,7 +65,11 @@ void process_plugin_task_timer(unsigned long id); unsigned long createRulesTimerId(unsigned int timerIndex); -bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, bool isRecurring); +// Set timer for Rules#Timer events. +// @param msecFromNow Number of milli seconds from now (also used as interval for recurring) +// @param timerIndex The index of the timer used. (1 ... max) +// @param recurringCount Number of times needed to run (-1 for always) +bool setRulesTimer(unsigned long msecFromNow, unsigned int timerIndex, int recurringCount = 0); void process_rules_timer(unsigned long id, unsigned long lasttimer); diff --git a/src/src/Helpers/msecTimerHandlerStruct.h b/src/src/Helpers/msecTimerHandlerStruct.h index 0fffa7ed9..718f5ce03 100644 --- a/src/src/Helpers/msecTimerHandlerStruct.h +++ b/src/src/Helpers/msecTimerHandlerStruct.h @@ -20,6 +20,7 @@ struct msecTimerHandlerStruct { unsigned long getNextId(unsigned long& timer); // Check if a give ID is scheduled and if so, return the set timer. + // N.B. the ID is the mixed ID. bool getTimerForId(unsigned long id, unsigned long& timer) const; String getQueueStats(); From 53f161df050e976d36ac532da48b2f1e17b346ae Mon Sep 17 00:00:00 2001 From: Gijs Noorlander Date: Sun, 9 Aug 2020 17:10:03 +0200 Subject: [PATCH 07/47] [Docs] Add documentation for msec timers and loop timers --- docs/source/Plugin/P000_commands.repl | 43 ++++++++++++++++++++-- docs/source/Rules/Rules.rst | 51 ++++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/docs/source/Plugin/P000_commands.repl b/docs/source/Plugin/P000_commands.repl index 55c49e498..38cb6562f 100644 --- a/docs/source/Plugin/P000_commands.repl +++ b/docs/source/Plugin/P000_commands.repl @@ -201,6 +201,37 @@ ``LogEntry,``" " + LoopTimerSet + + LoopTimerSet_ms"," + :green:`Rules`"," + Start a sequence of timed events + + * ``LoopTimerSet,,`` + * ``LoopTimerSet_ms,,