Skip to content

Commit

Permalink
Merge branch 'current' into guide_for_noobs
Browse files Browse the repository at this point in the history
  • Loading branch information
trip5 authored Nov 9, 2024
2 parents 33f813d + f53ecbe commit 21d9622
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "ESPHome"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2024.10.2
PROJECT_NUMBER = 2024.10.3

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ESPHOME_PATH = ../esphome
ESPHOME_REF = 2024.10.2
ESPHOME_REF = 2024.10.3
PAGEFIND_VERSION=1.1.1
PAGEFIND=pagefind
NET_PAGEFIND=../pagefindbin/pagefind
Expand Down
2 changes: 1 addition & 1 deletion _static/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.10.2
2024.10.3
7 changes: 7 additions & 0 deletions changelog/2024.10.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ Release 2024.10.2 - October 24
- [lvgl] Some properties were not templatable (Bugfix) :esphomepr:`7655` by :ghuser:`clydebarrow`
- [voice_assistant] Bugfix: Fix crash on start :esphomepr:`7662` by :ghuser:`kahrendt`

Release 2024.10.3 - November 8
------------------------------

- [rpi_dpi_rgb] Fix get_width and height (Bugfix) :esphomepr:`7675` by :ghuser:`clydebarrow`
- Fixes modbus timing error :esphomepr:`7674` by :ghuser:`exciton`
- [lvgl] Ensure images are configured before using them. (Bugfix) :esphomepr:`7721` by :ghuser:`clydebarrow`

Full list of changes
--------------------

Expand Down
2 changes: 1 addition & 1 deletion components/cover/current_based.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Configuration example:
scl: GPIO14
sensor:
- platform: ade7953
- platform: ade7953_i2c
irq_pin: GPIO16
voltage:
name: Shelly 2.5 Mains Voltage
Expand Down
16 changes: 13 additions & 3 deletions components/http_request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ can assign values to keys by using the ``root["KEY_NAME"] = VALUE;`` syntax as s
GET values from a JSON body response
************************************
If you want to retrieve the value for the vol key and assign it to a template sensor or number component whose id is
set to player_volume you can do this, but note that checking for the presence of the key will prevent difficult-to-read
error messages:


This example assumes that the server returns a response as a JSON object similar to this:
``{"status":"play","vol":"42","mute":"0"}``
Expand All @@ -263,14 +267,20 @@ whose ``id`` is set to ``player_volume``:
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
id(player_volume).publish_state(root["vol"]);
return true;
if (root["vol"]) {
id(player_volume).publish_state(root["vol"]);
return true;
}
else {
ESP_LOGD(TAG,"No 'vol' key in this json!");
return false;
}
});
See Also
--------

- :doc:`index`
- :apiref:`http_request/http_request.h`
- :doc:`/components/json`
- :ghedit:`Edit`
132 changes: 132 additions & 0 deletions components/json.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
json Component
==============

.. seo::
:description: Instructions for parsing and building json within ESPHome.
:keywords: json

The ``json`` component enables ESPHome to work with JSON data in automations, sensors, and HTTP requests. This is particularly useful for:

- Processing API responses
- Sending structured data to external services
- Parsing configuration from JSON files

What is JSON?

JSON is a text syntax that facilitates structured data interchange between all programming languages. JSON
is a syntax of braces, brackets, colons, and commas that is useful in many contexts, profiles, and applications.
JSON stands for JavaScript Object Notation and was inspired by the object literals of JavaScript aka
ECMAScript as defined in the `ECMAScript Language Specification, Third Edition <https://ecma-international.org/wp-content/uploads/ECMA-404_2nd_edition_december_2017.pdf>`_ .

Example 1: Relatively complex JSON

.. code-block:: json
{
"first_name": "John",
"last_name": "Smith",
"is_alive": true,
"age": 27,
"address": {
"street_address": "21 2nd Street",
"city": "New York",
"state": "NY",
"postal_code": "10021-3100"
},
"phone_numbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [
"Catherine",
"Thomas",
"Trevor"
],
"spouse": null
}
Example 2: Simple JSON:

.. code-block:: json
{"key": 42.0, "greeting": "Hello World"}
Parsing JSON:
-------------

This example assumes that the server returns a response as a JSON object similar to this:
``{"status":"play","vol":"42","mute":"0"}``


If you want to retrieve the value for the ``vol`` key and assign it to a template ``sensor`` or ``number`` component
whose ``id`` is set to ``player_volume`` you can do this, but note that checking for the presence of the key will prevent difficult-to-read error messages:

