How to switch %var% to case sensitive? (serial receive data loaded to %var) #23705
-
Hi, RULE: Receive string: Console Log:
I need to have not converted to uppercase data because I want to send these to OLED display.. unfortunately I need sometime clear the display by using DisplayText [z] - big [Z] doesn't work. BR, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
The rule handling is designed to be case insensitive, by always folding data to upper case when evaluating rule triggers. Hence no way of retaining mixed case values when picking up values from the JSON, except: For more flexible handling on ESP32, you have the Berry language with less such restrictions. This includes More generally, instead of the serial bridge you also have full serial handling in Berry, even avoiding the restrictions of needing JSON in a format matching what you can do with triggers. If you instead of serial bridge used serial console pins, you could also issue commands directly, instead of the indirection with rules to pick up parts, and then assemble a command. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. I've read about the serial port support in the Berry and even tested sending – it does seem more flexible, but it requires more knowledge and programming skills than simple rules. I'll try to do the same in the Berry, but it'll be a challenge (I tried initializing an OLED display and failed). This is obviously a result of my lack of knowledge and experience... I need to read more :-) EDIT. BR, |
Beta Was this translation helpful? Give feedback.
-
I'll try to do it like you said... some kind of wrapper may be use to catch all interested commands. My knowledge is regarding Berry is very weak, so all simple task are sometime too hard for me... Just simple example:
Run: Result:
So I assume, data was received because print(msg.asstring()) working fine but I can't understand why data were not transferred to tasmota.cmd as expected string ("DisplayText Received_from_SIO"). I tried with C style fprint parameter like %s e.g.: tasmota.cmd(string.format("%s", msg)) but effect is the same. Have no idea how to prepare proper data for tasmota.cmd("") function. Any hint? Please :-) BR, |
Beta Was this translation helpful? Give feedback.
Well, to use
tasmota.cmd
, you should provide a string, not useprint
inside it, as the result from theprint
function call isnil
.While you don't need the step through the
format
function, it would have worked if you instead of thebytes
object (which is what you have inmsg
) got the string value from it, using themsg.asstring()
you were already using other places. This should do it:tasmota.cmd(msg.asstring())
To use the approach with serial, you'd also need to poll the serial port at short intervals. If you code as a driver, you have callbacks like
every_100ms
which can work well for that. It can also work withtasmota.set_timer
with a function doing theset_timer
again for the next c…