diff --git a/docs/README.md b/docs/README.md index b0835dd35..9f6fdc2b7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -21,7 +21,7 @@ Do not add anything here, as it will overwritten with next rebuild. | [FAQ](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/faq.md) (30 total) | Here is a detailed list of questions you may ask. Some information from docs is repeated here. | | [Console/Script commands](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md) (280 total) | There are multiple console commands that allow you to automate your devices. Commands can be entered manually in command line, can be send by HTTP (just like in Tasmota), can be send by MQTT and also can be scripted. | | [Command Examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commandExamples.md) (10 total) | Here you can find some examples of console commands usage | -| [Autoexec.bat examples (configs)](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md) (19 total) | Here you can find examples of autoexec.bat configs. The autoexec.bat file can be created in Web Application, under LittleFS tab, and is run every time device reboots (unless device enters safe mode/AP mode). The autoexec.bat file allows you to create more advanced configs, setup TuyaMCU mappings, etc | +| [Autoexec.bat examples (configs)](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md) (20 total) | Here you can find examples of autoexec.bat configs. The autoexec.bat file can be created in Web Application, under LittleFS tab, and is run every time device reboots (unless device enters safe mode/AP mode). The autoexec.bat file allows you to create more advanced configs, setup TuyaMCU mappings, etc | | [MQTT Topics](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/mqttTopics.md) (25 total) | MQTT topic names and content for incoming and ougoing OBK MQTT publishes | | [Script examples](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/scriptExamples.md) (6 total) | Scripts can be put in autoexec.bat and then they will start automatically on reboot, you can also put script in other LittleFS file and use startScript [fileName] [Label] command to run them. From the firmware point of view, scripts and autoexecs are basically the same thing. There is, however, a little bit more advanced system of execution for scripts which can be written in a form of scripts threads that run over time, can have delays within then, conditional checks and jumps. | | [Console/Script commands [Extended Edition]](https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands-extended.md) (280 total) | More details on commands. | diff --git a/docs/autoexecExamples.md b/docs/autoexecExamples.md index a825d7855..860d3efe3 100644 --- a/docs/autoexecExamples.md +++ b/docs/autoexecExamples.md @@ -533,3 +533,57 @@ DeepSleep 120 ``` +Manual flash save example for TuyaMCU - using special Channels 200, 201, etc +
+```// Read full explanation here: https://www.elektroda.com/rtvforum/topic4003825.html +// NOTE: you can also use the feature of TuyaMCU itself (not OBK) to save relay state, but it's not always present +// Anyway, refer to article above. +// Here's the script: + +startDriver TuyaMCU + +setChannelType 1 toggle +setChannelType 2 toggle +setChannelType 3 toggle +setChannelType 4 toggle + + +setChannelType 7 TextField +setChannelType 8 TextField +setChannelType 9 TextField +setChannelType 10 TextField +setChannelType 14 TextField + +linkTuyaMCUOutputToChannel 1 1 1 +linkTuyaMCUOutputToChannel 2 1 2 +linkTuyaMCUOutputToChannel 3 1 3 +linkTuyaMCUOutputToChannel 4 1 4 +linkTuyaMCUOutputToChannel 7 2 7 +linkTuyaMCUOutputToChannel 8 2 8 +linkTuyaMCUOutputToChannel 9 2 9 +linkTuyaMCUOutputToChannel 10 2 10 +linkTuyaMCUOutputToChannel 14 4 14 + + +delay_s 1 +echo Restoring states: $CH201 $CH202 $CH203 $CH204 +setChannel 1 $CH201 +delay_s 0.1 +setChannel 2 $CH202 +delay_s 0.1 +setChannel 3 $CH203 +delay_s 0.1 +setChannel 4 $CH204 + +// when channel 1 changes, save it to flash channel 201 +addEventHandler OnChannelChange 1 setChannel 201 $CH1 +// when channel 2 changes, save it to flash channel 202 +addEventHandler OnChannelChange 2 setChannel 202 $CH2 +// when channel 3 changes, save it to flash channel 202 +addEventHandler OnChannelChange 3 setChannel 203 $CH3 +// when channel 4 changes, save it to flash channel 204 +addEventHandler OnChannelChange 4 setChannel 204 $CH4 + +``` + + diff --git a/docs/autoexecs/manual_tuyamcu_flash_save.bat b/docs/autoexecs/manual_tuyamcu_flash_save.bat new file mode 100644 index 000000000..4e58ac909 --- /dev/null +++ b/docs/autoexecs/manual_tuyamcu_flash_save.bat @@ -0,0 +1,48 @@ +// Read full explanation here: https://www.elektroda.com/rtvforum/topic4003825.html +// NOTE: you can also use the feature of TuyaMCU itself (not OBK) to save relay state, but it's not always present +// Anyway, refer to article above. +// Here's the script: + +startDriver TuyaMCU + +setChannelType 1 toggle +setChannelType 2 toggle +setChannelType 3 toggle +setChannelType 4 toggle + + +setChannelType 7 TextField +setChannelType 8 TextField +setChannelType 9 TextField +setChannelType 10 TextField +setChannelType 14 TextField + +linkTuyaMCUOutputToChannel 1 1 1 +linkTuyaMCUOutputToChannel 2 1 2 +linkTuyaMCUOutputToChannel 3 1 3 +linkTuyaMCUOutputToChannel 4 1 4 +linkTuyaMCUOutputToChannel 7 2 7 +linkTuyaMCUOutputToChannel 8 2 8 +linkTuyaMCUOutputToChannel 9 2 9 +linkTuyaMCUOutputToChannel 10 2 10 +linkTuyaMCUOutputToChannel 14 4 14 + + +delay_s 1 +echo Restoring states: $CH201 $CH202 $CH203 $CH204 +setChannel 1 $CH201 +delay_s 0.1 +setChannel 2 $CH202 +delay_s 0.1 +setChannel 3 $CH203 +delay_s 0.1 +setChannel 4 $CH204 + +// when channel 1 changes, save it to flash channel 201 +addEventHandler OnChannelChange 1 setChannel 201 $CH1 +// when channel 2 changes, save it to flash channel 202 +addEventHandler OnChannelChange 2 setChannel 202 $CH2 +// when channel 3 changes, save it to flash channel 202 +addEventHandler OnChannelChange 3 setChannel 203 $CH3 +// when channel 4 changes, save it to flash channel 204 +addEventHandler OnChannelChange 4 setChannel 204 $CH4 diff --git a/docs/json/autoexecExamples.json b/docs/json/autoexecExamples.json index 41c553df3..5ebc9f8e0 100644 --- a/docs/json/autoexecExamples.json +++ b/docs/json/autoexecExamples.json @@ -74,5 +74,9 @@ { "title": "Deep sleep usage with SHT30 sensor and data reporting via HTTP GET", "file": "autoexecs/deep_sleep_temp_sensor_http.bat" +}, +{ +"title": "Manual flash save example for TuyaMCU - using special Channels 200, 201, etc", +"file": "autoexecs/manual_tuyamcu_flash_save.bat" } ]