A simple example with lots of comments #9
Replies: 5 comments
-
And to add some very simple UI. Note the use of global.xxx to check if the driver already was present, and remove it. This allows the driver to be replaced, and so this code can be pasted many times into the berry console without a restart.
|
Beta Was this translation helpful? Give feedback.
-
thanks for sharing. I've asked to have the discussion turned on for this repo. With discussion folks can do a post like this that then can be linked from the readme. Until then using issues works. I have going on several hundred SLOC in berry of which I haven't shared a line which is making you look like a hero and me a jerk. As I commented in that other issue I have a dev environment which may help with your dev cycle (coding pain). arendst/Tasmota#17490 (comment) |
Beta Was this translation helpful? Give feedback.
-
Discussions opened |
Beta Was this translation helpful? Give feedback.
-
@dkebler - ref the coding environment, note the code above can be run again and again without a reboot :). That was the first thing I HAD to solve when pasting stuff into the berry console, and finding myself continually forgetting to reboot. |
Beta Was this translation helpful? Give feedback.
-
@dkebler "me a jerk" - haha, absolutely not. None of us are being paid here, and I dip in and out every 2 years or so, throw in a load of shit, and then dissappear completely (then it takes me 6 hours to get my build env going again!!!). Blame me for several (I feel nice) additions, including new BLE and 'new' Tuya!... but they are not great if people don't get a good understanding. Looking forward to discussion! |
Beta Was this translation helpful? Give feedback.
-
I was frustrated by not easily finding Berry examples, and then found the discussion thread and hence to this repo.
So below is my first Berry script, which illustrates some of the simplest functions in use
Maybe enable the wiki on this repo, and encourage people to contribute there - easier than forking and PRing.
I found this example useful in understanding some of the basics.
###Things to highlight:
Repeatedly running code in the berry console is cumulative - especially and obviously adding tas rules :).
At least when developing, best to remove then add.... else you end up restarting a lot.
It's not obvious that the function added with add_cmd should end with a tas response to be sent (e.g. tasmota.resp_cmnd_done() ).
Else I got a cryptic error BRY: ERROR, bad json: OFF
Beta Was this translation helpful? Give feedback.
All reactions