TobKra96 / music_led_strip_control

Audio visualization for LED strips in real-time with web interface on a raspberry pi.
https://tobkra96.github.io/music_led_strip_control/
MIT License
298 stars 64 forks source link

is it possible to trigger Effects from extern #94

Closed BomBastikDE closed 3 years ago

BomBastikDE commented 3 years ago

Is it posible to trigger the effects from Extern (like an Smarthome Tablet) over an Http-adress? I want insert the controll of MLSC in my ioBroker Project.

TobKra96 commented 3 years ago

Hi, we use a Rest API to communicate between the web interface. Maybe you can use an adapter for this.

E.g. Rest enpoint: http:///SetActiveEffectForAll Json content: {effect: "effect_gradient"}

See this issue: https://github.com/TobKra96/music_led_strip_control/issues/48 PHP Example: https://gist.github.com/TobKra96/7004030cfb846f9792b3ec2afe423275 Available effects: https://github.com/TobKra96/music_led_strip_control/blob/master/server/libs/effects_enum.py

Teraskull commented 3 years ago

Adding some full examples, so that others can find this answer. This works for both Linux and Windows.

cURL:

curl -X POST -H "Content-Type: application/json" -d "{\"effect\": \"effect_gradient\"}" http://[YOUR_IP]:8080/SetActiveEffectForAll

Python:

import requests

r = requests.post('http://[YOUR_IP]:8080/SetActiveEffectForAll', json={"effect": "effect_gradient"})
TobKra96 commented 3 years ago

done, I will add a entry inside the faq