Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions components/espcontrol/configuration_release_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ namespace espcontrol::configuration {
constexpr LegacyConfigurationMode PANEL_CONFIG_LEGACY_MODE =
LegacyConfigurationMode::NATIVE_ONLY;
constexpr std::array<uint16_t, 2> PANEL_CONFIG_STORAGE_READ_VERSIONS = {1, 2};
constexpr uint16_t PANEL_CONFIG_DURABLE_WRITE_VERSION = 1;
constexpr uint16_t PANEL_CONFIG_DURABLE_WRITE_VERSION = 2;
constexpr uint16_t PANEL_CONFIG_STORAGE_READ_NAVIGATION_DEPTH = 2;
constexpr uint16_t PANEL_CONFIG_STORAGE_WRITE_NAVIGATION_DEPTH = 1;
static_assert(PANEL_CONFIG_DURABLE_WRITE_VERSION == CURRENT_CONFIGURATION_DOCUMENT_VERSION);
constexpr uint16_t PANEL_CONFIG_STORAGE_WRITE_NAVIGATION_DEPTH = 2;
static_assert(PANEL_CONFIG_DURABLE_WRITE_VERSION == 1 || PANEL_CONFIG_DURABLE_WRITE_VERSION == 2);
static_assert(PANEL_CONFIG_STORAGE_READ_NAVIGATION_DEPTH >= 1 && PANEL_CONFIG_STORAGE_READ_NAVIGATION_DEPTH <= 2);
static_assert(PANEL_CONFIG_STORAGE_WRITE_NAVIGATION_DEPTH >= 1 &&
PANEL_CONFIG_STORAGE_WRITE_NAVIGATION_DEPTH <= PANEL_CONFIG_STORAGE_READ_NAVIGATION_DEPTH);
Expand Down
6 changes: 4 additions & 2 deletions components/espcontrol/panel_config_service_validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace espcontrol::configuration {

// Ship both readers while the durable writer stays v1. Firmware supplies the
// Read both stored formats and save using the release policy. Firmware supplies the
// same PSRAM-only temporary allocator as the service; no index is retained.
class PanelConfigDocumentValidator final
: public ConfigurationDocumentValidator {
Expand All @@ -20,9 +20,11 @@ class PanelConfigDocumentValidator final
document_version) != PANEL_CONFIG_STORAGE_READ_VERSIONS.end();
}
bool supports_write_version(uint16_t version) const override {
// Flat layouts can still fit in v1 when their v2 representation exceeds
// the storage limit. Replacement admission separately protects nested pages.
return version == PANEL_CONFIG_DURABLE_WRITE_VERSION ||
(version == 1 && supports_version(1) && PANEL_CONFIG_DURABLE_WRITE_VERSION == 2 &&
PANEL_CONFIG_LEGACY_MODE == LegacyConfigurationMode::READ_IMPORT_ONLY);
PANEL_CONFIG_LEGACY_MODE != LegacyConfigurationMode::DUAL_WRITE);
}
uint16_t write_version() const override { return PANEL_CONFIG_DURABLE_WRITE_VERSION; }

Expand Down
4 changes: 3 additions & 1 deletion docs/features/subpages.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ To customise the **Back** card, select it in the web preview and click **Edit**.

You can also right-click an empty space on the home screen and choose **Create Subpage**.

Subpages can contain Switch, Lights, Action, Local Action, Option Select, Webhook, Trigger, Sensor, Local Sensor, Doors & Windows, Presence, Slider, Fans, Vacuum, Lawn Mower, Cover, Garage Door, Lock, Alarm, Date & Time, Clock, World Clock, Weather, Camera, Media, Climate, Internal Switches, and Screen Lock cards. Subpages cannot contain another Subpage card.
Subpages can contain Switch, Lights, Action, Local Action, Option Select, Webhook, Trigger, Sensor, Local Sensor, Doors & Windows, Presence, Slider, Fans, Vacuum, Lawn Mower, Cover, Garage Door, Lock, Alarm, Date & Time, Clock, World Clock, Weather, Camera, Media, Climate, Internal Switches, and Screen Lock cards.

The web editor offers **Subpage** as a card type inside a first-level subpage when the panel supports saving nested subpages. Use **Back** to return one level at a time. Firmware v2.17.0 can open saved second-level subpages.

## Automate Panel Navigation and Controls

