esphome / esp-web-tools

Open source tools to allow working with ESP devices in the browser
https://esphome.github.io/esp-web-tools/
Apache License 2.0
450 stars 120 forks source link

Custom Manifest creation on the fly #498

Open lost-hope opened 7 months ago

lost-hope commented 7 months ago

Hello, i am currently looking into rebuilding a webinstaller where i would like to have the user select the flash size and some other options that would result in a high number of possible combinations and thus manifest files.

While looking around in the issues, i found this reply (https://github.com/esphome/esp-web-tools/issues/469#issuecomment-1926157937 ) by @balloob.

In my opinion i would be able to craft a manifest string based on the User input, but i cant write that to a file and provide that to the install button.

Is there a way around that, or does this need more development in the install scripts?

lost-hope commented 7 months ago

i have looked into this a bit. with a small change in the install dialog script this is possible. but my implementation will break the current manifest file method. there might be a way to use a if statement to filter between them. Is there a technical reason why the code is minified? Ok can answer myself after some research. It can improve performance

velijv commented 4 months ago

https://veli.ee/esphome/ota.manifest.json?name=TX-Ultimate&chip=esp32&summary=Cool-new-colors&v=1234

ex:

{
    "name": "re5v1c",
    "version": "123",
    "home_assistant_domain": "esphome",
    "builds": [
        {
            "chipFamily": "ESP8266",
            "ota": {
                "md5": "f5fb10347f29d944897db09975b39f29",
                "path": "http://homeassistant.local:8123/local/ota/re5v1c/firmware.ota.bin",
                "release_url": "http://re5v1c.local",
                "summary": "re5v1c has a new Update"
            },
            "parts": [
                {
                    "path": "http://homeassistant.local:8123/local/ota/re5v1c/firmware.factory.bin",
                    "offset": 0
                }
            ]
        }
    ]
}
pbolduc commented 2 months ago

I think a simple way of handling this would be to make manifest property be either a string or a Promise that returns a Manifest.

https://github.com/esphome/esp-web-tools/blob/b7b4b5beba5a496fa4ff29a0df2659364fd57344/src/install-button.ts#L55C3-L55C28

From:

public manifest?: string;

To:

public manifest?: string | Promise<Manifest>;

or

public manifest?: string;
public manifestResolver?: Promise<Manifest>;

If the value is a string, then it would refer to the path to fetch the manifest like it does now. If the value is a Promise , then it await the promise and the resulting should return the manifest value. Alternatively, another property could be added that would return the manifest such as manifestFactory manifestProvider manifestResolver, etc.