Skip to content
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

New 1-wire Component: Dallas PIO (DS2413 DS2406 DS2408) #4584

Open
wants to merge 41 commits into
base: current
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
95ec858
Merge branch 'current' of https://github.com/esphome/esphome-docs int…
tdy91 Dec 30, 2024
a3b39cb
Merge branch 'current' of https://github.com/tdy91/esphome-docs into …
tdy91 Jan 7, 2025
cf86363
Merge branch 'current' of https://github.com/tdy91/esphome-docs into …
tdy91 Jan 15, 2025
d29083a
Initialization of dallas_pio component documentation.
tdy91 Jan 15, 2025
1924f45
Update dallas_pio.rst
tdy91 Jan 15, 2025
c8dd12d
Update dallas_pio.rst
tdy91 Jan 15, 2025
e7e3e97
Update dallas_pio binary sensor documentation
tdy91 Jan 15, 2025
2711a57
Update dallas_pio binary sensor documentation
tdy91 Jan 15, 2025
df1b790
Update dallas_pio switch documentation
tdy91 Jan 15, 2025
7aee325
Merge branch 'feature_dallas_pio' of https://github.com/tdy91/esphome…
tdy91 Jan 15, 2025
b3d5296
Update dallas_pio switch documentation
tdy91 Jan 15, 2025
e7512c4
Merge branch 'feature_dallas_pio' of https://github.com/tdy91/esphome…
tdy91 Jan 15, 2025
1aec40f
Adding dallas_pio image file for DS2413, DS2406 and DS2408 1-wire Dal…
tdy91 Jan 15, 2025
3d08784
Update documentation index
tdy91 Jan 15, 2025
1f7d3d6
Update documentation
tdy91 Jan 16, 2025
d473f2e
Restoring missing dallas_pio.jpg file
tdy91 Jan 16, 2025
a553e3a
Adding label dallas_pio
tdy91 Jan 16, 2025
1864c95
Label config-binary_sensor correction
tdy91 Jan 16, 2025
3fe3f8e
Merge branch 'current' into feature_dallas_pio
tdy91 Jan 17, 2025
4657b35
Merge branch 'feature_dallas_pio' of https://github.com/tdy91/esphome…
tdy91 Jan 18, 2025
bc018be
Adding DS2408 coded but not tested
tdy91 Jan 18, 2025
f0394b1
Merge branch 'esphome:current' into feature_dallas_pio
tdy91 Jan 18, 2025
71b756c
Upgrade documentation
tdy91 Jan 18, 2025
d49b570
Merge branch 'feature_dallas_pio' of https://github.com/tdy91/esphome…
tdy91 Jan 18, 2025
65eea7d
Update binary sensor dallas_pio.rst
tdy91 Jan 18, 2025
1044a1c
Update switch dallas_pio.rst
tdy91 Jan 18, 2025
a31c85d
Update binary sensor dallas_pio.rst
tdy91 Jan 18, 2025
481ed82
Update binary sensor dallas_pio.rst
tdy91 Jan 18, 2025
3bae876
Update switch dallas_pio.rst
tdy91 Jan 18, 2025
ac57f04
Update binary sensor dallas_pio.rst
tdy91 Jan 18, 2025
6531b6d
Update switch dallas_pio.rst
tdy91 Jan 18, 2025
f171f56
Update dallas_pio.rst
tdy91 Jan 18, 2025
4b99432
Update dallas_pio.rst Remove warning because DS2413 DS2406 and DS2408…
tdy91 Jan 26, 2025
0e68c0c
Update dallas_pio.rst Adding warning pull up on DS2408 RSTZ pin to en…
tdy91 Jan 26, 2025
f9c1c67
Update dallas_pio.rst Update dallas_pio switch (coderabbitai)
tdy91 Jan 26, 2025
7dad1d8
Update dallas_pio.rst Upgrade dallas_pio switch documentation (codera…
tdy91 Jan 26, 2025
a86b151
Update dallas_pio.rst binary sensor
tdy91 Jan 26, 2025
23a4f88
Update dallas_pio.rst one wire documentation link correction
tdy91 Jan 26, 2025
9783241
Update dallas_pio.rst one wire documentation link correction
tdy91 Jan 26, 2025
ca999bd
Merge branch 'current' into feature_dallas_pio
tdy91 Jan 27, 2025
eb1aae0
Merge branch 'esphome:current' into feature_dallas_pio
tdy91 Feb 24, 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
92 changes: 92 additions & 0 deletions components/binary_sensor/dallas_pio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
Dallas PIO Binary Sensor
========================

.. seo::
:description: Instructions for setting up Dallas 1-Wire PIO addressable switch as ESPHome binary sensor
:image: dallas_pio.jpg
:keywords: Dallas, ds2413, ds2406, ds2408, onewire

The ``dallas_pio`` component allows you to use
`DS2413 <https://www.adafruit.com/product/1551>`__
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2413.pdf>`__),
`DS2406`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2406.pdf>`__),
`DS2408`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2408.pdf>`__)
and similar 1-Wire Dallas addressable switches PIO as ESPHome binary sensors. A :ref:`Dallas PIO <dallas_pio>` is
required to be set up in your configuration for this binary sensor to work.

Example Configuration
*********************

Below are configuration examples for different Dallas devices, including DS2408 with P0-P7 pin usage.

**Single DS2413 on One-Wire Bus**

.. code-block:: yaml

# Example configuration entry
binary_sensor:
- platform: dallas_pio
name: ds2413 binary sensor # Friendly name for the binary sensor
dallas_pio_id: ds2413_ic1 # Reference to the Dallas PIO component
id: ds2413_binary_sensor # Optional ID for internal reference
pin:
number: PIOA # Pin to use on the Dallas device (PIOA/PIOB for DS2413/DS2406, P0-P7 for DS2408)
mode: # Configuration of the pin's behavior
input: true # If set, must be true to read input values from the pin
inverted: true # Invert the signal (true = active-low, false = active-high)
update_interval: 1s # How often the sensor should poll the pin's state

**Multiple Devices (DS2413 and DS2408) on the Same Bus**

.. code-block:: yaml

# Example configuration entry
binary_sensor:
- platform: dallas_pio
name: ds2413 binary sensor
dallas_pio_id: ds2413_ic1
id: ds2413_binary_sensor
pin:
number: PIOA
mode:
input: true
inverted: true
update_interval: 1s

- platform: dallas_pio
name: ds2408 binary sensor
dallas_pio_id: ds2408_ic2
id: ds2408_binary_sensor
pin:
number: P0
mode:
input: true
inverted: true
update_interval: 1s


Configuration variables:
************************

- **name** (*Optional*, string): The name for the sensor. At least one of **id** and **name** must be specified.
- **id** (*Optional*, string): Manually specify the ID for code generation. At least one of **id** and **name** must be specified.
- **dallas_pio_id** (*Required*, string): The ID of the dallas pio to use.
- **pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The PIO pin to use for the binary sensor.

Options:
- **number**: The pin to use. For DS2413 or DS2406, use `PIOA` or `PIOB`. For DS2408, use `P0` to `P7`.
- **mode**:
- `input: true`: Configure the pin as an input (default)
- `input: false`: not allowed (binary sensor acts necessarily as an input).
- **inverted**: Set to `true` to interpret a high signal as low (active-low). Useful for devices where a low voltage signifies an active state. Defaults to `false`.

- **update_interval** (*Optional*, :ref:`config-time`): The interval that the binary sensors should be checked. Defaults to 1 second.
- All other options from :ref:`Binary Sensor <config-binary_sensor>`.

See Also
--------

- :apiref:`dallas_pio/binary_sensor.h`
- :ghedit:`Edit`
78 changes: 78 additions & 0 deletions components/dallas_pio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.. _dallas_pio:

Dallas PIO
==========

.. seo::
:description: Instructions for setting up Dallas 1-Wire addressable switches
:image: dallas_pio.jpg
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add missing image file.

The pipeline is failing because the referenced image file 'dallas_pio.jpg' is missing. Please add the image to the /images directory.

🧰 Tools
🪛 GitHub Actions: Lint

[error] Missing image file: The referenced image file '/home/runner/work/esphome-docs/esphome-docs/images/dallas_pio.jpg' does not exist but is required for the SEO tag

:keywords: Dallas, PIO, DS2413, DS2406, DS2408, onewire, 1-wire

The ``dallas_pio`` component allows you to use
`DS2413 <https://www.adafruit.com/product/1551>`__
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2413.pdf>`__),
`DS2406`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2406.pdf>`__),
`DS2408`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2408.pdf>`__)
and similar 1-Wire addressable switches. A :ref:`1-Wire bus <one_wire>` is
required to be set up in your configuration for this sensor to work.

Example Configuration
*********************

Below are configuration examples for different Dallas devices.

**Single DS2413 on One-Wire Bus**

.. code-block:: yaml

# Example configuration entry
dallas_pio:
- id: ds2413_ic1
name: DS2413 IC1
reference: DS2413
address: 0xfe10055073e122ba
one_wire_id: OneWireBus1

**Multiple Devices (DS2413 and DS2408) on the Same Bus**

.. code-block:: yaml

# Example configuration entry
dallas_pio:
- id: ds2413_ic1
name: DS2413 IC1
reference: DS2413
address: 0xfe10055073e122ba
one_wire_id: OneWireBus1

- id: ds2408_ic2
name: DS2408 IC2
reference: DS2408
address: 0x1234567812345628
one_wire_id: OneWireBus1

**Address Format**

The `address` parameter specifies the unique 1-Wire address of the device. This address is an 8-byte hexadecimal value (e.g., `0xfe10055073e122ba`) and can typically be obtained using a 1-Wire bus scanner or through the Dallas 1-Wire library.


Configuration variables:
************************
- **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.
- **reference** (*Optional*, string): The dallas reference of adressable switch among DS2413 (default), DS2406 or DS2408 (see warning note below).
- **address** (*Required*, int): The address of the sensor. Required if there is more than one device on the bus.
- **crc** (*Optional*, bool): [DS2406 only] Use CRC if true. Defaults to false.
- **one_wire_id** (*Required*, :ref:`config-id`): Manually specify the ID used for code generation. Required if you have multiple busses.

Comment on lines +61 to +69
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix typo and clarify CRC usage.

  1. Fix typo: "adressable" should be "addressable" in the reference description
  2. Clarify if CRC is applicable to other device types besides DS2406


See Also
--------

- :doc:`/components/binary_sensor/index`
- :doc:`/components/switch/index`
- :doc:`/components/one_wire`
- :apiref:`dallas_pio/dallas_pio.h`
- :ghedit:`Edit`
96 changes: 96 additions & 0 deletions components/switch/dallas_pio.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
Dallas PIO Switch
=================

.. seo::
:description: Instructions for setting up Dallas 1-Wire PIO addressable switch as ESPHome switch
:image: dallas_pio.jpg
:keywords: Dallas, ds2413, ds2406, ds2408, onewire

The ``dallas_pio`` component allows you to use
`DS2413 <https://www.adafruit.com/product/1551>`__
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2413.pdf>`__),
`DS2406`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2406.pdf>`__),
`DS2408`
(`datasheet <https://datasheets.maximintegrated.com/en/ds/DS2408.pdf>`__)
and similar 1-Wire Dallas addressable switches PIO as ESPHome switch. A :ref:`Dallas PIO <dallas_pio>` is
required to be set up in your configuration for this binary sensor to work.
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect component reference.

