- Platform information:
- Hardware: Orangepi 3 LTS
- OS: Armbian 22.11.1
- Java Runtime Environment: OpenJDK Runtime Environment Zulu11.43+100-CA (build 11.0.9.1+1-LTS)
- openHAB version: 3.4
- Issue of the topic:
I am trying to send data produced by tuya cli to mqtt with mosquitto sub.
I have a bunch of Tuya zigbee temperature and humidity sensors around the house. I have not been able to configure tuya-mqtt to read them. Fortunately tuya-cli can read each of the sensors separately like this:
tuya-cli get --ip 192.168.0.114 --id bf828770253d********** --key 322f1a********** --cid a4c138********** --protocol-version 3.3
{ '1': 174, '2': 255, '4': 100 }
I would like to write an Openhab script that calls tuya-cli, converts the output and publishes it e.g. with mosquitto sub to sensor specific topics. id and key stay the same, sensors are identified by cid.
Need model script to convert json data for publishing on mqtt
tuya-cli provides data output in the following format
{ '1': 174, '2': 255, '4': 100 }
As far as I understand to publish this with mosquitto_sub it has to be of the format
"{\"1\":\"174\", \"2\":\"255\",\"4\":\"100\ }"
I know a little python, but that is all. I would be greatly thankful for help to create an Openhab script or rule that would call tuya-cli, convert the data and publish it to mqtt.