Node configuration without MQTT

I am running ESPHome to get data from my Smartmeter over the Home Assistant API which is then used in the Energy Dashboard. So far this is the code I was using:

esphome:
  name: meter01
  platform: ESP32
  board: esp32-poe
  includes:
    - ./esphome-dlms-meter

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO17_OUT
  phy_addr: 0
  power_pin: GPIO12
  domain: .lan

# Enable logging
logger:
  level: INFO
#  tx_buffer_size: 2048 # Only needed when logging large packets

# Enable Home Assistant API if not using MQTT
api:
  password: "..."
  reboot_timeout: 0s

ota:
  password: "..."

#web_server:
#  port: 80

uart:
  tx_pin: GPIO4
  rx_pin: GPIO36
  baud_rate: 2400
  rx_buffer_size: 1024 # Needed to receive the large packets send by the smart meter
  id: mbus

sensor:
  - platform: template
    id: meter01_voltage_l1
    name: meter01_voltage_l1
    unit_of_measurement: V
    accuracy_decimals: 1
    device_class: "voltage"
    state_class: "measurement"
  - platform: template
    id: meter01_voltage_l2
    name: meter01_voltage_l2
    unit_of_measurement: V
    accuracy_decimals: 1
    device_class: "voltage"
    state_class: "measurement"
  - platform: template
    id: meter01_voltage_l3
    name: meter01_voltage_l3
    unit_of_measurement: V
    accuracy_decimals: 1
    device_class: "voltage"
    state_class: "measurement"

  - platform: template
    id: meter01_current_l1
    name: meter01_current_l1
    unit_of_measurement: A
    accuracy_decimals: 2
    device_class: "current"
    state_class: "measurement"
  - platform: template
    id: meter01_current_l2
    name: meter01_current_l2
    unit_of_measurement: A
    accuracy_decimals: 2
    device_class: "current"
    state_class: "measurement"
  - platform: template
    id: meter01_current_l3
    name: meter01_current_l3
    unit_of_measurement: A
    accuracy_decimals: 2
    device_class: "current"
    state_class: "measurement"

  - platform: template
    id: meter01_active_power_plus
    name: meter01_active_power_plus
    unit_of_measurement: W
    accuracy_decimals: 0
    device_class: "power"
    state_class: "measurement"
  - platform: template
    id: meter01_active_power_minus
    name: meter01_active_power_minus
    unit_of_measurement: W
    accuracy_decimals: 0
    device_class: "power"
    state_class: "measurement"
  - platform: template
    id: meter01_power_factor
    name: meter01_power_factor
    unit_of_measurement: " "
    accuracy_decimals: 3
    device_class: "power_factor"
    state_class: "measurement"

  - platform: template
    id: meter01_active_energy_plus
    name: meter01_active_energy_plus
    unit_of_measurement: Wh
    accuracy_decimals: 0
    device_class: "energy"
    state_class: "total_increasing"
  - platform: template
    id: meter01_active_energy_minus
    name: meter01_active_energy_minus
    unit_of_measurement: Wh
    accuracy_decimals: 0
    device_class: "energy"
    state_class: "total_increasing"

  - platform: template
    id: meter01_reactive_energy_plus
    name: meter01_reactive_energy_plus
    unit_of_measurement: Wh
    accuracy_decimals: 0
    device_class: "energy"
    state_class: "total_increasing"
  - platform: template
    id: meter01_reactive_energy_minus
    name: meter01_reactive_energy_minus
    unit_of_measurement: Wh
    accuracy_decimals: 0
    device_class: "energy"
    state_class: "total_increasing"

text_sensor:
  - platform: template
    id: meter01_timestamp
    name: meter01_timestamp
  - platform: template
    id: meter01_meternumber
    name: meter01_meternumber

mqtt:
   broker: ''
   id: mqtt_broker

custom_component:
  - lambda: |-
      auto dlms_meter = new esphome::espdm::DlmsMeter(id(mbus));
      byte key[] = {...};
      dlms_meter->set_key(key, 16); // Pass your decryption key and key length here
      dlms_meter->set_voltage_sensors(id(meter01_voltage_l1), id(meter01_voltage_l2), id(meter01_voltage_l3)); // Set sensors to use for voltage (optional)
      dlms_meter->set_current_sensors(id(meter01_current_l1), id(meter01_current_l2), id(meter01_current_l3)); // Set sensors to use for current (optional)
      dlms_meter->set_active_power_sensors(id(meter01_active_power_plus), id(meter01_active_power_minus), id(meter01_power_factor)); // Set sensors to use for active power (optional)
      dlms_meter->set_active_energy_sensors(id(meter01_active_energy_plus), id(meter01_active_energy_minus)); // Set sensors to use for active energy (optional)
      dlms_meter->set_reactive_energy_sensors(id(meter01_reactive_energy_plus), id(meter01_reactive_energy_minus)); // Set sensors to use for reactive energy (optional)
      dlms_meter->set_timestamp_sensor(id(meter01_timestamp)); // Set sensor to use for timestamp (optional)
      dlms_meter->set_meternumber_sensor(id(meter01_meternumber)); // Set sensor to use for meterNumber (optional)
      dlms_meter->enable_mqtt(id(mqtt_broker), "meter01/data"); // Enable grouped together MQTT report, useful to get exact time with each data for storing results in InfluxDB
      return {dlms_meter};

As of 2022.9.2 I get the following error:

[22:48:07][W][mqtt:141]: Couldn't resolve IP address for ''!
[22:48:07][W][mqtt:126]: Error resolving MQTT broker IP address: -16

I have the mqtt configuration part in the code because it is mandatory but I actually don’t need it, as the Home Assistant API is used. What would be the “correct” way to set the MQTT in the configuration so it won’t be used? (I don’t have a MQTT broker and I’m not planning to use one)
I hope this will get my node delivering data again :slight_smile:

Delete the mqtt config, ie this bit

mqtt:
   broker: ''
   id: mqtt_broker

That’s what I already tried, but I can’t use a configuration without the mqtt part. I can save it but when I try to install it, this is the error I get:

Couldn't find ID 'mqtt_broker'. Please check you have defined an ID with that name in your configuration.

Looking closer, you also reference mqtt in your custom component.

Yeah, I just noticed that myself :smiley:
I’m currently combing through all the other used files to see where MQTT is referenced.

I don’t know where you got your code from, nor do I know why you have an aversion to mqtt.

I don’t have an aversion to MQTT, I just don’t want to run a broker just for the node when I’m getting the data over the API anyway :wink:

Anyways, I have fixed the problem now and the node is running and delivering data. Thanks for the nudge in the right direction!

2 Likes