I’ve already implemented this once using Home Assistant, but I was wondering if this could be done using the JSON HTTP or JSON features.
Built a wall panel with LED segments placed behind individual panels. Using HA, each segment gets assigned a random color then turned on for a short period of time. Sort of a Mondrian-inspired light show at periodic intervals.
I THOUGHT I could do this with a playlist and random colors, but the JSON API seems to have no facility to assign random colors to individual segments. Palettes and FX do seem to have the “r” flag for random, but a quick experiment found that unworkable with the “col” attribute within individual segments.
Am I missing something? Have someone managed to do something similar?
Thanks!
-J
SOLUTION:
Wasn’t able to find a way to solve this using JSON, but the HTTP request API can take segment info as well as random values for RGB values. For example:
&SS=0&R=r&G=r&B=r&W=r
This sets segment 0 (SS=0) to random values for R, G, B, and W respectively.
yes you can
you can also sewnd this jason command from every network item in the net
then no segment is needed you can access every light or lightstrip from-to at your command
1 Like
Could you provide just a short example?
@Rattykins
YES i use curl IP= your device on the network
turns on Node 0-13 with some green RGB value 0,176,0
curl -X POST "http://IP/json/state" -d '{"on":true, "bri":25, "seg":{"i":[
0,13,[0,176,0]]}}' -H "Content-Type: application/json"
1 Like
@Rattykins
you can alo run a batch like
led=1;for x in {0..14..1}; do r=$(jq -cn --arg led "$led" '($led|tonumber) as $led | {on:true,bri:25,seg:{i:[0,$led,[0,255,0],30-$led,[0,0,0]]}}'); curl -X POST "http://IP/json/state" -d $r -H "Content-Type: application/json";echo "nummer $led"; sleep 1;((led++)); done
Depending on system you might need a string builder
led=12 ; jq -cn --arg led "$led" '($led|tonumber) as $led | {on:true,bri:25,seg:{i:[0,$led,[0,255,0],30-$led,[0,0,0]]}}'
jq -cn --arg led "$led" '($led|tonumber) as $led | {on:true,bri:25,seg:{i:[0,$led,[0,255,0],30-$led,[0,0,0]]}}'
1 Like
All very cool. Will use this in the future! Thanks!
I was, however, unclear in my original post. Apologies.
The device I’m trying to do this on will have NO network connectivity; 100% standalone. So I’m trying to send API commands exclusively via Playlists/Presets; IE: no coding allowed.
With this restriction, I still haven’t found a way to simply assign a random color to an individual segment.
-J