logo elektroda
logo elektroda
X
logo elektroda

Error in Rule1 syntax for Tasmot on ESP8266 - correct configuration

opaaa 2931 13
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 20681192
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    I just wrote such a role for Tasmot on the ESP8266
    20:53:15.897 CMD: Rule1 ON Time 20:54 DO POWER0 0 ENDON
    20:53:15.902 RUL: Stored uncompressed, would compress from 31 to 30 (-4%)
    20:53:15.905 RSL: RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":31,"Free":480,"Rules":"ON Time 20:54 DO POWER0 0 ENDON"}}

    But it doesn't work. Why? What did I write wrong

    The GPIO0 output is configured as a relay but I also tried as an LED.
  • ADVERTISEMENT
  • #2 20681331
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14494
    Help: 651
    Rate: 12505
    Hello, where did you get this piece of writing:
    
    ON Time 20:54
    

    In Tasmota's documentation I only see:
    Screenshot of a table listing different time triggers in the Time# format, with Time#Minute241 highlighted in a red box.
    https://tasmota.github.io/docs/Rules/#rule-trigger
    By the way:
    https://github.com/tasmota/docs-7.1/blob/mast...a-luminance-triggered-switch-only-in-mornings
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20681367
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    p.kaczmarek2 wrote:
    Hello, where did you get this bit of notation:
    
    ON Time 20:54
    
    In Tasmota's documentation I only see the following:
    Screenshot of a table listing different time triggers in the Time# format, with Time#Minute241 highlighted in a red box. https://tasmota.github.io/docs/Rules/#rule-trigger
    By the way:
    https://github.com/tasmota/docs-7.1/blob/mast...a-luminance-triggered-switch-only-in-mornings

    If you mean a record of this type
    Rule1 ON Time#Minute=1379 DO POWER0 0 ENDON
    this does not work.
  • ADVERTISEMENT
  • #5 20681548
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    I connected the diode under GPIO15 D8 configured the output as Relay. I wrote this way
    Rule1 ON Time#Minute=524 DO POWER15 1 ENDON
    I checked the time zone that is set in the ESP of course +1 hour and it still doesn't work.
  • ADVERTISEMENT
  • #6 20681559
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14494
    Help: 651
    Rate: 12505
    What is POWER15 ? Are you trying to get to GPIO15 in this way? This is not how it works. POWER is not supposed to have a GPIO index, only a slot, channel index.

    So as you have:
    Screenshot of Tasmota configuration showing pin (GPIO) assignments to specific functions on a Generic module.
    This relay:
    Screenshot of Tasmota configuration with the D2 GPIO4 field highlighted, set as Relay with index 3.
    This is POWER3 (because it is assigned number 3) and not POWER4 (because GPIO4)

    Do a dry test - turn on the Tasmota console and enter your POWER15 TOGGLE and see if it works:
    Helpful post? Buy me a coffee.
  • #7 20681641
    opaaa
    Level 4  
    Posts: 282
    Rate: 32

    @p.kaczmarek2 you are right. Since I have as in the attached screenshot I should use POWER1. And in the console POWER1 1 works fine, while such a rule
    Rule2 ON Time#Minute=610 DO POWER1 1 ENDON
    does not work. Even after typing .
    Attachments:
    • Error in Rule1 syntax for Tasmot on ESP8266 - correct configuration tasmota.png (35.85 KB) You must be logged in to download this attachment.
  • Helpful post
    #8 20681666
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14494
    Help: 651
    Rate: 12505
    Checked. With me it works:
    Screenshot of Tasmota console logs showing time settings, rule configuration, and failed MQTT connection attempts.
    Log as text:
    
    09:31:10.552 CMD: Time
    09:31:10.557 RSL: RESULT = {"Time":"2023-08-05T09:31:10"}
    09:31:55.575 CMD: Rule1 ON Time#Minute=574 DO POWER OFF ENDON
    09:31:55.581 RUL: Stored uncompressed, would compress from 37 to 35 (-6%)
    09:31:55.584 RSL: RESULT = {"Rule1":{"State":"OFF","Once":"OFF","StopOnError":"OFF","Length":37,"Free":474,"Rules":"ON Time#Minute=574 DO POWER OFF ENDON"}}
    09:32:00.587 CMD: Rule1 1
    09:32:00.593 RSL: RESULT = {"Rule1":{"State":"ON","Once":"OFF","StopOnError":"OFF","Length":37,"Free":474,"Rules":"ON Time#Minute=574 DO POWER OFF ENDON"}}
    09:33:01.373 MQT: Attempting connection...
    09:33:01.601 MQT: Connect failed to wwqewqeqw:1883, rc -2. Retry in 120 sec
    09:33:50.086 RSL: STATE = {"Time":"2023-08-05T09:33:50","Uptime":"22T19:41:14","UptimeSec":1971674,"Heap":25,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount":0,"POWER1":"ON","POWER2":"OFF","POWER3":"ON","Wifi":{"AP":1,"SSId":"MY_WIFI_SSID","BSSId":"28:87:BA:A0:F5:6D","Channel":1,"Mode":"11n","RSSI":74,"Signal":-63,"LinkCount":1,"Downtime":"0T00:01:02"}}
    09:34:00.044 RUL: TIME#MINUTE=574 performs "POWER OFF"
    09:34:00.051 RSL: RESULT = {"POWER1":"OFF"}
    09:34:00.053 RSL: POWER1 = OFF
    
    I will add that I previously typed Time in the console to see the time, which was offset by 1h in the case of my Tasmota. What does the command Time show in your case? Maybe you've also got that 1h offset and don't know it?

    EDIT: Those 610s look like you didn't include that 1h offset. I guess we should both configure summer/winter time correctly in our Tasmoths....
    Helpful post? Buy me a coffee.
  • #9 20681678
    raks0
    Level 31  
    Posts: 769
    Help: 254
    Rate: 446
    Maybe it doesn't work because the syntax is uppercase?
    It works without a problem
    Rule2 On Time#Minute=645 do power1 0 endon
  • #10 20681684
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    I have no idea what the issue is, I copied from you
    Rule1 ON Time#Minute=574 DO POWER OFF ENDON
    changed the minutes to the current ones and it works.
  • Helpful post
    #11 20681692
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14494
    Help: 651
    Rate: 12505
    I don't know if it's case sensitive, it's worth checking, I'd also bet that since @opaaa a previously typed 610 and it didn't work and now he's typed 574 and it's ok, that means he was typing a time that is "an hour away" so the rule would work, it would just attach later than @opaaa would expect

    Writing the command Time in the console helps because it dispels doubts about the time that Tasmota sees

    It remains then to configure the time zone correctly (in my case too):
    https://tasmota.github.io/docs/Timezone-Table/
    Screenshot from Tasmota timezone table with the Europe/Warsaw line highlighted and its configuration code visible. .
    Helpful post? Buy me a coffee.
  • #12 20681859
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    That's right, I used to set "timezone 99" but you can see something has gone awry. And is it possible to save the trigger in some more friendly form and not how many minutes have to pass from midnight for something to work?
  • #13 20681926
    raks0
    Level 31  
    Posts: 769
    Help: 254
    Rate: 446
    opaaa wrote:
    As it is possible to write the trigger in some more friendly form and not how many minutes have to pass since midnight for something to take effect?
    You could use a Timer
    Timer1 {"Enable":1,"Mode":0,"Time":"08:00","Days":"1111111","Repeat":1,"Action":3}
    Rule2 On clock#Timer=1 do power1 0 endon
    .
  • #14 20681945
    opaaa
    Level 4  
    Posts: 282
    Rate: 32
    raks0 wrote:
    opaaa wrote:
    Are you able to write the trigger in some more friendly form and not how many minutes have to pass since midnight for something to work?

    You can use a Timer
    Timer1 {"Enable":1,"Mode":0,"Time":"08:00","Days":"1111111","Repeat":1,"Action":3}
    Rule2 On clock#Timer=1 do power1 0 endon

    Well, yes, I understand, however just turning something on and off there is just indirect combining in my case. Ultimately, what I want to do is to make the PWM control in such a way that from 13:00 it starts to increase the filling smoothly in such a way that at 15:00 it reaches the maximum, i.e. 1023 (if I read it correctly on the internet). Then for a few hours the filling is 100% and then for 2 hours it decreases from 1023 to 0. If he can suggest how to go about it, I would be happy to read.

Topic summary

✨ The discussion revolves around an error in the syntax of a Tasmota rule for the ESP8266, specifically regarding the configuration of GPIO outputs for controlling a relay. Users explore various aspects of the rule syntax, including the correct use of uppercase and lowercase letters, the proper identification of GPIO pins, and the necessity of enabling the rule. The conversation highlights troubleshooting steps, such as checking the time zone settings and testing commands in the Tasmota console. Additionally, suggestions are made for using timers to achieve more complex control scenarios, such as PWM (Pulse Width Modulation) for gradual changes in output.
Generated by the language model.

FAQ

TL;DR: Most Tasmota rule misfires trace to a 1-hour offset; "Writing the command Time in the console helps." Fix syntax to ON Time#Minute=... and enable Rule1 1. For ESP8266 users fixing Rule1 scheduling and POWER channel mapping. [Elektroda, p.kaczmarek2, post #20681692]

Why it matters: Reliable time-based rules prevent missed automations and confusing behavior on ESP8266 devices running Tasmota.

Quick Facts

  • Valid time trigger: ON Time#Minute=0–1439 (e.g., 21:15 → 1275). Close with ENDON. “HH*60+MM” gives the minute-of-day. “Tasmota Rules — Rule trigger”
  • Rules are inactive until enabled. After saving, send: Rule1 1 (or Rule2 1, etc.). [Elektroda, raks0, post #20681385]
  • POWERn targets relay/channel index, not a GPIO number. A Relay on slot 3 is POWER3, not POWER4/GPIO4. [Elektroda, p.kaczmarek2, post #20681559]
  • Human-readable schedules: configure Timer1 {"Enable":1, "Time":"HH:MM"} and trigger with ON Clock#Timer=1. [Elektroda, raks0, post #20681926]
  • Set timezone/DST correctly and verify with the Time command; use the official Timezone Table. “Tasmota Timezone Table”

How do I write a correct Tasmota time-based rule?

Use minute-of-day triggers. Example: Rule1 ON Time#Minute=1275 DO Power1 Off ENDON then enable with Rule1 1. Minute-of-day runs 0–1439 (HH*60+MM). For 21:15, use 1275. Keep each ON ... ENDON block self-contained. This avoids invalid HH:MM syntax and ensures predictable triggers. You can stack multiple ON Time#Minute lines in the same rule for different times. “Tasmota Rules — Rule trigger”

Why doesn’t "ON Time 20:54 DO POWER0 0 ENDON" work?

Tasmota rules do not accept HH:MM in the ON clause. Use the minute-of-day form: ON Time#Minute=1254 DO POWER0 0 ENDON. Alternatively, use a Timer with ON Clock#Timer=1 if you prefer HH:MM configuration in JSON. Enable the rule with Rule1 1 after saving. “Tasmota Rules — Rule trigger”

Do I need to enable Rule1 after saving my rule?

Yes. Rules are stored but inactive until enabled. Send Rule1 1 to activate, Rule1 0 to deactivate, and Rule1 to view state. If your syntax and time are correct but nothing happens, enabling the rule is often the missing step. [Elektroda, raks0, post #20681385]

Why did POWER15 not control GPIO15 on my ESP8266?

POWERn refers to the device’s power channel index, not a GPIO number. Check your template: the first relay/LED is POWER1, second POWER2, etc. Verify quickly in Console with POWER1 TOGGLE. Map channels correctly before writing rules that use POWERn. [Elektroda, p.kaczmarek2, post #20681559]

How do I check and fix the clock offset that breaks schedules?

Open Console and run Time to see the device time. If it’s off by an hour, set the proper timezone/DST, then confirm with Time again. As one expert notes, "Writing the command Time in the console helps." This eliminates the common 1‑hour slip that delays triggers. [Elektroda, p.kaczmarek2, post #20681692]

Is Tasmota rule syntax case-sensitive (ON vs On vs on)?

In practice, mixed case works for rules and commands. An example that runs: Rule2 On Time#Minute=645 do power1 0 endon. If your rule fails, focus on correct triggers and the device’s time rather than case. [Elektroda, raks0, post #20681678]

How can I schedule actions without calculating minutes since midnight?

Use Timers for human-readable scheduling. Example: Timer1 {"Enable":1,"Mode":0,"Time":"08:00","Days":"1111111","Repeat":1,"Action":3} and a rule: Rule2 On Clock#Timer=1 do Power1 0 endon. Timers integrate cleanly with rules for flexible schedules. [Elektroda, raks0, post #20681926]

How do I test a rule quickly?

Try this 3-step check:
  1. Set the rule: Rule1 ON Time#Minute= DO POWER1 TOGGLE ENDON
  2. Enable it: Rule1 1
  3. Run Time and watch Console for RUL: TIME#MINUTE logs at the target minute. [Elektroda, p.kaczmarek2, post #20681666]

What does POWER0 do in Tasmota?

POWER0 addresses all power channels on the device. POWER0 ON, OFF, or TOGGLE will affect every relay/output at once. Edge case: On multi-channel hardware, POWER0 may switch multiple loads simultaneously, which might be undesired. Use with caution. “Tasmota Commands — Power”

How can I ramp brightness from 13:00 to 15:00, hold, then fade down?

Configure the light as PWM and use Dimmer with RuleTimer. Example idea: at 13:00 start RuleTimer1 72 and ON Rules#Timer=1 DO Dimmer +1; RuleTimer1 72 ENDON to add ~1% every 72 seconds. Stop at 15:00. For a 2-hour rise, that’s 7200 seconds and ~100 steps. Later, start another timer that runs Dimmer -1 for the fade. “Tasmota Commands — Light”

My console command POWER1 1 works, but the rule never fires. Why?

Two common causes: the rule is not enabled, or the device time is wrong. Enable with Rule1 1 and verify the clock using Time. A 60-minute offset will make your rule fire at the wrong minute-of-day. Adjust timezone/DST, then retest. [Elektroda, p.kaczmarek2, post #20681666]

Can I trigger at second-level precision instead of per-minute?

Yes, use RuleTimer for second-level intervals. Example: RuleTimer1 5 and ON Rules#Timer=1 DO ; RuleTimer1 5 ENDON runs every five seconds. Time#Minute triggers are minute-based; RuleTimer provides finer granularity. “Tasmota Rules — Rule trigger”
Generated by the language model.
ADVERTISEMENT