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

[web_server] v3 entity grouping #6833

Merged
merged 45 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0f0268a
init
RFDarter May 30, 2024
8e48abe
add const.py
RFDarter May 30, 2024
3043d6f
order constants
RFDarter May 30, 2024
2fa1b26
hash intead off __hash__
RFDarter May 30, 2024
47a83a3
Send groups on connect as sorting_group event to client
RFDarter Jun 2, 2024
983cd2c
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jun 2, 2024
c8ef26d
remove unused this
RFDarter Jun 2, 2024
e45cec6
Merge branch 'webserver-v3-entity-grouping' of https://github.com/RFD…
RFDarter Jun 2, 2024
495ec22
replace unsigned long long with uint64_t
RFDarter Jun 2, 2024
4fa91d7
change config option to sorting_groups instead of sorting_group
RFDarter Jun 2, 2024
207759c
support button
RFDarter Jun 2, 2024
ecebd97
validate that `sorting_groups` is only allowed on v3
RFDarter Jun 2, 2024
3c1c39b
rejig sorting schema
RFDarter Jun 2, 2024
cb3579e
add tests
RFDarter Jun 2, 2024
5b7f84a
fix tests
RFDarter Jun 2, 2024
bd7cb69
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jun 5, 2024
2df6219
use constant for "web_server", rename add_entity_config to add_entity…
RFDarter Jun 9, 2024
1fbf5f2
sorting_weight and sorting_group for valve
RFDarter Jun 9, 2024
2730417
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jun 9, 2024
1881e51
use const on alarm component, add tests to web_server component
RFDarter Jun 9, 2024
d9dbc1b
Revert "add tests"
RFDarter Jun 20, 2024
c3aa32c
web_server tests
RFDarter Jun 20, 2024
a7b5962
Merge branch 'webserver-v3-entity-grouping' of https://github.com/RFD…
RFDarter Jun 20, 2024
98c3e96
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jun 20, 2024
d852a97
`update` component
RFDarter Jun 20, 2024
96ebd91
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jun 27, 2024
5a034ff
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Jul 20, 2024
7366fdd
merge dev
RFDarter Jul 20, 2024
349b886
move tests in a v3 file
RFDarter Jul 20, 2024
84b3615
spaces
RFDarter Jul 20, 2024
25d5c09
use packages in tests
RFDarter Jul 25, 2024
abacb45
add v3 tests
RFDarter Jul 25, 2024
3609b11
remove duplicate components in v3 tests
RFDarter Jul 25, 2024
d3dca4a
Merge remote-tracking branch 'upstream/dev' into webserver-v3-entity-…
RFDarter Jul 25, 2024
a513b9e
simplify
RFDarter Jul 25, 2024
5e0f43c
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Sep 27, 2024
79e5907
fix merging dev
RFDarter Sep 27, 2024
c3a9044
fix 2 merge dev
RFDarter Sep 27, 2024
b2e8d5d
rename sorting_group to sorting_group_id
RFDarter Sep 27, 2024
b6c9368
fix test for renameing sorting_group_id
RFDarter Sep 27, 2024
309740b
Merge branch 'dev' into webserver-v3-entity-grouping
jesserockz Sep 30, 2024
07ca5fc
Tidy up a little2
jesserockz Sep 30, 2024
7cab710
Merge branch 'dev' into webserver-v3-entity-grouping
jesserockz Sep 30, 2024
075ecee
Merge branch 'dev' into webserver-v3-entity-grouping
RFDarter Oct 1, 2024
47f3956
Discard changes to esphome/components/esp32_camera/__init__.py
jesserockz Oct 2, 2024
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
7 changes: 3 additions & 4 deletions esphome/components/alarm_control_panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CONF_MQTT_ID,
CONF_ON_STATE,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -195,9 +195,8 @@ async def setup_alarm_control_panel_core_(var, config):
for conf in config.get(CONF_ON_READY, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)
if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)
if mqtt_id := config.get(CONF_MQTT_ID):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/binary_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
CONF_STATE,
CONF_TIMING,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_CARBON_MONOXIDE,
Expand Down Expand Up @@ -543,9 +543,8 @@ async def setup_binary_sensor_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_binary_sensor(var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/button/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
CONF_MQTT_ID,
CONF_ON_PRESS,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_IDENTIFY,
DEVICE_CLASS_RESTART,
Expand Down Expand Up @@ -97,9 +97,8 @@ async def setup_button_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_button(var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/climate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
CONF_TEMPERATURE_STEP,
CONF_TRIGGER_ID,
CONF_VISUAL,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -408,9 +408,8 @@ async def setup_climate_core_(var, config):
trigger, [(ClimateCall.operator("ref"), "x")], conf
)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_climate(var, config):
Expand Down
9 changes: 4 additions & 5 deletions esphome/components/cover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
CONF_TILT_COMMAND_TOPIC,
CONF_TILT_STATE_TOPIC,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_AWNING,
DEVICE_CLASS_BLIND,
DEVICE_CLASS_CURTAIN,
Expand Down Expand Up @@ -137,10 +137,6 @@ async def setup_cover_core_(var, config):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)

