sidoh / esp8266_milight_hub

Replacement for a Milight/LimitlessLED hub hosted on an ESP8266
MIT License
931 stars 219 forks source link

Editing the Interface #809

Closed KitKat-ok closed 8 months ago

KitKat-ok commented 8 months ago

How can I change the web interface? changing the index.html doesnt seem to do anything

sidoh commented 8 months ago

It needs to be compiled. There's a script that does it here, although you'll need to install node and npm:

https://github.com/sidoh/esp8266_milight_hub/blob/master/.build_web.py

ultimately everything winds up in this compiled progmem string, which is what's served from the web interface:

https://github.com/sidoh/esp8266_milight_hub/blob/master/dist/index.html.gz.h

going to close this since it was a question, but feel free to keep the discussion going if you have followups.

KitKat-ok commented 8 months ago

I get an error when I try to execute it @sidoh Traceback (most recent call last): File "/esp8266_milight_hub/.build_web.py", line 8, in <module> Import("env") ^^^^^^ NameError: name 'Import' is not defined

sidoh commented 8 months ago

It's run as a part of the platformio build. I don't think you can run it directly. You'll need to compile and upload a firmware image with something like platformio run -e d1_mini -t upload. That should build the web image.

KitKat-ok commented 8 months ago

Oh it works now thanks. I have another question how can I set the state of a bulb like turn it on or off in the arduino code ??

sidoh commented 8 months ago

Here's an example: https://github.com/sidoh/esp8266_milight_hub/blob/master/lib/WebServer/MiLightHttpServer.cpp#L363

KitKat-ok commented 8 months ago

I cant get it to work can you explain it a bit further? @sidoh

sidoh commented 8 months ago

The rough flow is something like this:

const uint16_t deviceId = 1234;
const uint8_t groupId = 1;
// config is a MiLightRemoteConfig. there are constants available. For example, FUT096Config is for rgbw
auto config = FUT096Config;

milightClient->prepare(&config, deviceId, groupId);
// call any methods on milightClient to change state:
milightClient->updateStatus(MiLightStatus::ON);
milightClient->updateBrightness(255);