The text incorrectly refers to a "binary sensor" when this is a switch component documentation.

-required to be set up in your configuration for this binary sensor to work.
+required to be set up in your configuration for this switch to work.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
and similar 1-Wire Dallas addressable switches PIO as ESPHome switch. A :ref:`Dallas PIO <dallas_pio>` is
required to be set up in your configuration for this binary sensor to work.
and similar 1-Wire Dallas addressable switches PIO as ESPHome switch. A :ref:`Dallas PIO <dallas_pio>` is
required to be set up in your configuration for this switch to work.


.. warning::

**DS2408**: don't forget to put a pull up resistor to Vcc on the RSTZ pin to enable writing to ports P0 to P7 !

Example Configuration
*********************

Below are configuration examples for different Dallas devices, including DS2408 with P0-P7 pin usage.

**Single DS2413 on One-Wire Bus**

.. code-block:: yaml

# Example configuration entry
switch:
- platform: dallas_pio
name: ds2413 switch # Friendly name for the switch
dallas_pio_id: ds2413_ic1 # Reference to the Dallas PIO component
id: ds2413_switch # Optional ID for internal reference
pin:
number: PIOB # Pin to use on the Dallas device (PIOA/PIOB for DS2413/DS2406, P0-P7 for DS2408)
mode: # Configuration of the pin's behavior
output: true # If set, must be true to output values to the pin
inverted: true # Invert the signal (true = active-low, false = active-high)
inverted: false # Invert the switch

