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

Usermod: httpPullLightControl v0.0.5 (supersede v0.0.4) #3560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d431aa4
Show 2D Config button by default
w00000dy Oct 25, 2023
34bed44
Hide 2D Configuration if 2D is not compiled in
w00000dy Oct 25, 2023
96700fe
Fix for udp sync (#3487)
blazoncek Oct 27, 2023
e5f6f8d
Twinklefox & Twinklecat fix
blazoncek Oct 28, 2023
284366e
fixed wrong power supply info
w00000dy Oct 29, 2023
ccc56d4
Merge pull request #3484 from WoodyLetsCode/settings-page
blazoncek Oct 31, 2023
e260b94
Bump build
blazoncek Oct 31, 2023
555d0d3
Npm & version comment
blazoncek Nov 1, 2023
4f5816f
Merge branch '0_14_1' into power-supply
blazoncek Nov 1, 2023
031526b
Correction
blazoncek Nov 1, 2023
fb6271e
Merge pull request #3496 from WoodyLetsCode/power-supply
blazoncek Nov 1, 2023
5b7b34a
Add LDR sensor dusk/dawn preset control Usermod
Nov 2, 2023
1543862
Merge pull request #3490 from JeffWDH/main
blazoncek Nov 2, 2023
9db8d44
Sort presets by ID
blazoncek Nov 4, 2023
7c121b8
Dissolve fix (#3502)
blazoncek Nov 8, 2023
51dfa9a
Implement front-end strategy to prevent caching
Moustachauve Nov 9, 2023
e67a210
Implement back-end strategy to prevent caching
Moustachauve Nov 9, 2023
7238ef4
Fix repeatable action for ir json
marcin20 Nov 13, 2023
8825423
Update to v0.0.3, allowing all WLED JSON giving much more possibilities
Nov 13, 2023
71cec39
update to 0.0.4 includes SHA1 hash instead of old 10digit hash
Nov 15, 2023
c340a1d
Bugfix (#3526)
blazoncek Nov 15, 2023
44726c7
Changelog 0.14.1-b1
blazoncek Nov 16, 2023
eca3fb1
Revert "Implement front-end strategy to prevent caching"
Moustachauve Nov 17, 2023
a83d9a0
Merge pull request #3508 from Moustachauve/fix-settings-cache
blazoncek Nov 17, 2023
1661766
Bugfix (#3533)
blazoncek Nov 18, 2023
76a7f25
Merge pull request #3522 from martinez20m/fix_ir_repeat
blazoncek Nov 18, 2023
75f6a53
Fix (#3522)
blazoncek Nov 18, 2023
1e29d94
validate NTP responses (fixes #3515)
softhack007 Nov 20, 2023
80c67d3
bufix: ntp query when NTP gets enabled from UI
softhack007 Nov 20, 2023
d56cefd
indentation fix
softhack007 Nov 20, 2023
5fb891c
indentation fix2
softhack007 Nov 20, 2023
32e724e
Merge pull request #3536 from Aircoookie/ntp_errorchecking
softhack007 Nov 20, 2023
c3e937f
Fix for #3514
blazoncek Nov 27, 2023
ff82d36
Update readme.md
srg74 Nov 28, 2023
f66b343
Possible fix for #3541
blazoncek Nov 28, 2023
230af48
Fixing parsing only VALID JSON, in the past, when invalid JSON, the W…
Nov 28, 2023
b0d0bb7
Merge pull request #3555 from srg74/patch-1
blazoncek Nov 29, 2023
4873031
Bugfix #3561
blazoncek Dec 1, 2023
7c108e5
Bugfix for SEGENV if defult map1D2D not defined
blazoncek Dec 1, 2023
de4b352
Fix AsyncClient hangs
Dec 2, 2023
cb95a7d
Autowhite cleanup
blazoncek Dec 9, 2023
f513cae
code spell checking - part1 (core)
softhack007 Dec 14, 2023
9f79e64
code spell checking - part2 (dependencies)
softhack007 Dec 14, 2023
dbe8554
code spell checking - part3 (usermods)
softhack007 Dec 14, 2023
d6735be
comment clean-up (cosmetic)
softhack007 Dec 14, 2023
082d1ee
oappend robustness improvement
softhack007 Dec 14, 2023
1ec3a74
Manila Time is the same as CST (solves #3517)
softhack007 Dec 14, 2023
a8bd46c
bugfix - unusable pins on pico32 boards (#3573)
softhack007 Dec 14, 2023
6d28de7
npm run build
softhack007 Dec 14, 2023
da488f7
LDR_Dusk_Dawn: use pinManager, check ldrPin before use (quick-fix for…
softhack007 Dec 15, 2023
5c90a74
Fix for #3593
blazoncek Dec 17, 2023
7642c5a
Merge pull request #3529 from Aircoookie/0_14_1
blazoncek Dec 18, 2023
10faaaf
Build bump & changelog
blazoncek Dec 18, 2023
5ed02d2
Merge branch 'upstream/0_14_2' into usermod_v2_HttpPullLightControl_0…
Dec 23, 2023
c92cef1
Merge branch '0_15' into usermod_v2_HttpPullLightControl_0.0.5
blazoncek Feb 9, 2024
500a730
Fix merge error
blazoncek Feb 9, 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
110 changes: 110 additions & 0 deletions usermods/usermod_v2_HttpPullLightControl/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# usermod_v2_HttpPullLightControl

The `usermod_v2_HttpPullLightControl` is a custom user module for WLED that enables remote control over the lighting state and color through HTTP requests. It periodically polls a specified URL to obtain a JSON response containing instructions for controlling individual lights.

## Features

* Configure the URL endpoint (only support HTTP for now, no HTTPS) and polling interval via the WLED user interface.
* All options from the JSON API are supported (since v0.0.3). See: https://kno.wled.ge/interfaces/json-api/
* The ability to control the brightness of all lights and the state (on/off) and color of individual lights remotely.
* Start or stop an effect and when you run the same effect when its's already running, it won't restart.
* The ability to control all these settings per segment.
* Remotely turn on/off relays, change segments or presets.
* Unique ID generation based on the device's MAC address and a configurable salt value, appended to the request URL for identification.

## Configuration
* Enable the `usermod_v2_HttpPullLightControl` via the WLED user interface.
* Specify the URL endpoint and polling interval.

## JSON Format and examples
* The module sends a GET request to the configured URL, appending a unique identifier as a query parameter: `https://www.example.com/mycustompage.php?id=xxxxxxxx` where xxxxxxx is a 40 character long SHA1 hash of the MAC address combined with a given salt.

* Response Format (since v0.0.3) it is eactly the same as the WLED JSON API, see: https://kno.wled.ge/interfaces/json-api/
After getting the URL (it can be a static file like static.json or a mylogic.php which gives a dynamic response), the response is read and parsed to WLED.

* An example of a response to set the individual lights: 0 to RED, 12 to Green and 14 to BLUE. Remember that is will SET lights, you might want to set all the others to black.
`{
"seg":
{
"i": [
0, "FF0000",
12, "00FF00",
14, "0000FF"
]
}
}`

* Another example setting the first 10 LEDs to RED, LED 40 to a PURPLE (using RGB values) and all LEDs in between OFF (black color)
`{
"seg":
{
"i": [
0,10, "FF0000",
10,40, "00FF00",
40, [0,100,100]
]
}
}`

* Or first set all lights to black (off), then the LED5 to color RED:
`{
"seg":
{
"i": [
0,40, "000000",
5, "FF0000"
]
}
}`

* Or use the following example to start an effect, but first we UNFREEZE (frz=false) the segment because it was frozen by individual light control in the previous examples (28=Chase effect, Speed=180m Intensity=128). The three color slots are the slots you see under the color wheel and used by the effect. RED, Black, White in this case.
`{
"seg":
{
"frz": false,
"fx": 28,
"sx": 200,
"ix": 128,
"col": [
"FF0000",
"000000",
"FFFFFF"
]
}
}`


## Installation

1. Add `usermod_v2_HttpPullLightControl` to your WLED project following the instructions provided in the WLED documentation.
2. Compile by setting the build_flag: -D USERMOD_HTTP_PULL_LIGHT_CONTROL and upload to your ESP32/ESP8266!
3. There are several compile options which you can put in your platformio.ini or platformio_override.ini:
- -DUSERMOD_HTTP_PULL_LIGHT_CONTROL ;To Enable the usermod
- -DHTTP_PULL_LIGHT_CONTROL_URL="\"http://mydomain.com/json-response.php\"" ; The URL which will be requested all the time to set the lights/effects
- -DHTTP_PULL_LIGHT_CONTROL_SALT="\"my_very-S3cret_C0de\"" ; A secret SALT which will help by making the ID more safe
- -DHTTP_PULL_LIGHT_CONTROL_INTERVAL=30 ; The interval at which the URL is requested in seconds
- -DHTTP_PULL_LIGHT_CONTROL_HIDE_SALT ; Do you want to Hide the SALT in the User Interface? If yes, Set this flag. Note that the salt can now only be set via the above -DHTTP_PULL_LIGHT_CONTROL_SALT= setting

- -DWLED_AP_SSID="\"Christmas Card\"" ; These flags are not just for my Usermod but you probably want to set them
- -DWLED_AP_PASS="\"christmas\""
- -DWLED_OTA_PASS="\"otapw-secret\""
- -DMDNS_NAME="\"christmascard\""
- -DSERVERNAME="\"CHRISTMASCARD\""
- -D ABL_MILLIAMPS_DEFAULT=450
- -D DEFAULT_LED_COUNT=60 ; For a LED Ring of 60 LEDs
- -D BTNPIN=41 ; The M5Stack Atom S3 Lite has a button on GPIO41
- -D LEDPIN=2 ; The M5Stack Atom S3 Lite has a Grove connector on the front, we use this GPIO2
- -D STATUSLED=35 ; The M5Stack Atom S3 Lite has a Multi-Color LED on GPIO35, although I didnt managed to control it
- -D IRPIN=4 ; The M5Stack Atom S3 Lite has a IR LED on GPIO4

- -D DEBUG=1 ; Set these DEBUG flags ONLY if you want to debug and read out Serial (using Visual Studio Code - Serial Monitor)
- -DDEBUG_LEVEL=5
- -DWLED_DEBUG

## Use Case: Interactive Christmas Cards

Imagine distributing interactive Christmas cards embedded with a tiny ESP32 and a string of 20 LEDs to 20 friends. When a friend powers on their card, it connects to their Wi-Fi network and starts polling your server via the `usermod_v2_HttpPullLightControl`. (Tip: Let them scan a QR code to connect to the WLED WiFi, from there they configure their own WiFi).

Your server keeps track of how many cards are active at any given time. If all 20 cards are active, your server instructs each card to light up all of its LEDs. However, if only 4 cards are active, your server instructs each card to light up only 4 LEDs. This creates a real-time interactive experience, symbolizing the collective spirit of the holiday season. Each lit LED represents a friend who's thinking about the others, and the visual feedback creates a sense of connection among the group, despite the physical distance.

This setup demonstrates a unique way to blend traditional holiday sentiments with modern technology, offering an engaging and memorable experience.
Loading
Loading