Skip to content

Emontx component documentation #5004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 36 commits into
base: next
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
1b7d959
First check-in for emontx doc
FredM67 Jun 12, 2025
dd8b5be
Add some doc for emontx
FredM67 Jun 12, 2025
f5cba4d
Sensors definition
FredM67 Jun 17, 2025
de28161
Add reference link for emontx sensors section
FredM67 Jun 17, 2025
703fd42
Add EmonTx sensor entry to Electricity section
FredM67 Jun 17, 2025
f850034
Update EmonTx image reference in Electricity section
FredM67 Jun 17, 2025
f9eaf08
Fix EmonTx sensor reference and update data format description
FredM67 Jun 17, 2025
179d356
Add EmonTx5 image to the repository
FredM67 Jun 17, 2025
621ba8c
Update temperature sensor description in EmonTx documentation
FredM67 Jun 17, 2025
ae22d04
Resize image
FredM67 Jun 17, 2025
51eff89
Fix formatting and alignment issues in EmonTx documentation
FredM67 Jun 17, 2025
65dead5
Add alt text for EmonTx5 image and improve caption clarity in documen…
FredM67 Jun 17, 2025
3792919
Fix alignment of EmonTx5 image in documentation
FredM67 Jun 17, 2025
6c34a8d
Merge branch 'next' into emontx
FredM67 Jun 17, 2025
4382115
Fix sensor reference and enhance EmonTx documentation with indexing d…
FredM67 Jun 17, 2025
a70295f
Fix formatting and improve clarity of sensor indexing section in Emon…
FredM67 Jun 17, 2025
98cf291
Improve EmonTx documentation clarity and enhance emoncms integration …
FredM67 Jun 18, 2025
812b456
Fix link reference for http_request component in Emoncms integration …
FredM67 Jun 18, 2025
4a4a7c3
Add MQTT forwarding documentation
FredM67 Jun 18, 2025
2b8dc7d
Fix MQTT forwarding documentation
FredM67 Jun 18, 2025
7b0cd77
Fix bullet list
FredM67 Jun 18, 2025
bb931d3
Fix typo
FredM67 Jun 18, 2025
2d3b87a
Get rid of http_id
FredM67 Jun 19, 2025
9c49716
Clarify required parameters for emoncms and MQTT integration in docum…
FredM67 Jun 19, 2025
53b52e0
Get rid of mqtt_id
FredM67 Jun 19, 2025
d90f732
Some fixes in the doc
FredM67 Jun 19, 2025
ade4b76
Fix blank on empty line
FredM67 Jun 19, 2025
840fd23
Implement borpin's reviews
FredM67 Jun 19, 2025
b8a33eb
Update component config
FredM67 Jun 24, 2025
4fcfff2
Fix formatting for default value in MQTT base prefix documentation
FredM67 Jun 24, 2025
fc8d8a1
Update accuracy settings for sensor configurations
FredM67 Jun 25, 2025
f928e91
Add MQTT publish mode options for emontx component
FredM67 Jun 26, 2025
61a4cd8
Add MQTT publish mode option for emontx component
FredM67 Jun 26, 2025
b0dfc00
Update emontx.rst
FredM67 Jun 26, 2025
7a2a820
Fix emoncms configuration key in emontx documentation
FredM67 Jun 27, 2025
0392f1c
Fix emoncms API key parameter name in documentation
FredM67 Jun 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions components/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ Electricity
CT Clamp, components/sensor/ct_clamp, ct_clamp.jpg, Alternating Current (AC)
Daly BMS, components/sensor/daly_bms, daly_bms.jpg, Voltage & Current & Power
DSMR, components/sensor/dsmr, dsmr.svg, Electrical counter
EmonTx, components/sensor/emontx, emontx5.jpg, Voltage & Current & Power & Energy & Temperature
HLW8012, components/sensor/hlw8012, hlw8012.svg, Voltage & Current & Power
INA219, components/sensor/ina219, ina219.jpg, Direct Current (DC)
INA226, components/sensor/ina226, ina226.jpg, Direct Current (DC) & Power
Expand Down
322 changes: 322 additions & 0 deletions components/sensor/emontx.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,322 @@
OpenEnergyMonitor EmonTx Sensors
================================

