SzczepanLeon / esphome-components

153 stars 54 forks source link

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

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.

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: "m³"
        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: "m³"
        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: "m³"
        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

text_sensor:
  - platform: wmbus
    meter_id: 0xABCD1122
    type: izar
    sensors:
      - name: "Izar current_alarms"
        field: "current_alarms"

Configuration variables:

In wmbus platform:

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

sensor:

text_sensor:


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

3. Author & License

Szczepan, GPL, 2022-2024