Skip to content
Open

Storage #5498

3 changes: 0 additions & 3 deletions content/components/esphome.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ esphome:
name: livingroom
comment: Living room ESP32 controller
area: Living Room

esp32:
board: nodemcu-32s
```

{{< anchor "esphome-configuration_variables" >}}
Expand Down
1 change: 1 addition & 0 deletions content/components/images/storage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion content/components/sensor/sps30.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ params:
---

The `sps30` sensor platform allows you to use your Sensirion SPS30
([datasheet](https://sensirion.com/media/documents/8600FF88/616542B5/Sensirion_PM_Sensors_Datasheet_SPS30.pdf)) sensors with ESPHome.
([datasheet](https://sensirion.com/media/documents/8600FF88/64A3B8D6/Sensirion_PM_Sensors_Datasheet_SPS30.pdf)) sensors with ESPHome.
The [I²C Bus](#i2c) is required to be set up in your configuration for this sensor to work.
This sensor supports both UART and I²C communication. However, at the moment only I²C communication is implemented.

Expand Down
80 changes: 80 additions & 0 deletions content/components/storage/storage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
description: "Interface for storage devices."
title: "Storage"
params:
seo:
description: Information about base storage device interface.
image: storage.svg
---

Storage is the API for different kind of devise for save and retrive datas. It can be used for read and write data blocks, but primary target is to use as device driver for filesystems library.

{{< anchor "storage-base-config" >}}

## Base Stroage Configuration

Each Storage device represented by the platform component with coresponding type. Each platform type inherits parameters from storage configuration schema.

```yaml

storage:
- platform: ...
...
- platform: ...
...

```

**Configuration variables:**

- **id** (*Optional*, [ID](#config-id)): Manually specify the ID used for code generation.

{{< anchor "storage-is_pressent-condition" >}}

## Is_present Condition

This is an condition for checking if media present.

```yaml
- if:
condition:
- storage.is_present: storage_1
then:
...
```

Configuration variables:

- **id** (**Required**, [ID](#config-id)): The ID of storage component

{{< anchor "storage-lambda-calls" >}}

### lambda calls

From [lambdas](#config-lambda), you can call several methods on all storage objects to do some
advanced stuff.

- Attributes: All storage devices have forlowing attributes

```cpp
// Initialize device
id(my_fatfs).initialize()
// Read sectors
id(my_fatfs).read_sectors(path)
// wriet sectors
id(my_fatfs).write_sectors(buff*, bloack, count)
// Reset initialization status
id(my_fatfs).reset(path,mode)
// Return true if media present
id(my_fatfs).state_media()
// Id drives iitialized
id(my_fatfs).state_init()
// return error of last operation
id(my_fatfs).error(path)
```

## See Also

- {{< apiref "Component" "esphome/core/component.h" >}}
- {{< apiref "api" "content/components/api.md">}}
- {{< apiref "storage" "esphome/components/storage/storage.h">}}