.. seo:: :description: Instructions for setting up OpenEnergyMonitor EmonTx energy monitors with ESPHome. :image: emontx.jpg :keywords: EmonTx, OpenEnergyMonitor, energy monitor, power monitoring, CT clamp

.. _emontx-component:

Component/Hub
-------------

The ``emontx`` component allows you to use ESPHome to create a connection to an OpenEnergyMonitor emonTX via a supported device (ESP32 recommended).
This component is a global hub that establishes the connection to the EmonTx via :ref:`UART <uart>` and translates the received data.
Using the :ref:`emontx sensors <emontx-sensors>`, you can then create sensors for Home Assistant that track voltage, current, power as measured by CTs (up to 12), pulse data, and temperature depending on the configuration of the emonTX.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component can send data to an MQTT Broker either as JSON or as individual topics to be consumed by any system.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

The component can send data to an MQTT Broker either as JSON or as individual topics to be consumed by any system.

This component can also be used to send data to a remote emoncms instance such as `emoncms <https://emoncms.org/>`_ via HTTP or a locally hosted system via HTTP or MQTT. Working directly with emoncms seamlessly is a key benefit of this component, allowing you to integrate your energy monitoring data with powerful visualization and analysis tools.

.. figure:: images/emontx5.jpg
:alt: OpenEnergyMonitor EmonTx5
:align: center
:width: 50.0%

OpenEnergyMonitor EmonTx.

As the communication with the EmonTx is done using UART, you need to have an :ref:`UART bus <uart>` in your configuration with the ``rx_pin`` connected to the data pin of the EmonTx and with the baud rate set to 115200.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly a key point that this component can only receive data not send it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot send data yet, but I could implement it.... We've just to define what to send, and specially how.
No idea if it's possible to implement a UI similar to what exists through https://openenergymonitor.org/serial/.


.. code-block:: yaml

# Example configuration entry
uart:
id: emontx_uart # using UART2
rx_pin: GPIO16
tx_pin: GPIO17
baud_rate: 115200

emontx:
id: myemontx

Configuration variables
-----------------------

In `emontx` platform:

- **id** (*Optional*, :ref:`config-id`): Manually specify the ID used for code generation or multiple hubs.
- **uart_id** (*Optional*, :ref:`config-id`): Manually specify the ID of the UART Component if you want to use multiple UART buses.
- **emoncms** (*Optional*): For forwarding data to an `emoncms` server.

- **http** (*Optional*): For forwarding data to an HTTP server.

- **server** (**Required**): The URL of the emoncms server.
- **apikey** (**Required**, string): The API Read/Write key for the emoncms server.
- **node** (**Required**, string): The node ID to use for the emoncms server.

- **mqtt** (*Optional*): For forwarding data to an MQTT broker, including emoncms via MQTT.

- **publish_mode** (*Optional*, enum): The MQTT publish mode. Defaults to ``json``.

- ``json`` - Publish the raw json as receive from EmonTx
- ``individual`` - Publish each value individually

- **base_prefix** (*Optional*, string): The MQTT base prefix to use for publishing data. Defaults to ``emon``.
- **node** (*Optional*, string): The MQTT node to use for publishing data. Defaults to ``${device_name}``.

Emoncms Integration
-------------------

.. warning::

If you enable ``emoncms`` and you do *not* use the :doc:`/components/api`, ie the module is exclusively used for forwarding data to Emoncms and it's *not* connected to any Home Assistant instance, you must
remove the ``api:`` configuration or set ``reboot_timeout: 0s``, otherwise the ESP will
reboot every 15 minutes because no client connected to the native API.