**Multiple Devices (DS2413 and DS2408) on the Same Bus**

.. code-block:: yaml

# Example configuration entry
switch:
- platform: dallas_pio
name: ds2413 switch
dallas_pio_id: ds2413_ic1
id: ds2413_switch
pin:
number: PIOB
mode:
output: true
inverted: true
Comment on lines +55 to +59
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Document pin mode options

The pin configuration example shows mode options, but these are not documented in the configuration variables section. Please add documentation for the available pin modes.

Add the following to the configuration variables section:

- **pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The PIO pin to use for the switch.
+ **pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The PIO pin to use for the switch.
+   - **mode** (*Optional*): Configure the pin mode.
+     - **output** (*Optional*, bool): Set to true to configure the pin as output (default: false).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pin:
number: PIOB
mode:
output: true
inverted: true
pin:
number: PIOB
mode:
output: true
inverted: true
**pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The PIO pin to use for the switch.
- **mode** (*Optional*): Configure the pin mode.
- **output** (*Optional*, bool): Set to true to configure the pin as output (default: false).

inverted: false

- platform: dallas_pio
name: ds2408 switch
dallas_pio_id: ds2408_ic2
id: ds2408_switch
pin:
number: P0
mode:
output: true
inverted: true
inverted: false


Configuration variables:
************************

