Skip to content

SzczepanLeon/esphome-components

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

Szczepan's esphome custom components

This repository contains a collection of my custom components for ESPHome.

"Buy Me A Coffee"
"Kup mi kawę"

1. Usage

Use latest ESPHome with external components and add this to your .yaml definition:

external_components:
  - source: github://SzczepanLeon/esphome-components@main

2. Components

2.1. wmbus

Component to receive wMBus frame (via CC1101), create HA sensor and send decoded value. You can also use this component with wmbusmeters HA addon: https://github.com/SzczepanLeon/esphome-components/blob/main/docs/wmbus.md

"CC1101 to D1 mini PCB"

NOTE: Configuration for version 3.x is described here

2.1.1. Fast start

  • don't know meter type (driver) and don't know ID
wmbus:
  all_drivers: True
  log_all: True

Then in logs you will have trace with driver name and ID:

[17:13:07][I][wmbus:085]: apator162 [0x00148686] RSSI: -44dBm T: 4e4401068686140005077a350040852f2f0f005B599600000010aa55000041545a42850Bd800437d037301c5500000564B00009e46 (79) T1 A
  • meter type (driver) and ID are known, but you don't know how to add sensors (map decoded data to sensor)
wmbus:
  all_drivers: False
  log_all: False

sensor:
  - platform: wmbus
    meter_id: 0x00148686
    type: apator162
    key: "00000000000000000000000000000000"
    sensors:
      - name: "my hot water RSSi"
        field: "rssi"
        accuracy_decimals: 0
        unit_of_measurement: "dBm"
        device_class: "signal_strength"
        state_class: "measurement"
        entity_category: "diagnostic"

Then in logs you will have trace with telegram:

[17:13:07][I][wmbus:085]: apator162 [0x00148686] RSSI: -44dBm T: 4e4401068686140005077a350040852f2f0f005B599600000010aa55000041545a42850Bd800437d037301c5500000564B00009e46 (79) T1 A

You can decode that telegram on wmbusmeters and create sensors.

  • everything is known, let's find field and unit From decoded JSON: decoded JSON

find interesting data (in that case total_m3), split it into field (total) and unit (m3) and create sensor in YAML. In YAML config please use units from HA (ie. "m³" not "m3", etc).

wmbus:
  all_drivers: False
  log_all: False

sensor:
  - platform: wmbus
    meter_id: 0x00148686
    type: apator162
    key: "00000000000000000000000000000000"
    sensors:
      - name: "my hot water RSSi"
        field: "rssi"
        accuracy_decimals: 0
        unit_of_measurement: "dBm"
        device_class: "signal_strength"
        state_class: "measurement"
        entity_category: "diagnostic"
      - name: "my hot water"
        field: "total"
        accuracy_decimals: 3
        unit_of_measurement: ""
        device_class: "water"
        state_class: "total_increasing"
        icon: "mdi:water"

2.1.2. Example

time:
  - platform: sntp
    id: time_sntp

external_components:
  - source: github://SzczepanLeon/esphome-components@main
    refresh: 0d
    components: [ wmbus ]

wmbus:
  mosi_pin: GPIO13
  miso_pin: GPIO5
  clk_pin:  GPIO2
  cs_pin:   GPIO14
  gdo0_pin: GPIO15
  gdo2_pin: GPIO16

  led_pin: GPIO0
  led_blink_time: "1s"

  frequency: 868.950
  all_drivers: False
  sync_mode: True
  log_all: True

  mqtt:
    broker: 10.0.0.88
    username: mqttUser
    password: mqttPass

  clients:
    - name: "wmbusmeters"
      ip_address: "10.0.0.22"
      port: 7227

sensor:
# add driver to compile list (will be available for autodetect), don't create sensor
  - platform: wmbus
    type: itron

# add sensor with defined type (driver will be also added to compile list)
  - platform: wmbus
    meter_id: 0x12345678
    type: apator162
    key: "00000000000000000000000000000000"
    sensors:
      - name: "my hot water RSSi"
        field: "rssi"
        accuracy_decimals: 0
        unit_of_measurement: "dBm"
        device_class: "signal_strength"
        state_class: "measurement"
        entity_category: "diagnostic"
      - name: "my hot water"
        field: "total"
        accuracy_decimals: 3
        unit_of_measurement: ""
        device_class: "water"
        state_class: "total_increasing"
        icon: "mdi:water"

