Skip to content

Commit 5ee50a7

Browse files
authored
Merge branch 'next' into mipi-rgb-wave-3.16
2 parents 0c3c936 + d49e160 commit 5ee50a7

File tree

10 files changed

+309
-25
lines changed

10 files changed

+309
-25
lines changed

content/components/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ Sensors are organized into categories; if a given sensor fits into more than one
337337
"Daly BMS","components/sensor/daly_bms","daly_bms.jpg","Voltage & Current & Power"
338338
"DSMR","components/sensor/dsmr","dsmr.svg","Electrical counter"
339339
"HLW8012","components/sensor/hlw8012","hlw8012.svg","Voltage & Current & Power"
340+
"HLW8032","components/sensor/hlw8032","hlw8032.png","Voltage & Current & Power"
340341
"INA219","components/sensor/ina219","ina219.jpg","DC Current"
341342
"INA226","components/sensor/ina226","ina226.jpg","DC Current & Power"
342343
"INA228","components/sensor/ina2xx","ina228.jpg","DC Voltage & Current & Power & Charge"

content/components/api.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@ It is also possible to get data from Home Assistant to ESPHome with user-defined
443443
When you declare actions in your ESPHome YAML file, they will automatically show up in
444444
Home Assistant and you can call them directly.
445445

446+
> [!NOTE]
447+
> User-defined actions can also send responses back to the calling client using the `api.respond` action.
448+
> See [Action Responses](#action-responses) for details.
449+
446450
```yaml
447451
# Example configuration entry
448452
api:
@@ -502,6 +506,144 @@ Each of these also exist in array form:
502506
- bool[]: An array of boolean values. C++ type: `std::vector<bool>`
503507
- ... - Same for other types.
504508

509+
### Action Responses
510+
511+
User-defined actions can send responses back to the calling client (such as Home Assistant). This enables
512+
bidirectional communication where actions can report success/error status or return structured JSON data.
513+
514+
#### Response Modes
515+
516+
The response behavior is controlled by the `supports_response` option, which can be set explicitly or
517+
auto-detected based on your action configuration:
518+
519+
- **none** (default): No response is sent. The action is "fire and forget".
520+
- **status**: Reports success/error status without data. Auto-detected when `api.respond` is used without `data:`.
521+
- **optional**: Returns JSON data when the client requests it. Auto-detected when `api.respond` is used with `data:`.
522+
- **only**: Always returns JSON data. Must be set explicitly. Use this for query-type actions.
523+
524+
#### Configuration variables
525+
526+
- **supports_response** (*Optional*, string): The response mode for this action. One of `none`, `status`,
527+
`optional`, or `only`. If not specified, the mode is auto-detected based on `api.respond` usage in the action.
528+
529+
#### Trigger variables
530+
531+
When `supports_response` is not `none`, the following variables are available in the action:
532+
533+
- **call_id** (`uint32_t`): A unique identifier for this action call. Used internally by `api.respond`.
534+
- **return_response** (`bool`): Only available in `optional` mode. Indicates whether the client requested
535+
a response. You don't typically need to check this - `api.respond` handles it automatically.
536+
537+
### `api.respond` Action
538+
539+
This action sends a response back to the client that called the user-defined action. It can report
540+
success/error status and optionally include JSON data.
541+
542+
#### Configuration variables
543+
544+
- **success** (*Optional*, boolean, [templatable](/automations/templates)): Whether the action succeeded.
545+
Defaults to `true`.
546+
- **error_message** (*Optional*, string, [templatable](/automations/templates)): An error message to include
547+
when `success` is `false`. Defaults to an empty string.
548+
- **data** (*Optional*, [lambda](/automations/templates#config-lambda)): A lambda that populates a JSON object
549+
with response data. The lambda receives a `root` variable of type [`JsonObject`](https://arduinojson.org/v7/api/jsonobject/)
550+
that you can populate with key-value pairs.
551+
552+
#### Status Response Example
553+
554+
Report success or error without returning data:
555+
556+
```yaml
557+
api:
558+
actions:
559+
- action: validate_input
560+
variables:
561+
value: int
562+
then:
563+
- if:
564+
condition:
565+
lambda: 'return value < 0;'
566+
then:
567+
- api.respond:
568+
success: false
569+
error_message: "Value must be positive"
570+
else:
571+
- api.respond:
572+
success: true
573+
```
574+
575+
#### Data Response Example
576+
577+
Return structured JSON data to the caller:
578+
579+
```yaml
580+
api:
581+
actions:
582+
- action: get_sensor_data
583+
variables:
584+
sensor_name: string
585+
then:
586+
- api.respond:
587+
data: !lambda |-
588+
root["sensor"] = sensor_name;
589+
root["value"] = id(my_sensor).state;
590+
root["unit"] = "°C";
591+
root["timestamp"] = id(homeassistant_time).now().timestamp;
592+
```
593+
594+
This action will be auto-detected as `optional` mode because it uses `api.respond` with `data:`.
595+
596+
#### Query Action Example
597+
598+
For actions that always return data (like queries), explicitly set `supports_response: only`:
599+
600+
```yaml
601+
api:
602+
actions:
603+
- action: get_device_info
604+
supports_response: only
605+
then:
606+
- api.respond:
607+
data: !lambda |-
608+
root["hostname"] = App.get_name();
609+
root["version"] = ESPHOME_VERSION;
610+
root["uptime"] = millis() / 1000;
611+
```
612+
613+
#### Nested JSON Data
614+
615+
You can create complex nested JSON structures:
616+
617+
```yaml
618+
api:
619+
actions:
620+
- action: get_full_status
621+
supports_response: only
622+
then:
623+
- api.respond:
624+
data: !lambda |-
625+
root["device"]["name"] = "living_room";
626+
root["device"]["version"] = 1;
627+
root["sensors"]["temperature"] = id(temp_sensor).state;
628+
root["sensors"]["humidity"] = id(humidity_sensor).state;
629+
```
630+
631+
#### Calling from Home Assistant
632+
633+
Actions with response support appear in Home Assistant with their response mode indicated. You can call
634+
them and receive the response data:
635+
636+
```yaml
637+
# Home Assistant automation example
638+
action: esphome.device_get_sensor_data
639+
data:
640+
sensor_name: "living_room"
641+
response_variable: sensor_response
642+
```
643+
644+
The response will be available in the `sensor_response` variable with the structure you defined in the
645+
`data:` lambda.
646+
505647
## Advantages over MQTT
506648

507649
The ESPHome native API has many advantages over using MQTT for communication with Home

content/components/cc1101.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ cc1101:
5353
- **filter_bandwidth** (*Optional*, frequency): The receive filter bandwidth.
5454
Range: `58kHz` to `812kHz`. Defaults to `203kHz`.
5555
- **fsk_deviation** (*Optional*, frequency): Frequency deviation for FSK/GFSK modulation.
56+
Range: `1.5kHz` to `381kHz`.
57+
- **msk_deviation** (*Optional*, int): Deviation index for MSK modulation. Range: `1` to `8`.
5658
- **channel** (*Optional*, int): Channel number (added to base frequency). Defaults to `0`.
57-
- **channel_spacing** (*Optional*, frequency): Spacing between channels. Defaults to `200kHz`.
58-
- **if_frequency** (*Optional*, frequency): Intermediate Frequency. Defaults to `153kHz`.
59+
- **channel_spacing** (*Optional*, frequency): Spacing between channels.
60+
Range: `25kHz` to `405kHz`. Defaults to `200kHz`.
61+
- **if_frequency** (*Optional*, frequency): Intermediate Frequency.
62+
Range: `25kHz` to `788kHz`. Defaults to `153kHz`.
5963
- **pktlen** (*Optional*, int): Packet length configuration. Sets the expected packet size for
6064
fixed-length packet mode. Range: `1` to `255`. Not typically needed for OOK/ASK modulation.
6165

content/components/i2c.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ i2c:
5353
- **scl_pullup_enabled** (*Optional*, boolean): Enable the internal pullup resistor for the SCL pin.
5454
Defaults to `true`. Only available on ESP32.
5555

56+
- **low_power_mode** (*Optional*, boolean): Enable the low-power (master only) I²C bus.
57+
Only availible on ESP32C5, ESP32C6 and ESP32P4. Defaults to `false` unless required.
58+
5659
- **id** (*Optional*, [ID](/guides/configuration-types#id)): Manually specify the ID for this I²C bus if you need multiple I²C buses.
5760

5861
> [!NOTE]

content/components/micronova.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ micronova:
4949
### Configuration variables
5050
5151
- **enable_rx_pin** (**Required**, [Pin](/guides/configuration-types#pin)): Output pin to be used to switch the line between RX and TX.
52-
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked.
53-
Defaults to 60 seconds.
5452
5553
> [!NOTE]
5654
> For all text sensors, sensors, numbers, buttons and switches hereafter most of the the default **memory_location** and **memory_address** parameters will work so you should
5755
> not specify them. However your Micronova boad may require you to specify alternate values. So every text sensor, button,
5856
> switch or number accepts these parameters:
5957
>
60-
> - **memory_location** (*Optional*): The memory location where the parameter must be read. For most stoves this is 0x00 for RAM
61-
> or 0x20 for EPROM.
58+
> - **memory_location** (*Optional*): The memory location for the parameter (0x00 for RAM, 0x20 for EPROM on most stoves).
59+
> The write bit is set automatically when writing.
6260
>
6361
> - **memory_address** (*Optional*): The address where the parameter is stored.
6462
@@ -74,7 +72,8 @@ text_sensor:
7472
### Configuration variables
7573
7674
- **stove_state** (*Optional*): The current stove state.
77-
All options from [Text Sensor](/components/text_sensor#config-text_sensor).
75+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
76+
- All options from [Text Sensor](/components/text_sensor#config-text_sensor).
7877
7978
## Sensors
8079
@@ -103,27 +102,34 @@ sensor:
103102
### Configuration variables
104103
105104
- **room_temperature** (*Optional*): Sensor that reads the stoves ambient room temperature.
106-
All options from [Sensor](/components/sensor).
105+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
106+
- All options from [Sensor](/components/sensor).
107107
108108
- **fumes_temperature** (*Optional*): Fumes temperature.
109-
All options from [Sensor](/components/sensor).
109+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
110+
- All options from [Sensor](/components/sensor).
110111
111112
- **stove_power** (*Optional*): Current stove power.
112-
All options from [Sensor](/components/sensor).
113+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
114+
- All options from [Sensor](/components/sensor).
113115
114116
- **fan_speed** (*Optional*): Current fan speed. The raw value from the stove is multiplied by 10 + `fan_rpm_offset`.
115-
116117
- **fan_rpm_offset** (*Optional*, integer): Offset the reported RPM value. Must be between 0 and 255. Defaults to 0.
118+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
117119
- All other options from [Sensor](/components/sensor).
118-
- **water_temperature** (*Optional*): Internal boiler water termperature.
119-
All options from [Sensor](/components/sensor).
120+
121+
- **water_temperature** (*Optional*): Internal boiler water temperature.
122+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
123+
- All options from [Sensor](/components/sensor).
120124

121125
- **water_pressure** (*Optional*): Internal boiler water pressure.
122-
All options from [Sensor](/components/sensor).
126+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
127+
- All options from [Sensor](/components/sensor).
123128

124129
- **memory_address_sensor** (*Optional*): Can be any **memory_location** / **memory_address** you want to track. Usefull
125130
when you don't know where the parameter is for your stove is.
126-
All options from [Sensor](/components/sensor).
131+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
132+
- All options from [Sensor](/components/sensor).
127133

128134
## Numbers
129135

@@ -141,15 +147,11 @@ number:
141147

142148
- **thermostat_temperature** (*Optional*): Number that holds the current stove thermostat value.
143149
- **step** (*Optional*): Temperature step. This value is used to multiply/devide the raw value when setting/reading the **thermostat_temperature**
150+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
144151
- All other options from [Number](/components/number#config-number).
145152
- **power_level** (*Optional*): Number that sets/reads the requested stove power.
146-
All options from [Number](/components/number#config-number).
147-
148-
> [!NOTE]
149-
> Besides **memory_location** and **memory_address** you can specify a specific **memory_write_location** parameter.
150-
> This parameter is a hex value for the **memory_location** where the new thermostat value must be written.
151-
>
152-
> - **memory_write_location** (*Optional*): The **memory_location** where to write the new thermostat value.
153+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval that the sensors should be checked. Defaults to 60 seconds.
154+
- All options from [Number](/components/number#config-number).
153155

154156
## Buttons
155157

@@ -185,8 +187,10 @@ switch:
185187
### Configuration variables
186188

187189
- **stove** (*Optional*): Turn the stove on or off. This switch will also reflect the current stove state.
188-
If the **stove_state** is "Off" the switch will be off, in all other states, the switch wil be on.
189-
All options from [Switch](/components/switch#config-switch).
190+
If the **stove_state** is "Off" the switch will be off, in all other states, the switch will be on.
191+
- **update_interval** (*Optional*, [Time](/guides/configuration-types#time)): The interval at which the state should
192+
be checked. Defaults to 60 seconds.
193+
- All options from [Switch](/components/switch#config-switch).
190194

191195
> [!NOTE]
192196
> Besides **memory_location** and **memory_address** you can specify specific **memory_data_on** and **memory_data_off** parameters.

content/components/output/pca9685.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ output:
5353
channel: 0
5454
```
5555
56+
```yaml
57+
# Example configuration entry with disabled phase_balancer
58+
pca9685:
59+
- id: pca9685_hub1
60+
phase_balancer: none
61+
62+
# Individual outputs
63+
output:
64+
- platform: pca9685
65+
pca9685_id: 'pca9685_hub1'
66+
channel: 0
67+
- platform: pca9685
68+
pca9685_id: 'pca9685_hub1'
69+
channel: 1
70+
```
71+
5672
### Configuration variables
5773
5874
- **frequency** (*Optional*, float): The frequency to let the
@@ -66,6 +82,20 @@ output:
6682
- **id** (*Optional*, [ID](/guides/configuration-types#id)): The id to use for
6783
this pca9685 component. Use this if you have multiple PCA9685s connected at the same time
6884

85+
- **phase_balancer** (*Optional*, string): The phase balancer algorithm to use.
86+
See [Phase Balancer](#phase-balancer) below.
87+
88+
### Phase Balancer
89+
90+
The PCA9685 allows setting different phase angles on each output. The following algorithms can be used
91+
to set the phase angle of each output:
92+
93+
- `linear` (default): The phase angle is set by distributing all defined outputs equally among 360°.
94+
So with 3 outputs the first would have 0°, the second 120° and the last 240°. This algorithm can
95+
cause flickering when animating the light, because the PCA9685 chip will need an additional frame
96+
where no PWM is generated if the start angle is higher than the stop angle.
97+
- `none`: The phase angle is always 0°. This is the safer option if you control LED lights.
98+
6999
{{< anchor "pca9685-output" >}}
70100

71101
## PCA9685 Output

0 commit comments

Comments
 (0)