Get music playlist from Youtube and play music using home assistant API.
cd ./front-end
npm install
npm run build
cd ../back-end
npm install
make ./back-end/config/property.js
refering below example
module.exports = {
redis_host: 'redis',
redis_port: '6379',
google_api_key: 'GOOGLE_API_KEY',
hass_api_key: 'HOME_ASSISTANT_API_KEY',
HASS_DNS: 'https://YOUR_HA_DNS'
}
cd ./back-end
npm start
- docker platform
- docker-compose
- Install redis
# Sample docker-compose.yml
version: "3.5"
services:
redis:
image: redis:alpine3.11
container_name: redis
volumes:
- "/storage/redis:/data"
ports:
- 26379:6379
networks:
- backend
restart: always
entrypoint: redis-server --appendonly yes
networks:
backend:
driver: bridge
- Install yt-player by dockerfile
# Sample docker-compose.yml
version: "3.5"
services:
yt-player:
image: gaussian8/yt-player:[TAG]
container_name: yt-player
volumes:
- "./property.js:/app/back-end/config/property.js:ro"
ports:
- 6001:3000
restart: always
networks:
default:
external:
name: redis_backend
- Modify homeassistant config file refering below
configuration.yml
# Sample media_extractor: panel_iframe: yt_player: title: 'Youtube' icon: mdi:youtube url: 'https://YOUR_YT_PLAYER_DOMAIN' rest_command: play_media_next: url: http://localhost:6001/api/entities/{{entity_id}}/next method: POST play_media_stop: url: http://localhost:6001/api/entities/{{entity_id}}/stop method: POST automation: - alias: NextMusic description: '' trigger: - entity_id: YOUR_MEDIA_PLAYER_ENTITY_ID from: playing platform: state to: idle condition: [] action: - data: entity_id: YOUR_MEDIA_PLAYER_ENTITY_ID service: rest_command.play_media_next - alias: StopMusic description: '' trigger: - entity_id: YOUR_MEDIA_PLAYER_ENTITY_ID from: palying platform: state to: 'off' - entity_id: YOUR_MEDIA_PLAYER_ENTITY_ID from: paused platform: state to: 'off' condition: [] action: - data: entity_id: YOUR_MEDIA_PLAYER_ENTITY_ID service: rest_command.play_media_stop