If you configure the ``emoncms`` option, you will also need to define the :doc:`/components/http_request` component in your configuration.
This is required for the component to communicate with the emoncms server.

Example:

.. code-block:: yaml

http_request:
useragent: esphome/emontx
timeout: 10s

emontx:
emoncms:
http:
server: "https://emoncms.org"
apikey: YOUR_API_KEY
node: 1

.. note::

The ``node`` parameter must be compliant with what emoncms expects. Depending on your emoncms server configuration, this could be a numeric ID (like "1") or a string identifier. Check your emoncms server documentation to ensure you're using the correct node format.

MQTT Integration
----------------

.. warning::

If you enable ``mqtt`` forwarding and you do *not* use the :doc:`/components/api`, ie the module is exclusively used for forwarding data via MQTT and it's *not* connected to any Home Assistant instance, you must
remove the ``api:`` configuration or set ``reboot_timeout: 0s``, otherwise the ESP will
reboot every 15 minutes because no client connected to the native API.

If you configure the ``mqtt`` option, you will need to define the :doc:`/components/mqtt` component in your configuration.
This is required for the component to publish data to the MQTT broker.

The component will publish all sensor data to topics following this structure:
``<base_prefix>/<node>/<sensor_name>``

Example:

.. code-block:: yaml

mqtt:
broker: 192.168.1.10
port: 1883 # Optional
username: mqtt_user # Optional
password: mqtt_pass # Optional
id: mqtt_client # Optional

emontx:
emoncms:
mqtt:
publish_mode: individual
base_prefix: "emon"
node: "emontx"

With this configuration, data will be published to topics such as:

- ``emon/emontx/V1`` for voltage on phase 1
- ``emon/emontx/P1`` for power on CT1
- ``emon/emontx/E1`` for energy on CT1

For integration with emoncms via MQTT, use the base prefix that includes any node identification required by your emoncms instance.

.. _emontx-sensors:

Sensors
-------

The EmonTx component provides several sensors that can be used to monitor various parameters:

- **Power**: Calculates the power consumption based on the voltage and current readings.
- **Energy**: Accumulates the energy consumption over time.
- **Voltage**: Measures the voltage of the mains supply.
- **Current**: Measures the current flowing through the connected CT clamps.
- **Power Factor**: Calculates the power factor based on the voltage and current readings.
- **Pulse**: Measures the number of pulses from the connected pulse sensor (interface S0 for example).
- **Temperature**: Reports temperatures of connected Dallas DS18B20 sensors.

Predefined Sensor Configuration
*******************************
Each type of sensor in the EmonTx component has predefined configuration parameters:

Power Sensors (P)
^^^^^^^^^^^^^^^^^
Power sensors have the following default configuration:

- Unit of Measurement: W (Watt)
- Device Class: power
- State Class: measurement
- Accuracy: 0 decimal place

Energy Sensors (E)
^^^^^^^^^^^^^^^^^^
Energy sensors have the following default configuration:

- Unit of Measurement: Wh (Watt-hours)
- Device Class: energy
- State Class: total_increasing
- Accuracy: 0 decimal places

Voltage Sensors (V)
^^^^^^^^^^^^^^^^^^^
Voltage sensors have the following default configuration:

- Unit of Measurement: V (Volt)
- Device Class: voltage
- State Class: measurement
- Accuracy: 2 decimal places

Current Sensors (I)
^^^^^^^^^^^^^^^^^^^
Current sensors have the following default configuration:

- Unit of Measurement: A (Ampere)
- Device Class: current
- State Class: measurement
- Accuracy: 2 decimal places

Power Factor Sensors (PF)
^^^^^^^^^^^^^^^^^^^^^^^^^
Power factor sensors have the following default configuration:

- Unit of Measurement: (dimensionless)
- Device Class: power_factor
- State Class: measurement
- Accuracy: 2 decimal places

Temperature Sensors (T)
^^^^^^^^^^^^^^^^^^^^^^^
Temperature sensors have the following default configuration:

