home_assistant_automation.yaml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. alias: Floppy Player
  2. description: ""
  3. trigger:
  4. - platform: state
  5. entity_id:
  6. - sensor.floppy_player_current_disc_id
  7. id: disc_changed
  8. - platform: state
  9. entity_id:
  10. - sensor.floppy_player_device_status
  11. id: EJECT
  12. to: EJECT
  13. - platform: state
  14. entity_id:
  15. - sensor.floppy_player_device_status
  16. id: PLAY
  17. to: PLAY
  18. enabled: true
  19. - platform: state
  20. entity_id:
  21. - sensor.floppy_player_device_status
  22. id: PAUSE
  23. to: PAUSE
  24. enabled: true
  25. condition: []
  26. action:
  27. - if:
  28. - condition: trigger
  29. id:
  30. - disc_changed
  31. then:
  32. - service: media_player.play_media
  33. data:
  34. media_content_id: "{{ states('sensor.floppy_player_current_disc_id') | string }}"
  35. media_content_type: "{{ states('sensor.floppy_player_current_disc_type') | string }}"
  36. target:
  37. entity_id: media_player.ytube_music_player
  38. - if:
  39. - condition: trigger
  40. id:
  41. - EJECT
  42. then:
  43. - service: media_player.media_stop
  44. target:
  45. entity_id: media_player.ytube_music_player
  46. data: {}
  47. - if:
  48. - condition: trigger
  49. id:
  50. - PLAY
  51. - PAUSE
  52. then:
  53. - service: media_player.media_play_pause
  54. target:
  55. entity_id:
  56. - media_player.ytube_music_player
  57. data: {}
  58. mode: single