Localtuya templating problem fix
To manage my smart home, I use infrared controllers (like these). By using the LocalTuya project, I ensure independence from the cloud, allowing me to control these devices locally without relying on an internet connection.
During my experiments with the air conditioner (which I will discuss in the next article), I found that it was not possible to send a command through LocalTuya using the Home Assistant template language:
- action: localtuya.set_dp
data:
device_id: {{ python_script_output['device'] }}
dp: 201
value: >-
{"control":"send_ir","head":"{{ python_script_output['head'] }}","key1":"{{ python_script_output['packet'] }}","type":0,"delay":300}
This template resulted in no response, and the command was simply ignored.
Through debugging, I learned that the localtuya.set_dp
method requires a string as a parameter, whereas the templating engine was providing an object. Fortunately, a minor fix available here addresses this problem.