- Unit of Measurement: °C (Celsius)
- Device Class: temperature
- State Class: measurement
- Accuracy: 2 decimal place

Pulse Sensors (PULSE)
^^^^^^^^^^^^^^^^^^^^^
Pulse sensors have the following default configuration:

- Unit of Measurement: pulses
- Accuracy: 0 decimal places (whole numbers)

These predefined configurations can be overridden in your YAML configuration if needed.

Sensor Indexing
***************

The EmonTx sensors use a specific indexing scheme that depends on the physical configuration of your EmonTx device:

Voltage Sensors (V1-V3)
^^^^^^^^^^^^^^^^^^^^^^^
Voltage sensors are indexed based on your power system configuration:

- **V1**: Voltage reading for single-phase systems or phase 1 in multi-phase systems
- **V2**: Voltage reading for phase 2 in multi-phase systems
- **V3**: Voltage reading for phase 3 in three-phase systems

Power Sensors (P1-P12)
^^^^^^^^^^^^^^^^^^^^^^
Power sensors are indexed based on the CT clamp connections:

- **P1-P6**: Power readings for CT1-CT6 on the standard EmonTx
- **P7-P12**: Power readings for CT7-CT12 when an expansion board is present

Energy Sensors (E1-E12)
^^^^^^^^^^^^^^^^^^^^^^^
Energy sensors follow the same indexing scheme as power sensors:

- **E1-E6**: Energy accumulation for CT1-CT6 on the standard EmonTx
- **E7-E12**: Energy accumulation for CT7-CT12 when an expansion board is present

Current Sensors (I1-I12)
^^^^^^^^^^^^^^^^^^^^^^^^
Current sensors are indexed according to the CT inputs:

- **I1-I6**: Current readings from CT1-CT6 on the standard EmonTx
- **I7-I12**: Current readings from CT7-CT12 when an expansion board is present

Power Factor Sensors (PF1-PF12)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Power factor sensors follow the same indexing as the CT inputs:

- **PF1-PF6**: Power factor for CT1-CT6 on the standard EmonTx
- **PF7-PF12**: Power factor for CT7-CT12 when an expansion board is present

Temperature Sensors (T1-T3)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Temperature sensors are indexed according to the connected temperature probes:

- **T1-T3**: Readings from up to 3 temperature sensors (usually DS18B20)

Pulse Sensor (PULSE, DIGPULSE, ANAPULSE)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The pulse sensor is a single counter input and doesn't use indexing.

.. note::

The actual availability of sensors depends on your specific EmonTx configuration and firmware.
Not all sensor indexes may be active or report values in your setup.
For example, in a single-phase system, only V1 will provide readings, while V2 and V3 won't be available.

Example of Sensor Configuration
*******************************
Here is an example of how to configure the EmonTx sensors in your ESPHome YAML configuration:

.. code-block:: yaml

sensor:
- platform: emontx
tag_name: "V1"
name: "Voltage L1"
- platform: emontx
tag_name: "V2"
name: "Voltage L2"
- platform: emontx
tag_name: "V3"
name: "Voltage L3"
- platform: emontx
tag_name: "P1"
name: "Power CT1"
- platform: emontx
tag_name: "E2"
name: "Energy CT2"
- platform: emontx
tag_name: "I3"
name: "Current CT3"
- platform: emontx
tag_name: "pf1"
name: "Power factor CT1"
- platform: emontx
tag_name: "T1"
name: "Temp 1"
- platform: emontx
tag_name: "pulse"
name: "Pulse"

Hardware Setup
--------------

The EmonTx can be connected to your ESP device via the serial UART interface.

Make sure the EmonTx is configured to output data in JSON format. The default baud rate for communication is 115200.

See Also
--------
- :ref:`sensor-filters`
- `OpenEnergyMonitor <https://openenergymonitor.org/>`_
- :ghedit:`Edit`
Binary file added components/sensor/images/emontx5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/emontx5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.