MiczFlor / RPi-Jukebox-RFID

A Raspberry Pi jukebox, playing local music, podcasts, web radio and streams triggered by RFID cards, web app or home automation. All plug and play via USB. GPIO scripts available.
http://phoniebox.de
MIT License
1.37k stars 398 forks source link

Remote control with MQTT #581

Closed codegrau closed 1 year ago

codegrau commented 5 years ago

Hi there, thank you @MiczFlor and all contributors for this wonderful project.

Since mqtt is very common for smart home and home automation stuff I was wondering: wouldn't it be cool for phonieboxes to connect to a mqtt broker for other devices to know, which tune is playing and control phoniebox remotely?

This way you could easily integrate phoniebox to openHAB or HomeAssistant or even use cheap ESP8266 to control or visualize phoniebox contents.

Looking forward to your thoughts.

KingKahn123 commented 5 years ago

Ok that worked:

image

And my MQTT Server (IPSymcon) received the publish and saved it in the attribute:

image
andreasbrett commented 5 years ago

Alright, I think I fixed it. Please download the script once again from latest dev (see link above).

KingKahn123 commented 5 years ago

Perfect! It is working now ;-)

image
andreasbrett commented 5 years ago

Awesome! Thanks for the patience and enjoy it. Let me know if there's something missing that you need/want.

KingKahn123 commented 5 years ago

Are you kidding me?! Thanks for your patience and your help!

MiczFlor commented 5 years ago

I committed the last pull requests to master:

600

MiczFlor commented 5 years ago

And thanks for the lively discussion and great input!

andreasbrett commented 5 years ago

Thanks and sorry if we flooded your mailbox... 😜

whenthelight commented 5 years ago

PS: the new Function for Folderplay(which is incredible when i get this work as Switch and then in Google Home :-)) need some Parameters , are these the directory Path to Musicalbums ? like : /RPi-Jukebox-RFID/shared/audiofolders/Album1 or only Album1 ?

You simply pass the folder name (Album1). BTW: I primarily use the Basic UI to control openHAB and therefore would implement that with a String element that is linked to the MQTT topic "phoniebox/cmd/playfolder" and make a dropdown in the sitemap with pre-set folder names. Something like that:

Selection item=phoniebox_playfolder mappings=["Album1"="Tool - Fear Inocolum", "Album2"="Slipknot - We are not your kind"]

So if I select the Slipknot album from that dropdown the value "Album2" would be sent to the playfolder command. Not sure how you would handle that with your Google Home though.

Hey andreasbrett, If i select only 1 Album , i can handle this as Switch with 1 Value (Album1). Items create as Switch et voila my Son is happy ;-) . Volume are configured as Dimmer and Lightning. The Reaction Time is awesome fast. Sleeptimer also as Switch with Value in my Case 60 for 60min. Play and Pause also works good as Switch.

georgbachmann commented 5 years ago

Thank you guys a lot for this addon! I can't wait to realize a wake-up-alarm for my kids with it! I can run it and it also works if I run it manually like so: python3 RPi-Jukebox-RFID/scripts/daemon_mqtt_client.py. But when I follow the instructions on the wiki page and then run sudo systemctl status phoniebox-mqtt-client at the end, I always get error messages:

pi@phoniebox:~ $ sudo systemctl status phoniebox-mqtt-client
● phoniebox-mqtt-client.service - Phoniebox MQTT Client Service
   Loaded: loaded (/etc/systemd/system/phoniebox-mqtt-client.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-10-13 19:59:43 BST; 1min 42s ago
  Process: 531 ExecStart=/home/pi/RPi-Jukebox-RFID/scripts/daemon_mqtt_client.py (code=exited, status=203/EXEC)
 Main PID: 531 (code=exited, status=203/EXEC)

Oct 13 19:59:42 phoniebox systemd[1]: phoniebox-mqtt-client.service: Failed with result 'exit-code'.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Service hold-off time over, scheduling restart.
Oct 13 19:59:43 phoniebox systemd[1]: Stopped Phoniebox MQTT Client Service.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Start request repeated too quickly.
Oct 13 19:59:43 phoniebox systemd[1]: Failed to start Phoniebox MQTT Client Service.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Unit entered failed state.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Failed with result 'exit-code'.

Do you guys have any idea what the problem might be? I already tried rebooting... but didn't work.

whenthelight commented 5 years ago

Thank you guys a lot for this addon! I can't wait to realize a wake-up-alarm for my kids with it! I can run it and it also works if I run it manually like so: python3 RPi-Jukebox-RFID/scripts/daemon_mqtt_client.py. But when I follow the instructions on the wiki page and then run sudo systemctl status phoniebox-mqtt-client at the end, I always get error messages:

pi@phoniebox:~ $ sudo systemctl status phoniebox-mqtt-client
● phoniebox-mqtt-client.service - Phoniebox MQTT Client Service
   Loaded: loaded (/etc/systemd/system/phoniebox-mqtt-client.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2019-10-13 19:59:43 BST; 1min 42s ago
  Process: 531 ExecStart=/home/pi/RPi-Jukebox-RFID/scripts/daemon_mqtt_client.py (code=exited, status=203/EXEC)
 Main PID: 531 (code=exited, status=203/EXEC)

Oct 13 19:59:42 phoniebox systemd[1]: phoniebox-mqtt-client.service: Failed with result 'exit-code'.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Service hold-off time over, scheduling restart.
Oct 13 19:59:43 phoniebox systemd[1]: Stopped Phoniebox MQTT Client Service.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Start request repeated too quickly.
Oct 13 19:59:43 phoniebox systemd[1]: Failed to start Phoniebox MQTT Client Service.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Unit entered failed state.
Oct 13 19:59:43 phoniebox systemd[1]: phoniebox-mqtt-client.service: Failed with result 'exit-code'.

Do you guys have any idea what the problem might be? I already tried rebooting... but didn't work.

Show was going on with : journalctl -u phoniebox-mqtt-client.service

georgbachmann commented 4 years ago

Sorry for the super late reply... so much stuff going on currently and so little time for the fun stuff... The message I am getting was essentially:

phoniebox-mqtt-client.service: Failed at step EXEC spawning /home/pi/RPi-Jukebox-RFID/scripts/daemon_mqtt_client.py: Permission denied

So I simply ran chmod +x daemon_mqtt_client.py any everything is now working as expected... awesome :) Excited to see how long my kids will like "Guten morgen Sonnenschein" as their wake up sound :) haha

Again... thanks for that MQTT plugin! Love it!

andreasbrett commented 4 years ago

So I simply ran chmod +x daemon_mqtt_client.py any everything is now working as expected

Ah I see. I had not pushed the file via git but instead pasted its contents here on github. That's why the file attributes are missing. Thanks for pointing out!

MiczFlor commented 4 years ago

Hi @andreasbrett can you create a pull request, please?

andreasbrett commented 4 years ago

Hi @andreasbrett can you create a pull request, please?

Of course. It's done.

s-martin commented 4 years ago

Description for MQTT in https://github.com/MiczFlor/RPi-Jukebox-RFID/wiki/Smart-Home-remote-control-with-MQTT

Closing this issue now.