Implement ESP8266 sensor via MQTT not working

Hello Community!

I am facing some issues to implement a sensor, which reads the energy out of my electric smart meter.
The reader is reachable under 192.168.2.204. The MQTT setup in this reader looks like this:

Further i have installed the mosquitto broker addon on my home assistant os. In the configuration the setup is all on default.

The MQTT integration is configured like this:

And i use this code in my configuration.yaml:
mqtt:
sensor:

  • name: “AMIS Bezug (Wh)”
    state_topic: amisHH
    value_template: “{{ value_json[‘1.8.0’] }}”
    unit_of_measurement: Wh
    device_class: energy
    state_class: total_increasing
    unique_id: “sensor_amis_180”
  • name: “AMIS Lieferung (Wh)”
    state_topic: amisHH
    value_template: “{{ value_json[‘2.8.0’] }}”
    unit_of_measurement: Wh
    device_class: energy
    state_class: total_increasing
    unique_id: “sensor_amis_280”
  • name: “AMIS Power Buy (W)”
    state_topic: amisHH
    value_template: “{{ value_json[‘1.7.0’] }}”
    unit_of_measurement: W
    device_class: energy
    unique_id: “sensor_amis_170”
  • name: “AMIS Power Sell (W)”
    state_topic: amisHH
    value_template: “{{ value_json[‘2.7.0’] }}”
    unit_of_measurement: W
    device_class: energy
    unique_id: “sensor_amis_270”
  • name: “AMIS Power Saldo (W)”
    state_topic: amisHH
    value_template: “{{ value_json[‘saldo’] }}”
    unit_of_measurement: W
    device_class: energy
    unique_id: “sensor_amis_saldo”

Could a different subnet of Reader and Broker be a problem?
What else can i miss?

Thank you in advance!

What are the actual issues?
Is “192.168.3.38” your HA IP address, where the Mosquitto addon is running?
What do you see when using, e.g., “MQTT Explorer | An all-round MQTT client that provides a structured topic overview (mqtt-explorer.com)

Thank you for your reply!

The issue is, that there is in my home assistant no delivery:
image

Yes, 192.168.3.38 ist my HA where the Mosquitto addon is running.

I can connect to my HA via MQTT Explorer. It looks like that MQTT is sending correct, am i right with this intention? Maybe the code in configuration.yaml is wrong.

TY !

At first sight, there is no messages in Mosquitto (although, as you did not specify “retain” on the “reader” side, you’ll have to wait a bit for message to appear).

Likely, as it seems your “reader” does not push data to Mosquitto.
Don’t you have any kind of logging on that side?

Your sensor and your HA machines are on different subnets, 192.168.2.x vs 192.168.3.x

Thank you for your reply!

Somehow, when i set the sensor to 192.168.3.xx, i can´t reach it anymore.
The sensor is connected via WIFI to an AccessPoint, which is in the subnet 192.168.2.xx.
How do i get the sensor correctly to the 192.168.3.xx subnet?

As you haven’t told us what the sensor is, who knows.

Sorry, i dont quite understand this.
The sensor is connected via WLAN at IP 192.168.2.204. What else information can i give?

We don’t know what sort of device it is, so we can’t tell you how to change it’s IP address.

Warning: wild guess about the OP network configuration

Would you be using a wifi mesh like the TP-link deco P9?
By default, those install themselves in “Router” mode, creating a separate subnet which can lead to a bunch of unexpected issues. I set mines in “Access point” mode, which “bridges” all the networks in the same address space.

Sorry for my late answer!

The device is an AMIS-Reader. Its interface looks like this:


or this:

To WiFi settings: i tried already with IP 192.168.3.xx and Gateway 192.168.3.1 - but then ive no connection to the Reader.

The current ip of the reader is 192.168.2.204 and is reachable.

@koying
Im using an EdgeRouter as dhcp client an on this connected a FritzBox 7530 as mesh master (but configured as AP) for my W-LAN. The Reader is connected via W-LAN over my mesh master.

The mosquitto broker logfile tells this:

so there is a new connection from my ESP8266 device at 14:47 (after restart).

Thank you!

Your reader connects to your mqtt server. Next problem please.

I suspect that having 0 in the “MQTT Keep alive” just doesn’t publish anything.
Try “5” as in Optimize your Home Energy Consumption with an ESP8266 Siemens AMIS Reader and Home Assistant – Smartlab

1 Like

Thank you thank you thank you. Thats it. Its working!

Greetings!