home_assistant_automation.yaml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. - platform: state
  26. entity_id:
  27. - sensor.floppy_player_device_status
  28. id: SKIP
  29. to: SKIP
  30. enabled: true
  31. - platform: state
  32. entity_id:
  33. - sensor.floppy_player_device_status
  34. id: RADIO
  35. to: RADIO
  36. enabled: true
  37. condition: []
  38. action:
  39. - if:
  40. - condition: trigger
  41. id:
  42. - disc_changed
  43. then:
  44. - service: media_player.play_media
  45. data:
  46. media_content_id: "{{ states('sensor.floppy_player_current_disc_id') | string }}"
  47. media_content_type: "{{ states('sensor.floppy_player_current_disc_type') | string }}"
  48. target:
  49. entity_id: media_player.ytube_music_player
  50. - if:
  51. - condition: trigger
  52. id:
  53. - EJECT
  54. then:
  55. - service: media_player.media_stop
  56. target:
  57. entity_id: media_player.ytube_music_player
  58. data: {}
  59. - if:
  60. - condition: trigger
  61. id:
  62. - PLAY
  63. - PAUSE
  64. then:
  65. - service: media_player.media_play_pause
  66. target:
  67. entity_id:
  68. - media_player.ytube_music_player
  69. data: {}
  70. - if:
  71. - condition: trigger
  72. id:
  73. - SKIP
  74. then:
  75. - service: media_player.media_next_track
  76. target:
  77. entity_id:
  78. - media_player.ytube_music_player
  79. data: {}
  80. - if:
  81. - condition: trigger
  82. id:
  83. - RADIO
  84. then:
  85. - alias: RadioOnSong
  86. sequence:
  87. - service: media_player.play_media
  88. data:
  89. media_content_id: |
  90. {{state_attr("media_player.ytube_music_player","videoId") }}
  91. media_content_type: vid_channel
  92. entity_id: media_player.ytube_music_player
  93. mode: single