-
It's a simple request but i cannot catch the switch value in no way.
On console i can see the print and the publish |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 19 replies
-
Really not enough information to help you. Look at the documentation on switches or you could use rules, I suppose. https://tasmota.github.io/docs/Rules/ Most likely you should use PIR as a button, but it depends on the PIR. Some give a short pulse, use button for that and set the topic. This is the old school way of doing it. If the PIR output stays active for a long time, you should use Switch. But, it sounds like your PIR is not staying active for long when it senses motion. |
Beta Was this translation helpful? Give feedback.
-
if you look at the documentation sw[x] index starts from 0 not from 1. Events (section >E) are executed when Tasmota generates a JSON EVENT/ RESULT. (can be seen in console) since it is not really relevant in your application you can also watch for a change in section >F (every 100ms) |
Beta Was this translation helpful? Give feedback.
-
Look this: |
Beta Was this translation helpful? Give feedback.
-
ok, this used to work 1 year ago. there have been many changes to tasmota switches since that time. did you try with button and (PUSH_IGNORE) ? code: i myself do nearly all that stuff inside scripts itself also PIR. >D >B >F |
Beta Was this translation helpful? Give feedback.
-
i will evaluate this sw[x] problem and update the source soon |
Beta Was this translation helpful? Give feedback.
-
ok works like expected: configure switch1 in Tasmota on gpio x >E |
Beta Was this translation helpful? Give feedback.
-
@rice103 as stated on Discord, apart from the index issue, you should use 'chg' and not 'upd' |
Beta Was this translation helpful? Give feedback.
-
ha, discovered the bug! must be a name clash with sw[x] |
Beta Was this translation helpful? Give feedback.
-
Ok thanks i'll try.
|
Beta Was this translation helpful? Give feedback.
-
please read my comment above! do NOT use a variable named sw ! it all works if you use e.g. pir! |
Beta Was this translation helpful? Give feedback.
-
it looks like you have still sw=0 in >D ? |
Beta Was this translation helpful? Give feedback.
-
Remains only one problem: |
Beta Was this translation helpful? Give feedback.
-
it works without problems in my setup >D >E >S |
Beta Was this translation helpful? Give feedback.
it works without problems in my setup
>D
pir=0
>B
->setoption114 1
->switchmode 1
>E
pir=sw[0]
if chg[pir]>0
then
print event %pir%
endif
>S
print %sw[0]%