Expand Down
8 changes: 4 additions & 4 deletions product/release_contract.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"schemaVersion": 1,
"productModelVersion": 2,
"panelConfigDocumentVersion": 1,
"panelConfigDocumentVersion": 2,
"panelConfigReadVersions": [1, 2],
"panelConfigWriteVersion": 1,
"panelConfigWriteVersion": 2,
"panelConfigReadNavigationDepth": 2,
"panelConfigWriteNavigationDepth": 1,
"panelConfigMinimumReaderRelease": null,
"panelConfigWriteNavigationDepth": 2,
"panelConfigMinimumReaderRelease": "v2.17.0",
"webAssetVersion": 2,
"panelConfigCompatibility": {
"phase": "native-only",
Expand Down
10 changes: 6 additions & 4 deletions scripts/check_release_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
DEVICE_MANIFEST = ROOT / "devices" / "manifest.json"
WEB_MANIFEST = ROOT / "docs" / "public" / "webserver" / "web-assets.json"
DOCUMENT_HEADER = ROOT / "components" / "espcontrol" / "panel_config_document.h"
SERVICE_HEADER = ROOT / "components" / "espcontrol" / "configuration_service.h"
CAPABILITIES_HEADER = ROOT / "components" / "espcontrol" / "panel_config_capabilities.h"
COMPATIBILITY_POLICY = ROOT / "components" / "espcontrol" / "configuration_release_policy.h"
FIRMWARE_MODES = {
Expand Down Expand Up @@ -172,7 +171,7 @@ def verify(*, product_model_path: Path = PRODUCT_MODEL,
assert product_model["modelVersion"] == contract["productModelVersion"], (
"Product Model version disagrees with release contract"
)
document_version = constant(SERVICE_HEADER, "CURRENT_CONFIGURATION_DOCUMENT_VERSION")
document_version = constant(compatibility_policy_path, "PANEL_CONFIG_DURABLE_WRITE_VERSION")
capabilities = CAPABILITIES_HEADER.read_text(encoding="utf-8")
assert "PANEL_CONFIG_DURABLE_WRITE_VERSION" in capabilities, (
"firmware capabilities do not advertise the PanelConfig document version"
Expand All @@ -183,7 +182,7 @@ def verify(*, product_model_path: Path = PRODUCT_MODEL,
assert document_version == contract["panelConfigDocumentVersion"], (
"PanelConfig document version disagrees with release contract"
)
assert constant(compatibility_policy_path, "PANEL_CONFIG_DURABLE_WRITE_VERSION") == document_version == contract.get("panelConfigWriteVersion"), (
assert document_version == contract.get("panelConfigWriteVersion"), (
"durable write policy disagrees with release contract"
)
assert constant(compatibility_policy_path, "PANEL_CONFIG_STORAGE_READ_NAVIGATION_DEPTH") == read_depth and \
Expand Down Expand Up @@ -236,6 +235,7 @@ def self_test() -> None:
future = json.loads(json.dumps(contract))
future["panelConfigCompatibility"]["phase"] = "dual-write"
future["panelConfigDocumentVersion"] = future["panelConfigWriteVersion"] = 2
future["panelConfigWriteNavigationDepth"] = 1
for floor, history, expected in [
(None, [], False),
("v2.10.0", [], False),
Expand All @@ -253,7 +253,7 @@ def self_test() -> None:
read_import_contract = json.loads(json.dumps(contract))
read_import_contract["panelConfigCompatibility"]["phase"] = "read-import-only"
read_import_contract.update(panelConfigDocumentVersion=2, panelConfigWriteVersion=2,
panelConfigMinimumReaderRelease="v2.10.0")
panelConfigWriteNavigationDepth=1, panelConfigMinimumReaderRelease="v2.10.0")

def published(phase: str, tag: str) -> dict:
manifest_contract = json.loads(json.dumps(read_import_contract))
Expand Down Expand Up @@ -309,6 +309,8 @@ def published(phase: str, tag: str) -> dict:
native_only_policy = native_only_contract["panelConfigCompatibility"]
native_only_policy["phase"] = "native-only"
native_only_policy["legacyGatewayRelease"] = "v2.15.0"
native_only_contract.update(panelConfigDocumentVersion=1, panelConfigWriteVersion=1,
panelConfigWriteNavigationDepth=1, panelConfigMinimumReaderRelease=None)
def published_v1(phase: str, tag: str) -> dict:
release = published(phase, tag)
release["manifest"]["releaseContract"].update(
Expand Down
4 changes: 2 additions & 2 deletions tests/firmware/panel_config_capabilities_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ int main() {
&capabilities_size) &&
std::strstr(capabilities.data(), "\"document_versions\":[1,2]") != nullptr &&
std::strstr(capabilities.data(), "\"default_document_version\":1") != nullptr &&
std::strstr(capabilities.data(), "\"durable_document_version\":1") != nullptr &&
std::strstr(capabilities.data(), "\"durable_document_version\":2") != nullptr &&
std::strstr(capabilities.data(), "\"max_navigation_depth\":2") != nullptr &&
std::strstr(capabilities.data(), "\"writable_navigation_depth\":1") != nullptr &&
std::strstr(capabilities.data(), "\"writable_navigation_depth\":2") != nullptr &&
std::strstr(capabilities.data(), "\"max_v2_document_bytes\":524288") != nullptr &&
std::strstr(capabilities.data(), "\"preserves_inactive_records\":true") != nullptr &&
std::strstr(capabilities.data(), "\"read\":true") != nullptr &&
Expand Down
9 changes: 5 additions & 4 deletions tests/firmware/panel_config_dual_boot_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
#include "page_store_runtime.h"
#include "panel_config_legacy_adapter.h"
#include "panel_config_runtime_adapter.h"
#include "panel_config_service_validator.h"
#include "panel_config_test_policies.h"

using namespace espcontrol;
using namespace espcontrol::configuration;
using namespace espcontrol::pages;
using espcontrol::configuration::test::DepthOnePanelConfigPolicy;
using Bytes=std::vector<uint8_t>;
using Row=PanelConfigV2Record;
using Kind=PanelConfigV2Kind;
Expand Down Expand Up @@ -93,7 +94,7 @@ struct Fixture {
Backend backend;ConfigurationStore store{backend};Text order,color;
std::array<Text,32> buttons;std::array<std::array<Text,8>,32> chunks;
PanelConfigTextBindings bindings;PanelConfigLegacyAdapter legacy{bindings,allocate,release};
PanelConfigDocumentValidator validator{allocate,release};ConfigurationService service{store,legacy,&validator};
DepthOnePanelConfigPolicy<1> validator{allocate,release};ConfigurationService service{store,legacy,&validator};
Arena arena;PageStoreRuntime runtime;
explicit Fixture(const DeviceUiLimits &limits):runtime(limits,arena,128*1024) {
bindings.set_device_profile(limits.device_profile);bindings.set_button_order(&order);bindings.set_button_on_color(&color);
Expand Down Expand Up @@ -303,7 +304,7 @@ void imports_cannot_enable_v2_writes() {
bool mirror(uint16_t,const uint8_t *,size_t)override {assert(false);return false;}
} legacy;
legacy.document=native(DEVICE_UI_PROFILES[8],false);
Backend backend;ConfigurationStore store(backend);PanelConfigDocumentValidator validator(allocate,release);
Backend backend;ConfigurationStore store(backend);DepthOnePanelConfigPolicy<1> validator(allocate,release);
ConfigurationService service(store,legacy,&validator);Bytes output(32768);
assert(validator.supports_version(2)&&!validator.supports_write_version(2));
assert(service.load(output.data(),output.size()).status==ServiceStatus::UNSUPPORTED_VERSION);
Expand All @@ -317,5 +318,5 @@ int main() {
publication_repair_and_transient_buffers();
permanent_legacy_limit_does_not_retry_writes();
profiles();unavailable_and_publication();imports_cannot_enable_v2_writes();assert(allocations.empty());
std::cout<<"PASS actual ECDO v2 boot, v1 write policy, all nine ordinary/maximum profiles, inactive/empty preservation, compatibility fencing and allocation failures; transient service/compatibility peak="<<peak<<" bytes (host, excludes runtime arenas)\n";
std::cout<<"PASS actual ECDO v2 boot, previous v1 write policy, all nine ordinary/maximum profiles, inactive/empty preservation, compatibility fencing and allocation failures; transient service/compatibility peak="<<peak<<" bytes (host, excludes runtime arenas)\n";
}
38 changes: 10 additions & 28 deletions tests/firmware/panel_config_http_versions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "panel_config_read_endpoint.h"
#include "panel_config_write_endpoint.h"
#include "panel_config_capabilities_endpoint.h"
#include "panel_config_service_validator.h"
#include "panel_config_test_policies.h"
#include "panel_config_legacy_adapter.h"
#include "durable_format_fixture.h"

Expand Down Expand Up @@ -179,33 +179,15 @@ std::unique_ptr<PageRuntimeResources> renderer(const DeviceUiLimits& limits,Aren
default:assert(false);return {};
}
}
// Test-only future policy. Stable product policy remains the declared v1 writer.
struct FutureGraphWriter:ConfigurationDocumentValidator {
PanelConfigDocumentValidator content{allocate,release};
bool supports_version(uint16_t version)const override{return content.supports_version(version);}
uint16_t write_version()const override{return 2;}
bool supports_write_version(uint16_t version)const override{return version==1||version==2;}
bool checks_replacements(uint16_t version)const override{return content.checks_replacements(version);}
bool replacement_needs_document(uint16_t current,uint16_t incoming)const override{return content.replacement_needs_document(current,incoming);}
ServiceStatus replacement_status(uint16_t current,const uint8_t*bytes,size_t size,uint16_t incoming)const override {
return content.replacement_status(current,bytes,size,incoming);
}
bool validate(uint16_t version,const uint8_t*bytes,size_t size)const override{return content.validate(version,bytes,size);}
ServiceStatus validation_status(uint16_t version,const uint8_t*bytes,size_t size)const override{return content.validation_status(version,bytes,size);}
};
struct FutureFlatWriter:FutureGraphWriter {
ServiceStatus write_validation_status(uint16_t version,const uint8_t*bytes,size_t size)const override {
return content.write_validation_status(version,bytes,size);
}
};
using espcontrol::configuration::test::DepthOnePanelConfigPolicy;
struct Fixture {
Backend backend;ConfigurationStore store{backend};Legacy legacy;PanelConfigDocumentValidator validator{allocate,release};
Backend backend;ConfigurationStore store{backend};Legacy legacy;DepthOnePanelConfigPolicy<1> validator{allocate,release};
ConfigurationService service;ConfigurationMainLoop queue;Arena arena;
RendererPort port;std::unique_ptr<PageRuntimeResources> render_resources;PageRuntimeResourcesGroup<1> resources;
PageStoreRuntime runtime;PanelConfigReadHandler reader;PanelConfigWriteHandler writer;
explicit Fixture(const DeviceUiLimits &limits,const ConfigurationDocumentValidator*policy=nullptr,
LegacyConfigurationMode mode=LegacyConfigurationMode::DUAL_WRITE):legacy(limits),
service(store,legacy,policy?policy:&validator,nullptr,0,mode),port(limits),render_resources(renderer(limits,arena,port)),
service(store,legacy,policy ? policy : &validator,nullptr,0,mode),port(limits),render_resources(renderer(limits,arena,port)),
resources({{render_resources.get()}}),runtime(limits,arena,128*1024,&resources) {
service.set_runtime_adapter(&runtime);
bind_panel_config_http_context(service,queue,40*1024,allocate,release,"user","password");
Expand Down Expand Up @@ -603,7 +585,7 @@ void oversized_flat_v2_uses_lossless_durable_v1() {
}();
assert(source.size() < 40932 && v2.size() > 40932);
for (const char *format : {"1", "2"}) {
FutureGraphWriter policy;
PanelConfigDocumentValidator policy{allocate,release};
Fixture f(DEVICE_UI_PROFILES[4], &policy, LegacyConfigurationMode::READ_IMPORT_ONLY);
const auto &input = *format == '1' ? source : v2;
const auto saved = f.put(input, format, *format == '1' ? "\"1\"" : "\"v2-1\"");
Expand Down Expand Up @@ -638,14 +620,14 @@ void oversized_flat_v2_uses_lossless_durable_v1() {
}
void original_format_survives_a_future_writer_conversion() {
{
FutureGraphWriter policy;Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
PanelConfigDocumentValidator policy{allocate,release};Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
const auto old=fixture.get("1").response;
const auto saved=fixture.put(old,nullptr,"\"1\"");
assert(status(saved)==204&&saved.sent_headers.at("X-Panel-Config-Durable-Version")=="2");
assert(records(fixture.get("1").response)==records(old));
}
for(bool restored:{false,true}) {
FutureGraphWriter policy;Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
PanelConfigDocumentValidator policy{allocate,release};Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
const auto old=fixture.get("1").response,old_v2=fixture.get("2").response;
const auto nested=nested_document();fixture.seed_v2(nested);
if(restored) {
Expand All @@ -670,7 +652,7 @@ void original_format_survives_a_future_writer_conversion() {
assert(fixture.get("2").response==old_v2&&fixture.runtime.active().generation()==3);
}
for(bool http:{false,true}) {
FutureGraphWriter policy;Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
PanelConfigDocumentValidator policy{allocate,release};Fixture fixture(DEVICE_UI_PROFILES[8],&policy);
const auto old=fixture.get("1").response,old_v2=fixture.get("2").response;
const auto nested=nested_document();bool replaced=false;
const auto preferences=fixture.legacy.preference_writes();
Expand All @@ -682,7 +664,7 @@ void original_format_survives_a_future_writer_conversion() {
}
}
void native_graph_publication_returns_success() {
FutureGraphWriter policy;
PanelConfigDocumentValidator policy{allocate,release};
Fixture fixture(DEVICE_UI_PROFILES[8],&policy,LegacyConfigurationMode::READ_IMPORT_ONLY);
const auto old=fixture.get("1").response;
const auto source=nested_document();
Expand Down Expand Up @@ -715,7 +697,7 @@ void native_graph_publication_returns_success() {
assert(!fixture.service.compatibility_state().retry_pending());
}
void flat_v2_writer_rejects_nested_http_publication() {
FutureFlatWriter policy;
DepthOnePanelConfigPolicy<2> policy{allocate,release};
Fixture fixture(DEVICE_UI_PROFILES[8],&policy,LegacyConfigurationMode::READ_IMPORT_ONLY);
const auto original=fixture.get("2").response;
const auto nested=nested_document();
Expand Down
Loading