I am currently playing around with arduino and LED stripes.
There is a cool demo in the FastLED library wich generates a pulsing rainbow to a defined bpm.
I think it would be great if I openhab could get the bpm of a current playing song and sends the bpm value to the arduino.
So maybe someone likes this idea and could develope a binding or action to use the artist and titel of a song (supposed you already got these information in openhab) that returns the bpm.
Since you are not talking about actually listening to the audio and calculating the BPM, all you are really talking about is a lookup in a database. You should be able to implement this in a rule easily.
When the current playing song changes an Item (somehow) changes in OH. This triggers a rule and OH makes a call to that API using the http request actions, parses the BPM out of the result, and sends it to your Arduino. There is no need for a binding to do this.
import java.net.URLEncoder
rule "Test"
when
Item Test changed
then
logInfo("Test", "Test")
var String url = "https://api.getsongbpm.com/search/?api_key="
var String api_key = "********************************"
var String artist = "lorde"
var String song = "green light"
var String json = sendHttpGetRequest(url + api_key + "&type=both&lookup=artist:" + URLEncoder::encode(artist, 'UTF-8') + "+song:" + URLEncoder::encode(song, 'UTF-8'))
var String value = transform("JSONPATH", "$.search[0].tempo", json)
logDebug<------>("Test", "json: " + json)
logInfo("Test", "Tempo: " + value)
end
I am just posting this intermediate result, because it might take a while before I will finish this topic.
But it should be relatively easy to get the artist and song titel from existing items and do something with the tempo we get.