The only way tuya infrared blasters work via zigbee2mqtt is by a text publish:
id: "1739965733791"
name: ar escritório 25 sleep
entities:
text.ir_branco_3v_escritorio_ir_code_to_send:
mode: text
min: 0
max: 255
pattern: null
assumed_state: true
friendly_name: ir 1 Ir code to send
state: CCsMzyUCAvoFAuAEAOAPD+AHF0AAQBNAA0AAwAdAAOAQCwIFAgI=
metadata: {}
icon: mdi:gamepad-square-outline
which means it has to respect the 255 limit of characters. However, many codes from my Samsung air conditioner remote have 350 characters or more, so its not possible to send through text entity. Text entities in HA need to support at least 1000 characters, I’d do 2000 just to be sure
This FR is dead on arrival. All entity states are limited to 255 characters on purpose.
If you want to store more than 255 characters, put it in the entity’s attributes (can store 16K). Or in the secrets.yaml file or as a variable in the automation that requires it or etc etc.
I think it was DOA because the problem is really due to a misunderstanding of a third-party add-on. Zigbee2MQTT has provided a text entity as an input, but OP doesn’t seem to understand that what is needed is to use the mqtt.publish action.
it looks like you made a script as a program that does the publishing for you.
From what I ve searched theres no way to do mqtt publish from scenes. I made a script where the input is the string to send, however I cannot call it with the correct command from a scene.
Is the only option to make buttons that call actions? I would like to have scenes like “fan off” so I can use it from many places, but it seems not possible.
So I will have to copy the IR codes to my each automation, each button, and etc?
Scripts can be called as actions from dashboard cards, other scripts, or automations… that is one of the major purposes of scripts, to package sequences of actions that will be called from various sources/locations.
ok, I was able to use scripts to do mqtt publishing, but for newcomers it would require listening to MQTT publish messages to discover the structure of the message and the arguments, then do a script and if the entity on the zigbee2mqtt changes this script will break. This is hard and I did so many things wrong like putting the wrong entity name as there is no helper to select from, and others.
I still couldn’t save the IR codes as helpers because the text there is maximum 255 characters. So I need to put the message on each action invoke. Shouldn’t HA have support for bigger helpers?
The text entity that zigbee IR blasters expose on zigbee2mqtt seem sufficient if it were possible to support more than 255 characters and there were a way to send it twice in a row and actually get updated.
Is there a proper action that takes text as input, in the MQTT protocol from home assistant, and that this text can be larger than 255? I can try to make this PR in the future. I’d like the experience to be as easy as possible to newcomers.
Thank you both, the support from the community is awesome, messages get responded quickly.
So we need to change those to not be a text entity but instead an action that sends arbitraty text
I dont know how to do that though.
The “action” is mqtt.publish.
Since MQTT can publish anything, I think this is a problem related to the protocol agreed between home assistant and zigbee2mqtt which I dont know how it works.
The “protocol” is MQTT.
I guess you didn’t follow the example in the link I posted above.
yes, but these variables are bound to the script, right? I wanted them to be gloal and used on other scripts. Also I didn’t need to make it as a json message, when I listened for the topic there was no json structure, just a string publish.
I know that the protocol is MQTT, but the communication of HA ↔ Zigbee2mqtt happens over MQTT with some structure, in this example, json with some expected keys. I wonder if there were a way to expect something rather than a simple text on the zigbee2mqtt side
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.
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 topic zigbee2mqtt/FRIENDLY_NAME/set with 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.