Tasmota icon indicating copy to clipboard operation
Tasmota copied to clipboard

Script example for simple switch missing in doc

Open muchcodesuchwow opened this issue 8 months ago • 1 comments

Hello, i am trying to add a switch to a esp8266 which has no rules but scripts enabled. (i also want to use SML on this esp, which requiers scripts).

The documentation is missing a simple example of a switch and i am struggeling hard to get this working. There is no real intro into the scripts. Please add a example script to read a switch, which also shows up in Home Assistant and give an easy introduction, how to get scripts working. I.e. i just discovered, that i need to write "Weblog 2" into the console, to see print output of the script after long struggle to understand the scripts.

My not working switch script is:

>D
>B
>S
switchmode 1
switchtopic 0

>E
print event happened

sw=sw[1]
if chg[sw]>0
then
  if sw==1
  then
    publish stat/%topic%/PIR1 ON
    print motion
  else
    publish stat/%topic%/PIR1 OFF
    print no motion
  endif
endif


In the doc one can find this, but this does not help me:

; check if switch changed state
sw=sw[1]
if chg[sw]>0
then =>power1 %sw%
endif

Thank you very much

PROBLEM DESCRIPTION

A clear and concise description of what the problem is.

REQUESTED INFORMATION

Make sure your have performed every step and checked the applicable boxes before submitting your issue. Thank you!

  • [ ] Read the Contributing Guide and Policy and the Code of Conduct
  • [ ] Searched the problem in issues
  • [x] Searched the problem in discussions
  • [x] Searched the problem in the docs
  • [x] Searched the problem in the chat
  • [ ] Device used (e.g., Sonoff Basic): _____
  • [ ] Tasmota binary firmware version number used: _____
    • [ ] Pre-compiled
    • [ ] Self-compiled
  • [ ] Flashing tools used: _____
  • [ ] Provide the output of command: Backlog Template; Module; GPIO 255:
  Configuration output here:


  • [ ] If using rules, provide the output of this command: Backlog Rule1; Rule2; Rule3:
  Rules output here:


  • [ ] Provide the output of this command: Status 0:
  STATUS 0 output here:


  • [ ] Set weblog to 4 and then, when you experience your issue, provide the output of the Console log:
  Console output here:


TO REPRODUCE

Steps to reproduce the behavior:

EXPECTED BEHAVIOUR

A clear and concise description of what you expected to happen.

SCREENSHOTS

If applicable, add screenshots to help explain your problem.

ADDITIONAL CONTEXT

Add any other context about the problem here.

(Please, remember to close the issue when the problem has been addressed)

muchcodesuchwow avatar Jun 15 '24 16:06 muchcodesuchwow