>>21361285 Ok, this has helped a lot. After much testing I've ruled out dp 5,6,7 and 104 using TextFields. All is accounted for apart from 107 which is valid but still unknown. I set it to 1 but it sets itself back to 0. Also I set the alarm off and repeated that test - no different. So yes it could possibly be a calibration setting as mentioned before. Here's a revised autoexec, based on the JSON:
I've also found a workaround for the save crashes (autoexec only) by keeping web tabs open.
One for the display interface where I can click Restart
One from the Web Application - Filesystem tab
One from the Web Application - Logs tab
This way, when the save corrupts after a restart, I can tab over and save again, tab back and restart. This works 100%. It's just unfortunate that most times it means 2x saves, occasionally 3, sometimes 4 just to get it to load right. Not good for flash wear but it is what it is.
After much experimentation, looking through the commands, and ChatGPT getting it wrong, I've given up on decimalisation in the autoexec. Looks like it can only de done in HTML, which if it wasn't guaranteed to crash the device I'd love to try and work on again. So instead of trying to copy the nice display on the web inferface, I'll see if I can get the values from MQTT into Home Assistant and then modify them.
Thanks everyone for your help with this. With just dp107 left we're almost there.
// Tuya PV28-CW 8-in-1 Air Quality Sensor autoexec.bat
// Clear previous autoexec settings
clearIO
// clear flags
// flags 0
// set flag 46
SetFlag 46 1
// Start TuyaMCU driver at Baud 9600
startDriver TuyaMCU
tuyaMCU_setBaudRate 9600
// If not using MQTT comment out waitFor MQTTState 1 or
// If using MQTT comment out tuyaMcu_defWiFiState 4
waitFor MQTTState 1
// tuyaMcu_defWiFiState 4
// Force update from TuyaMCU every 10 sec
addRepeatingEvent 10 -1 tuyaMcu_sendQueryState
// Mappings [dpID] [varType] [tgChannel]
// CO2 (ppm) - Dp 2 - Ch 1
setChannelLabel 1 "CO2 (ppm)"
setChannelType 1 ReadOnly
linkTuyaMCUOutputToChannel 2 val 1
// PM2.5 (ug/m3) - Dp 20 -Ch 2
setChannelLabel 2 "PM2.5 (ug/m3)"
setChannelType 2 ReadOnly
linkTuyaMCUOutputToChannel 20 val 2
// PM1.0 (ug/m3 - Dp 102 - Ch 3
setChannelLabel 3 "PM1.0 (ug/m3)"
setChannelType 3 ReadOnly
linkTuyaMCUOutputToChannel 102 val 3
// PM10 (ug/m3) - Dp 101 - Ch 4
setChannelLabel 4 "PM10 (ug/m3)"
setChannelType 4 ReadOnly
linkTuyaMCUOutputToChannel 101 val 4
// HCHO (ug/m3) - Dp 22 - Ch 5
setChannelLabel 5 "HCHO Formaldehyde (ug/m3)"
setChannelType 5 ReadOnly
linkTuyaMCUOutputToChannel 22 val 5
// TVOC (ug/m3) - Dp 21 - Ch 6
setChannelLabel 6 "TVOC (ug/m3)"
setChannelType 6 ReadOnly
linkTuyaMCUOutputToChannel 21 val 6
// Temperature - Dp 18 - Ch 7
setChannelType 7 Temperature
setChannelLabel 7 "Temperature"
linkTuyaMCUOutputToChannel 18 val 7
// Humidity ID19 (%) - Dp 19 - Ch 8
setChannelLabel 8 "Humidity"
setChannelType 8 Humidity
linkTuyaMCUOutputToChannel 19 val 8
// Humidity Current ID103 (%) - Dp 103 - Ch 9
setChannelLabel 9 "Humidity Current"
setChannelType 9 Humidity
linkTuyaMCUOutputToChannel 103 val 9
// Battery Level (%) - Dp 15 - Ch 10
setChannelLabel 10 "Battery Level"
setChannelType 10 BatteryLevelPercent
linkTuyaMCUOutputToChannel 15 val 10
// Brightness Level Detected - Dp 17 - Ch 11
setChannelLabel 11 "Brightness Level Detected (0-100)"
setChannelType 11 ReadOnly
linkTuyaMCUOutputToChannel 17 val 11
// CO2 Alarm State - Dp 1 - Ch 12
setChannelLabel 12 "CO2 Alarm State (1 Normal, 0 Alarm)"
setChannelType 12 ReadOnly
linkTuyaMCUOutputToChannel 1 enum 12
// Battery State - Dp 14 - Ch 13
setChannelLabel 13 "Battery State (1 Charging, 0 Discharging)"
setChannelType 13 ReadOnly
linkTuyaMCUOutputToChannel 14 enum 13
// PM2.5 Alarm State - Dp 106 - Ch 14
setChannelLabel 14 "PM2.5 Alarm State (1 Normal, 0 Alarm)"
setChannelType 14 ReadOnly
linkTuyaMCUOutputToChannel 106 enum 14
// CO2 Alarm Threshold - Dp 26 - Ch 15
setChannelLabel 15 "CO2 Alarm Threshold (400-5000 ppm - Default: 1500)"
setChannelType 15 TextField
linkTuyaMCUOutputToChannel 26 val 15
// PM2.5 Alarm Threshold - Dp 105 - Ch 20
setChannelLabel 20 "PM2.5 Alarm Threshold (0-1000 - Default: 75)"
setChannelType 20 TextField
linkTuyaMCUOutputToChannel 105 val 20
// Temperature Unit Display - Dp 31 - Ch 16
setChannelLabel 16 "Temperature Unit (0=Celsius, 1=Fahrenheit)"
setChannelType 16 Toggle
linkTuyaMCUOutputToChannel 31 enum 16
// Check Time Unknown - stays set - Dp 107 - Ch 17
setChannelLabel 17 "Check Time? Unknown."
setChannelType 17 TextField
linkTuyaMCUOutputToChannel 107 bool 17
// Display Sleep - Dp 108 - Ch 18
setChannelLabel 18 "Display Sleep (0=Off, 1=On)"
setChannelType 18 Toggle
linkTuyaMCUOutputToChannel 108 bool 18
// Display Sleep Time - Dp 109 - Ch 19
setChannelLabel 19 "Display Sleep Time (1-3600 sec - Default: 30)"
setChannelType 19 TextField
linkTuyaMCUOutputToChannel 109 val 19
// Alarm Setting - Dp 13 - Ch 21
setChannelLabel 21 "Alarm Setting"
setChannelType 21 Toggle
linkTuyaMCUOutputToChannel 13 bool 21
I've also found a workaround for the save crashes (autoexec only) by keeping web tabs open.
One for the display interface where I can click Restart
One from the Web Application - Filesystem tab
One from the Web Application - Logs tab
This way, when the save corrupts after a restart, I can tab over and save again, tab back and restart. This works 100%. It's just unfortunate that most times it means 2x saves, occasionally 3, sometimes 4 just to get it to load right. Not good for flash wear but it is what it is.
After much experimentation, looking through the commands, and ChatGPT getting it wrong, I've given up on decimalisation in the autoexec. Looks like it can only de done in HTML, which if it wasn't guaranteed to crash the device I'd love to try and work on again. So instead of trying to copy the nice display on the web inferface, I'll see if I can get the values from MQTT into Home Assistant and then modify them.
Thanks everyone for your help with this. With just dp107 left we're almost there.