Help for beginner
i need to send the state of a sensor in string
#define sensor
sensor:
# used as mqtt publisher
- platform: uptime
id: upti
name: "${device_id} Uptime"
update_interval: ${publish_interval}
on_value:
- mqtt.publish_json:
topic: domoticz/in
payload: |-
root["command"] = "addlogmessage";
root["message"] = "Connexion MQTT depuis ESPHOME";
- logger.log: MQTT log domoticz published
#---dallas sensors
- platform: dallas
id: temp_piece
name: "temperature-chaufferie"
address: 0xAF012033B79C9F28
on_value:
#---Publisg sensors content to domoticz via mqtt
- mqtt.publish_json:
topic: domoticz/in
payload: |-
root["idx"] = 45;
root["nvalue"] = 0;
root["svalue"] = id(temp_piece).state;
- logger.log: MQTT Temp piece published
Give:
{“command”:“udevice”,“idx”:45,“nvalue”:0,“svalue”:26.75}
Domoticz need sensor value between quotes:
{“command”:“udevice”,“idx”:45,“nvalue”:0,“svalue”:“26.75”}
Thanks for Help
Philippe