if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)
Expand All @@ -156,6 +152,9 @@ async def setup_cover_core_(var, config):
if (tilt_command_topic := config.get(CONF_TILT_COMMAND_TOPIC)) is not None:
cg.add(mqtt_.set_custom_tilt_command_topic(tilt_command_topic))

if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_cover(var, config):
if not CORE.has_id(config[CONF_ID]):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/datetime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
CONF_TIME_ID,
CONF_TRIGGER_ID,
CONF_TYPE,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
CONF_YEAR,
)
from esphome.core import CORE, coroutine_with_priority
Expand Down Expand Up @@ -138,9 +138,8 @@ async def setup_datetime_core_(var, config):
if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)
if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)
for conf in config.get(CONF_ON_VALUE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [(cg.ESPTime, "x")], conf)
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/fan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
CONF_SPEED_LEVEL_STATE_TOPIC,
CONF_SPEED_STATE_TOPIC,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -218,9 +218,8 @@ async def setup_fan_core_(var, config):
if (speed_command_topic := config.get(CONF_SPEED_COMMAND_TOPIC)) is not None:
cg.add(mqtt_.set_custom_speed_command_topic(speed_command_topic))

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)

for conf in config.get(CONF_ON_STATE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/light/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
CONF_RESTORE_MODE,
CONF_TRIGGER_ID,
CONF_WARM_WHITE_COLOR_TEMPERATURE,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -181,9 +181,8 @@ async def setup_light_core_(light_var, output_var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, light_var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, light_var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(light_var, web_server_config)


async def register_light(output_var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/lock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
CONF_ON_LOCK,
CONF_ON_UNLOCK,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -66,9 +66,8 @@ async def setup_lock_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_lock(var, config):
Expand Down
8 changes: 3 additions & 5 deletions esphome/components/number/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
CONF_TRIGGER_ID,
CONF_UNIT_OF_MEASUREMENT,
CONF_VALUE,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_APPARENT_POWER,
DEVICE_CLASS_AQI,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
Expand Down Expand Up @@ -254,10 +254,8 @@ async def setup_number_core_(
if (mqtt_id := config.get(CONF_MQTT_ID)) is not None:
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_number(
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CONF_OPERATION,
CONF_OPTION,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_generator import MockObjClass
Expand Down Expand Up @@ -104,9 +104,8 @@ async def setup_select_core_(var, config, *, options: list[str]):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_select(var, config, *, options: list[str]):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
CONF_TYPE,
CONF_UNIT_OF_MEASUREMENT,
CONF_VALUE,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
CONF_WINDOW_SIZE,
DEVICE_CLASS_APPARENT_POWER,
DEVICE_CLASS_AQI,
Expand Down Expand Up @@ -800,9 +800,8 @@ async def setup_sensor_core_(var, config):
else:
cg.add(mqtt_.set_expire_after(expire_after))

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_sensor(var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/switch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CONF_ON_TURN_ON,
CONF_RESTORE_MODE,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_OUTLET,
DEVICE_CLASS_SWITCH,
Expand Down Expand Up @@ -156,9 +156,8 @@ async def setup_switch_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)

if (device_class := config.get(CONF_DEVICE_CLASS)) is not None:
cg.add(var.set_device_class(device_class))
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
CONF_ON_VALUE,
CONF_TRIGGER_ID,
CONF_VALUE,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity
Expand Down Expand Up @@ -82,9 +82,8 @@ async def setup_text_core_(
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_text(
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/text_sensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
CONF_STATE,
CONF_TO,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_DATE,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_TIMESTAMP,
Expand Down Expand Up @@ -212,9 +212,8 @@ async def setup_text_sensor_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id, var)
await mqtt.register_mqtt_component(mqtt_, config)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_text_sensor(var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/update/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
CONF_FORCE_UPDATE,
CONF_ID,
CONF_MQTT_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_FIRMWARE,
ENTITY_CATEGORY_CONFIG,
Expand Down Expand Up @@ -73,9 +73,8 @@ async def setup_update_core_(var, config):
mqtt_ = cg.new_Pvariable(mqtt_id_config, var)
await mqtt.register_mqtt_component(mqtt_, config)

if web_server_id_config := config.get(CONF_WEB_SERVER_ID):
web_server_ = await cg.get_variable(web_server_id_config)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_update(var, config):
Expand Down
7 changes: 3 additions & 4 deletions esphome/components/valve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
CONF_STATE,
CONF_STOP,
CONF_TRIGGER_ID,
CONF_WEB_SERVER_ID,
CONF_WEB_SERVER,
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_GAS,
DEVICE_CLASS_WATER,
Expand Down Expand Up @@ -124,9 +124,8 @@ async def setup_valve_core_(var, config):
mqtt_.set_custom_position_command_topic(position_command_topic_config)
)

if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
web_server_ = await cg.get_variable(webserver_id)
web_server.add_entity_to_sorting_list(web_server_, var, config)
if web_server_config := config.get(CONF_WEB_SERVER):
await web_server.add_entity_config(var, web_server_config)


async def register_valve(var, config):
Expand Down
Loading