Your needs are different than mine when I automated the range hood fan.
If I needed to store the IR code strings somewhere accessible to any script, I could create a Template Sensor and store the IR codes in is attributes (allows up to 16K of storage). Then I could reference them by name in any script using the state_attr() function.
Reference
An alternative is to reconsider your current approach to handling IR codes. Instead of storing the IR codes somewhere accessible to multiple scripts, store them in a dedicated “transmitter” script that is called by multiple other scripts.
According to Zigbee2MQTT’s documentation (refer to the link I posted above), you do need to ensure the payload you publish is in JSON format.
To write (
/set) a value publish a message to topiczigbee2mqtt/FRIENDLY_NAME/setwith payload{"ir_code_to_send": NEW_VALUE}.
That’s the advice I followed for my project and demonstrated in the short example I posted above.
Because a received IR code isn’t in JSON format. I strongly recommend you review Zigbee2MQTT’s documentation for your specific model of Tuya IR device. I read the docs for the Tuya ZS06 and it very clearly explains how IR codes are received and transmitted.