.. code-block:: yaml
on_...:
- http_request.get:
url: https://esphome.io
capture_response: true
on_response:
then:
- lambda: |-
json::parse_json(body, [](JsonObject root) -> bool {
if (root["vol"]) {
id(player_volume).publish_state(root["vol"]);
return true;
}
else {
ESP_LOGD(TAG,"No 'vol' key in this json!");
return false;
}
});
Building JSON:
--------------

You can build JSON in a lambda with a nested array like this:

.. code-block::
on_...:
- http_request.post:
url: https://esphome.io
json: |-
root["key"] = id(my_sensor).state;
root["greeting"] = "Hello World";
This will send::
``{"key": 42.0, "greeting": "Hello World"}``


Troubleshooting Errors:
-----------------------
A very common error when deserializing is:

.. code-block::
JSON parse error: InvalidInput
The software ESPHome uses does not provide particularly informative messages as to why, but
the people at ArduinoJson have created a `wonderful troubleshooter <https://arduinojson.org/troubleshooter>`__.

Another important resource is `JSONLint <https://jsonlint.com/>`__. It will help you determine if the JSON you are using is valid. It must be valid to work with ESPHome's deserializer and it probably needs to be valid for the destination, if you are sending it.


See Also
--------

- :doc:`index`
- :apiref:`http_request/http_request.h`
- :apiref:`json/json_util.h`
- `ArduinoJson <https://arduinojson.org/>`
- :ghedit:`Edit`

4 changes: 2 additions & 2 deletions components/mqtt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ in which case this is not needed.

.. warning::

If you enable MQTT and you do *not* use the "native API" for Home Assistant, you must
remove the ``api:`` line from your ESPHome configuration, otherwise the ESP will
If you enable MQTT and you do *not* use the :doc:`/components/api`, 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.

.. code-block:: yaml
Expand Down
2 changes: 1 addition & 1 deletion components/sensor/bme280.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Configuration variables:
See :ref:`Oversampling Options <bme280-oversampling>`.
- All other options from :ref:`Sensor <config-sensor>`.

- **humidity** (*Optional*): The information for the pressure sensor.
- **humidity** (*Optional*): The information for the humidity sensor.

