Hello,
I am looking to create and update a sensor from mqtt (Mosquitto). In my final solution, this will be from an external program (such as Java or Pyhton) which today retrieves information from my heating. Currently this program produces a json file that Home Assistant reads every 5 minutes and I am looking to transform my program to send the information directly to Mosquitto and be retrieved in Home Assistant.
Before going into the code, I’m currently testing through the mosquitto_pub functions (and inspired by what I can see on Zigbee2MQTT) but I can’t get anywhere. I also tried to create a sensor with “platform: mqtt” but I will not go further.
Here is my Json currently:
{
"time" : "2022-01-05 15:25:01",
"etat" : "5",
"temperatureActuel" : 20,
"puissanceReel" : 3,
"temperatureReglage" : 21,
"puissanceReglage" : 3,
"alarme" : "0"
}
I feel like you have to do attribute by attribute (based on Zigbee2MQTT) with things like this:
mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/sensor/Ravelli_Information/time/config" -m '{"name": "Ravelli_Information", "unique_id": "Ravelli_Information_time", "json_attributes_topic":"homeassistant/sensor/Ravelli_Information", "state_topic": "homeassistant/sensor/Ravelli_Information/state", "value_template": "{{ value_json.time}}"}'
mosquitto_pub -h 127.0.0.1 -p 1883 -t "homeassistant/sensor/Ravelli_Information/etat/config" -m '{"name": "Ravelli_Information", "unique_id": "Ravelli_Information_etat", "json_attributes_topic":"homeassistant/sensor/Ravelli_Information", "state_topic": "homeassistant/sensor/Ravelli_Information/state", "value_template": "{{ value_json.etat}}"}'
Thanks in advance