# add more sensors, one without field (name will be used)
  - platform: wmbus
    meter_id: 0xABCD4321
    type: amiplus
    sensors:
      - name: "my current power consumption in Watts"
        field: "current_power_consumption"
        accuracy_decimals: 1
        unit_of_measurement: "w"
        device_class: "power"
        state_class: "measurement"
        icon: "mdi:transmission-tower-import"
      - name: "total energy on T1"
        field: "total_energy_consumption_tariff_1"
        accuracy_decimals: 3
        unit_of_measurement: "kwh"
        device_class: "energy"
        state_class: "total_increasing"
        icon: "mdi:transmission-tower-import"
      - name: "voltage_at_phase_1"
        accuracy_decimals: 0
        unit_of_measurement: "v"
        device_class: "voltage"
        state_class: "measurement"
        icon: "mdi:sine-wave"

# sensor with offset, type should be autodetected
   - platform: wmbus
    meter_id: 0x11223344
    sensors:
      - name: "cold water from Apator NA-1"
        field: "total"
        accuracy_decimals: 3
        unit_of_measurement: ""
        device_class: "water"
        state_class: "total_increasing"
        icon: "mdi:water"
        filters:
          - offset: 123.0

# if mqtt defined, JSON with all decoded fields will be published to broker
  - platform: wmbus
    meter_id: 0x22113366
    type: vario411

Configuration variables:

In wmbus platform:

  • mosi_pin (Optional): CC1101 MOSI pin connection. Defaults to GPIO13.
  • miso_pin (Optional): CC1101 MISO pin connection. Defaults to GPIO12.
  • clk_pin (Optional): CC1101 CLK pin connection. Defaults to GPIO14.
  • cs_pin (Optional): CC1101 CS pin connection. Defaults to GPIO2.
  • gdo0_pin (Optional): CC1101 GDO0 pin connection. Defaults to GPIO5.
  • gdo2_pin (Optional): CC1101 GDO2 pin connection. Defaults to GPIO4.
  • led_pin (Optional): Pin where LED is connected. It will blink on each telegram. You can use all options from Pin Schema.
  • led_blink_time (Optional): How long LED will stay ON. Defaults to 300 ms.
  • frequency (Optional): Rx frequency in MHz. Defaults to 868.950 MHz.
  • sync_mode (Optional): Receive telegram in one loop. Defaults to False.
  • log_all (Optional): Show all received telegrams in log. Defaults to False.
  • all_drivers (Optional): Compile with all drivers. Defaults to False.
  • clients (Optional):
    • name (Required): The name for this client.
    • ip_address (Required): IP address.
    • port (Required): Port number.
    • format (Optional): Telegram format to send. HEX or RTLWMBUS. Defaults to RTLWMBUS.
    • transport (Optional): TCP or UDP. Defaults to TCP.
  • mqtt (Optional):
    • broker (Required): Broker IP address.
    • username (Required): User name.
    • password (Required): password.
    • port (Optional): Port number. Defaults to 1883.
    • retain (Optional): If the published message should have a retain flag on or not. Defaults to False.

NOTE: MQTT can be defined in wmbus component or in ESPHome level.

Meter/sensor:

  • meter_id (Optional, int): Meter ID. Can be specified as decimal or hex.
  • type (Optional, string): Meter type. When not defined, driver will be detected from telegram.
  • key (Optional): Key for meter, used in payload decoding process. Defaults to "".
  • sensors (Optional):
    • id (Optional, string): Manually specify the ID for code generation. At least one of id and name must be specified.
    • name (Optional, string): The name for the sensor. At least one of id and name must be specified.
    • field (Optional): Field from decoded telegram (without unit). If field is not present then name is used.
    • unit_of_measurement (Required): Unit for field defined above.
    • All other options from Sensor.

Supported drivers: almost all from wmbusmeters version 1.17.1 (without drivers from file)

3. Author & License

Szczepan, GPL, 2022-2024