- **name** (*Optional*, string): The name for the sensor. At least one of **id** and **name** must be specified.
- **id** (*Optional*, string): Manually specify the ID for code generation. At least one of **id** and **name** must be specified.
- **dallas_pio_id** (*Required*, string): The ID of the dallas pio to use.
- **pin** (**Required**, :ref:`Pin Schema <config-pin_schema>`): The PIO pin to use for the switch.

Options:
- **number**: The pin to use. For DS2413 or DS2406, use `PIOA` or `PIOB`. For DS2408, use `P0` to `P7`.
- **mode**:
- `output: true`: Configure the pin as an output (default)
- `output: false`: not allowed (switch acts necessarily as an output).
- **inverted**: Set to `true` to interpret a high signal as low (active-low). Useful for devices where a low voltage signifies an active state. Defaults to `false`.

- **inverted** (*Optional*, bool): Switch inverted if true (default: false).
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove redundant inverted option.

The inverted option is already documented in the pin configuration section. Having it twice with different descriptions is confusing.

-- **inverted** (*Optional*, bool): Switch inverted if true (default: false).

- All other options from :ref:`Switch <config-switch>`.

See Also
--------

- :apiref:`dallas_pio/switch.h`
- :ghedit:`Edit`
Binary file added images/dallas_pio.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/dallas_pio_ds2406.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/dallas_pio_ds2408.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/dallas_pio_ds2413.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ I/O Expanders/Multiplexers
TCA9555, components/tca9555, tca9555.svg
WeiKai SPI/I²C UART/IO Expander, components/weikai, wk2168.jpg
XL9535, components/xl9535, xl9535.svg
DS2413, components/dallas_pio, dallas_pio_ds2413.jpg
DS2406, components/dallas_pio, dallas_pio_ds2406.jpg
DS2408, components/dallas_pio, dallas_pio_ds2408.jpg

CAN Bus
-------
Expand Down
Loading