- **oversampling** (*Optional*): The oversampling parameter for the temperature sensor.
See :ref:`Oversampling Options <bme280-oversampling>`.
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# The short X.Y version.
version = "2024.10"
# The full version, including alpha/beta/rc tags.
release = "2024.10.2"
release = "2024.10.3"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion cookbook/lvgl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1875,8 +1875,8 @@ The weather condition icons we use are from MDI. We import just the ones corresp
width: 228
height: 250
pad_all: 10
pad_column: 0
layout:
pad_column: 0
type: GRID
grid_rows: [FR(48), FR(13), FR(13), FR(13), FR(13)]
grid_columns: [FR(10), FR(40), FR(40), FR(10)]
Expand Down
10 changes: 9 additions & 1 deletion guides/supporters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ Contributors
- `杨成锴 (@asjdf) <https://github.com/asjdf>`__
- `Pavel Pletenev (@ASMfreaK) <https://github.com/ASMfreaK>`__
- `Andreas Soehlke (@asoehlke) <https://github.com/asoehlke>`__
- `Aaron Solochek (@asolochek) <https://github.com/asolochek>`__
- `Mike Dunston (@atanisoft) <https://github.com/atanisoft>`__
- `Glenn Morrison (@atomicpapa) <https://github.com/atomicpapa>`__
- `Alexander Turlov (@aturlov) <https://github.com/aturlov>`__
Expand Down Expand Up @@ -313,6 +314,7 @@ Contributors
- `Chris Feenstra (@cfeenstra1024) <https://github.com/cfeenstra1024>`__
- `Filipe Mendonça (@cfilipem) <https://github.com/cfilipem>`__
- `cg089 (@cg089) <https://github.com/cg089>`__
- `Chad Matsalla (@ChadMatsalla) <https://github.com/ChadMatsalla>`__
- `Kostas Chatzikokolakis (@chatziko) <https://github.com/chatziko>`__
- `chbmuc (@chbmuc) <https://github.com/chbmuc>`__
- `Audric Schiltknecht (@chemicalstorm) <https://github.com/chemicalstorm>`__
Expand Down Expand Up @@ -961,6 +963,7 @@ Contributors
- `João Vitor M. Roma (@jvmr1) <https://github.com/jvmr1>`__
- `Jack Wozny (@jwozny) <https://github.com/jwozny>`__
- `Jozef Zuzelka (@jzlka) <https://github.com/jzlka>`__
- `Jordan Zucker (@jzucker2) <https://github.com/jzucker2>`__
- `Kris (@K-r-i-s-t-i-a-n) <https://github.com/K-r-i-s-t-i-a-n>`__
- `k0rtina (@k0rtina) <https://github.com/k0rtina>`__
- `Harald Nagel (@k7hpn) <https://github.com/k7hpn>`__
Expand Down Expand Up @@ -1135,6 +1138,7 @@ Contributors
- `Kasper Malfroid (@malfroid) <https://github.com/malfroid>`__
- `Malle355 (@Malle355) <https://github.com/Malle355>`__
- `raymonder jin (@mamil) <https://github.com/mamil>`__
- `Manish Madan (@manishxmadan) <https://github.com/manishxmadan>`__
- `manonfgoo (@manonfgoo) <https://github.com/manonfgoo>`__
- `Manuel Kasper (@manuelkasper) <https://github.com/manuelkasper>`__
- `Manuel Díez (@manutenfruits) <https://github.com/manutenfruits>`__
Expand Down Expand Up @@ -1273,6 +1277,7 @@ Contributors
- `Sam Hughes (@MrEditor97) <https://github.com/MrEditor97>`__
- `MrEditor97 (@mreditor97) <https://github.com/mreditor97>`__
- `MRemy2 (@MRemy2) <https://github.com/MRemy2>`__
- `Mathieu Rene (@mrene) <https://github.com/mrene>`__
- `Morgan Robertson (@mrgnr) <https://github.com/mrgnr>`__
- `Simon Sasburg (@MrHacky) <https://github.com/MrHacky>`__
- `Mariusz Kryński (@mrk-its) <https://github.com/mrk-its>`__
Expand Down Expand Up @@ -1643,6 +1648,7 @@ Contributors
- `Sean True (@seantrue) <https://github.com/seantrue>`__
- `Sebastian Rasor (@sebastianrasor) <https://github.com/sebastianrasor>`__
- `sebcaps (@sebcaps) <https://github.com/sebcaps>`__
- `SeByDocKy (@SeByDocKy) <https://github.com/SeByDocKy>`__
- `Seganku (@seganku) <https://github.com/seganku>`__
- `Stefan Seyfried (@seife) <https://github.com/seife>`__
- `sekkr1 (@sekkr1) <https://github.com/sekkr1>`__
Expand Down Expand Up @@ -1692,6 +1698,7 @@ Contributors
- `smischny (@smischny) <https://github.com/smischny>`__
- `Jacob Masen-Smith (@smithjacobj) <https://github.com/smithjacobj>`__
- `John Mueller (@softplus) <https://github.com/softplus>`__
- `Kyle Cascade (@solarkennedy) <https://github.com/solarkennedy>`__
- `Luca Zimmermann (@soundstorm) <https://github.com/soundstorm>`__
- `Sourabh Jaiswal (@sourabhjaiswal) <https://github.com/sourabhjaiswal>`__
- `Philip Allgaier (@spacegaier) <https://github.com/spacegaier>`__
Expand Down Expand Up @@ -1962,6 +1969,7 @@ Contributors
- `Mike Brown (@xenoxaos) <https://github.com/xenoxaos>`__
- `xheronimo (@xheronimo) <https://github.com/xheronimo>`__
- `Huw Percival (@xhuw) <https://github.com/xhuw>`__
- `Luciano Martin (@xluciano) <https://github.com/xluciano>`__
- `Péter Sárközi (@Xmister) <https://github.com/Xmister>`__
- `xmos-jenkins (@xmos-jenkins) <https://github.com/xmos-jenkins>`__
- `xmos-jmccarthy (@xmos-jmccarthy) <https://github.com/xmos-jmccarthy>`__
Expand Down Expand Up @@ -2006,4 +2014,4 @@ Contributors
- `Christian Zufferey (@zuzu59) <https://github.com/zuzu59>`__
- `Zynth-dev (@Zynth-dev) <https://github.com/Zynth-dev>`__

*This page was last updated October 24, 2024.*
*This page was last updated November 8, 2024.*
1 change: 1 addition & 0 deletions images/json.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ ESPHome-specific components or components supporting ESPHome device provisioning
Improv via BLE, components/esp32_improv, improv.svg, dark-invert
Improv via Serial, components/improv_serial, improv.svg, dark-invert
Interval, components/interval, description.svg, dark-invert
JSON, components/json, json.svg, dark-invert
Script, components/script, description.svg, dark-invert

ESPHome Configuration
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sphinx==7.1.2
sphinx-autobuild==2021.3.14
sphinx-tabs==3.4.5
sphinx-tabs==3.4.7
sphinx-toolbox==3.8.0

0 comments on commit 21d9622

Please sign in to comment.