How to send raw data to a tuya device? (Creating adapter for Woox Radiator Valve Thermostat - Invalid message 'null' error)

Hi everyone,

I am trying to create an adapter for the Woox Radiator Thermostats, which are based on Tuya.

After following the great instructions here and here, I found all the data point IDs and created an adapter to send and receive the heating setpoint, mode, and preset temperatures (such as “eco”, “comfort” etc.).

However, I am a bit stuck setting up the automated schedules (which switch the radiator temperature automatically at specific times on certain days). There are 7 data points, one for each day of the week. When I change the schedule using the buttons on the device for Thursday, for example, I receive this dump in the log:

Zigbee2MQTT:info 2022-10-15 11:25:32: zigbee-herdsman-converters:tuya_data_point_dump: Received Tuya DataPoint #112 from 0xec1bbdfffe8efc5e with raw data '{"dp":112,"datatype":0,"data":{"type":"Buffer","data":[4,32,1,30,96]}}': type='commandDataReport', datatype='raw', value='$<[""', known DP# usage: ["scheduleWorkday","neoUnknown2","wooxThursdaySchedule","saswellSetpointHistoryWeek","hyProtectionMaxTemp","fantemReportingEnable","fantemLoadType","trsScene","trsfScene","tvTuesdaySchedule","hochTemperatureThreshold"]

The key part here is the list of numbers in square brackets: [4,32,1,30,96] The number 4 is the day of the week (Thursday). The second number is the first temperature, which needs to be halved, so 32 means 16 degrees. The third number is the time. It refers to the 96 15-minute time periods in a day. So 1 would be 00:15, 2 would be 00:30 etc. The fourth number 30 is the second temperature (15 degrees). And the fifth number (96) is the second time, 24:00. This array can have as many times and temperatures as you like, but it will stop reading after time 96 (24:00) is listed.

Using this info, I created an adapter in fromZigbee.js that works, but I am stuck on the toZigbee.js part. For a start, I am simply trying to pass raw data to the device. I have added this to toZigbee.js:

    woox_thermostat_schedule_thursday: { 
        key: ['schedule_thursday'],
        convertSet: async (entity, key, value, meta) => {
        await tuya.sendDataPointRaw(entity, 112, value);        

However when I try to pass data to the device using mosquitto, I get the following error:

Zigbee2MQTT:debug 2022-10-15 11:49:49: Received MQTT message on 'zigbee2mqtt/0xec1bbdfffe8efc5e/set' with data '{"schedule_thursday":"data":{"type":"Buffer","data":[4,30,21,30,36,30,60,30,91,30,96,42,96,34,96,42,96,34]}}'
Zigbee2MQTT:error 2022-10-15 11:49:49: Invalid message 'null', skipping...

Can anyone help me out here? What do I need to change to successfully pass data to the device? Thanks in advance.