Esp-radio
Esp-radio copied to clipboard
Fun: ESP-Radio + MQTT + OpenHAB Intergration
Not cleaned up, but was having some fun hacking around with MQTT on the ESP-Radio and OpenHAB.

Updated...

/opt/openhab/conf/sitemaps/demo.sitemap
Frame label="ESP-Radio Control" {
Switch item=PlayerCTRL label="Controls" mappings=[1=Mute,2=Resume,3=Stop,4=Unmute]
Selection item=ESPRadio_Station mappings=[0=Lounge, 1=Chill, 2=Boost, 3=Indie]
Slider item=ESPVolume
Text item=NowPlaying
/opt/openhab/conf/items/demo.items
Number PlayerCTRL "Controls" <player>
Number ESPRadio_Station "ESP Radio" <network> { mqtt=">[broker:espradio:command:*:preset=${command}]" }
Dimmer ESPVolume "Volume [%s %%]" <soundvolume> { mqtt=">[broker:espradio:command:*:volume=${command}]" }
String NowPlaying "Now Playing: [%s]" <keyring> { mqtt="<[broker:espradio\nowplaying:state:default]" }
/opt/openhab/conf/items/demo.rules
rule "Player Controls"
when
Item PlayerCTRL received command
then
if(PlayerCTRL.state == 1)
{
publish("broker","espradio","mute")
}
if(PlayerCTRL.state == 2)
{
publish("broker","espradio","resume")
}
if(PlayerCTRL.state == 3)
{
publish("broker","espradio","stop")
}
if(PlayerCTRL.state == 4)
{
publish("broker","espradio","unmute")
}
PlayerCTRL.postUpdate(NULL)
end