Hi All,
I am totally newbie in this ESPHome world. I recently tried thingsboard and would like to test the possibility of using esphome with thingsboard via MQTT.
I have the following test code:
mqtt:
broker: "104.196.24.70"
client_id: "ik5gju7poo2s5ko52u5j"
username: "USER"
password: "PASSWORD"
discovery: false
port: 1883
on_connect:
- mqtt.publish_json:
topic: v1/devices/me/attributes
payload: !lambda |-
root["pin"] = "id7";
root["enabled"] = id(id7).state;
switch:
- platform: gpio
name: "Front door lamp"
id: id7
pin:
pcf8574: pcf8574_hub
# Use pin number P7
number: 7
# One of INPUT or OUTPUT
mode:
output: true
inverted: false
state_topic: 'v1/devices/me/attributes'
command_topic: 'v1/devices/me/attributes/getGpioStatus'
on_turn_on:
then:
- mqtt.publish_json:
topic: "v1/devices/me/attributes"
retain: true
payload: !lambda |-
root["pin"] = "id7";
root["enabled"] = id(id7).state;
on_turn_off:
then:
- mqtt.publish_json:
topic: "v1/devices/me/attributes"
retain: true
payload: !lambda |-
root["pin"] = "id7";
root["enabled"] = id(id7).state;
I did some connection with thingsboard with update on attributes, however, I have no idea on how to make esphome mqtt be successfully updated on thingsboard.
I would like the ESPhome device to send status of switch (that is currently be controlled by Home assistant) to the dashboard on thingsboard (so that thingsboard can also control the switch with its widget) but no matter how i tried with revising the code, thingsboard does not capture the connection from the esphome device.
Can you please be so kind to guide me on this with thanks!
Best regard,