alcar21 / WemosEM

Cheap power monitor (STC013) with Home Assistant Discover and Wemos D1 Mini / PRO (esp8266)
114 stars 24 forks source link

Mqtt Problem #21

Closed wladimir79 closed 3 years ago

wladimir79 commented 3 years ago

Hi, i configured MQTT Parameters and from Mosquitto broker logs the device is connected.

1616335675: Client wemosEM-4E7EF6 already connected, closing old connection.
1616335675: New client connected from 192.168.1.54 as wemosEM-4E7EF6 (p2, c1, k30, u'mqtt_user').

The entity created on Hassio always returns UNKNOWN this code is in sensors.yaml

- platform: mqtt
  state_topic: "wemos/wemosem-4e7ef6/power"
  name: "EM General A"
  icon: mdi:current-ac
  unit_of_measurement: "A"
  value_template: "{{ value_json.current }}"
- platform: mqtt
  state_topic: "wemos/wemosem-4e7ef6/power"
  name: "EM General W"
  icon: mdi:power-plug
  unit_of_measurement: "W"
  value_template: "{{ value_json.watios }}"
- platform: mqtt
  state_topic: "wemos/wemosem-4e7ef6/power"
  name: "EM General KWh"
  icon: mdi:power-plug
  unit_of_measurement: "KWh"
  value_template: "{{ value_json.kwh }}"

Where am I doing wrong?

thx

rantanlan commented 3 years ago

why do you even need the yaml config? hassio is able to autodiscover mqtt devices and creates the entities for you? Just remove it completly and check the mqtt integration in hassio.

wladimir79 commented 3 years ago

I have other device configured without autodiscover and I do not have any problem. The entity in hassio is created and in the mosquitto logs is connected correctly

the only problem is that the value is not read, how can I be sure that it is sent by the Wemos?

rantanlan commented 3 years ago

did you check if mqtt is recieving it? just subscribe to the topic and look how the payload looks

wladimir79 commented 3 years ago

i try with topic in the manual (wemos/wemosEM-XXXXXX/power), you see my config in the first post

Check the subscribe from hassio and from chrome addon but not received data 😔

rantanlan commented 3 years ago

maybe check with just some toollike https://mqttfx.jensd.de/ this show you your whole traffic on the server... if you don't get anything there... you know it's your D1 not sending anything.

alcar21 commented 3 years ago

Hello, Sorry, i have no time for this project. I want to help you.

You can use MQTT Explorer too, it's a good program for explorer your MQTT topics.

Your config is wrong. Test the next config:

- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General A"
  icon: mdi:current-ac
  unit_of_measurement: "A"
  value_template: "{{ value_json.current }}"
- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General W"
  icon: mdi:power-plug
  unit_of_measurement: "W"
  value_template: "{{ value_json.watios }}"
- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General KWh"
  icon: mdi:power-plug
  unit_of_measurement: "KWh"
  value_template: "{{ value_json.kwh }}"

The config of home assistant is case sensitive.

wladimir79 commented 3 years ago

thank you so much, I didn't know about case sensitive

now everything works correctly :-)

Hello, Sorry, i have no time for this project. I want to help you.

You can use MQTT Explorer too, it's a good program for explorer your MQTT topics.

Your config is wrong. Test the next config:

- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General A"
  icon: mdi:current-ac
  unit_of_measurement: "A"
  value_template: "{{ value_json.current }}"
- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General W"
  icon: mdi:power-plug
  unit_of_measurement: "W"
  value_template: "{{ value_json.watios }}"
- platform: mqtt
  state_topic: "wemos/wemosEM-4E7EF6/power"
  name: "EM General KWh"
  icon: mdi:power-plug
  unit_of_measurement: "KWh"
  value_template: "{{ value_json.kwh }}"

The config of home assistant is case sensitive.