From ffeee72652d358a9ea04ce409c09d595b7922786 Mon Sep 17 00:00:00 2001 From: Martin Bauer Date: Fri, 8 Mar 2024 13:02:43 +0100 Subject: [PATCH] music mouse setup --- full.yml | 12 +++++- inventory.yml | 9 ++-- roles/pi-musicmouse/files/config.yml | 40 ++++++++++++++++++ roles/pi-musicmouse/files/musicmouse.service | 11 +++++ roles/pi-musicmouse/files/smb.conf | 15 +++++++ roles/pi-musicmouse/tasks/main.yml | 38 +++++++++++++++++ working.yml | 43 +++++++++++++------- 7 files changed, 148 insertions(+), 20 deletions(-) create mode 100644 roles/pi-musicmouse/files/config.yml create mode 100644 roles/pi-musicmouse/files/musicmouse.service create mode 100644 roles/pi-musicmouse/files/smb.conf create mode 100644 roles/pi-musicmouse/tasks/main.yml diff --git a/full.yml b/full.yml index f435970..9269c88 100644 --- a/full.yml +++ b/full.yml @@ -41,13 +41,21 @@ - pi-disable-onboard-bluetooth - bluetooth-monitor +- hosts: musicmouse + roles: + - pi-standard-setup + - pi-hifiberry-amp + - pi-musicmouse + - pi-squeezelite-custom + - pi-shairport + - pi-lirc + - bluetooth-monitor + #- hosts: octopi # roles: # - pi-dhtsensor - #- hosts: newrpi # roles: # - pi-standard-setup # - pi-lirc - diff --git a/inventory.yml b/inventory.yml index d9e9948..1557325 100644 --- a/inventory.yml +++ b/inventory.yml @@ -40,12 +40,13 @@ all: sensor_room_name_ascii: wohnzimmeroben sensor_room_name: WohnzimmerOben hifiberry_overlay: hifiberry-dacplus - my_btmonitor_pl0: 68 # default is 73 - increase to make more sensitve (i.e. lower distances) musicmouse: squeezelite_name: MusicMouse shairport_name: MusicMouse - alsa_card_name: 0 + alsa_card_name: 1 hifiberry_overlay: hifiberry-dacplus + sensor_room_name: Kinderzimmer + sensor_room_name_ascii: kinderzimmer newrpi: squeezelite_name: MyTestRaspberry shairport_name: MyTestRaspberry @@ -56,7 +57,9 @@ all: server: sensor_room_name: Arbeitszimmer sensor_room_name_ascii: arbeitszimmer - my_btmonitor_pl0: 78 + homeassistant: + sensor_room_name: Anschlussraum + sensor_room_name_ascii: anschlussraum vars: ansible_user: root ansible_python_interpreter: /usr/bin/python3 diff --git a/roles/pi-musicmouse/files/config.yml b/roles/pi-musicmouse/files/config.yml new file mode 100644 index 0000000..71454ce --- /dev/null +++ b/roles/pi-musicmouse/files/config.yml @@ -0,0 +1,40 @@ +general: + alsa_device: softvol_effects + mqtt: + user: musicmouse + password: KNLEFLZF94yA6Zhj141 + server: homeassistant + hass_url: https://ha.bauer.tech + hass_token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4N2ExMzM2ZmQ4ZWQ0ZDgzOWZhMjU3NmZjYTg1NWQ1ZiIsImlhdCI6MTcwNDAyOTUyOSwiZXhwIjoyMDE5Mzg5NTI5fQ.vx9L5bTSey98uc8TwodShaEXSMr-hjXugPsNviR_fEw" + button_leds_brightness: 0.5 + volume_increment: 5 + min_volume: 23 + max_volume: 70 + serial_port: "/dev/ttyUSB0" + +figures: + elefant: + id: "88041174e9" + colors: ["#ffff00", "#00c8ff", "#094b46", "#c20099"] + fuchs: + id: "8804ce7230" + colors: ["#F4D35E", "#F95738", "#F95738", "#083d77"] + eule: + id: "88040d71f0" + colors: ["#e5a200", "#f8e300", "w33", "w99"] + omnom: + id: "88043c6ede" + colors: ["#005102", "#fec800", "#005102", "#3bc405"] + eichhoernchen: + id: "88040b78ff" + colors: ["#ff0ada", "#4BC6B9", "#69045a", "#4BC6B9"] + hund: + id: "8804bc7444" + colors: ["#ffff00", "#00c8ff", "#094b46", "#c20099"] + hase: + id: "88044670ba" + colors: ["#ffff00", "#00c8ff", "#094b46", "#c20099"] + schneemann: + id: "88043f71c2" + colors: ["#ff0ada", "#4BC6B9", "#69045a", "#4BC6B9"] + diff --git a/roles/pi-musicmouse/files/musicmouse.service b/roles/pi-musicmouse/files/musicmouse.service new file mode 100644 index 0000000..a09758c --- /dev/null +++ b/roles/pi-musicmouse/files/musicmouse.service @@ -0,0 +1,11 @@ +[Unit] +Description=MusicMouse Player +After=network.target + +[Service] +Type=simple +Restart=always +ExecStart=/opt/musicmouse_venv/bin/python /opt/musicmouse/espmusicmouse/host_driver/main.py /media/musicmouse/ + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/pi-musicmouse/files/smb.conf b/roles/pi-musicmouse/files/smb.conf new file mode 100644 index 0000000..27845d0 --- /dev/null +++ b/roles/pi-musicmouse/files/smb.conf @@ -0,0 +1,15 @@ +[global] + workgroup = WORKGROUP + logging = syslog@1 + server role = standalone server + obey pam restrictions = no + unix password sync = no + + +[MusicMouse] + browseable = yes + path = /media/musicmouse + guest ok = no + writeable = yes + create mask = 666 + force create mode = 666 diff --git a/roles/pi-musicmouse/tasks/main.yml b/roles/pi-musicmouse/tasks/main.yml new file mode 100644 index 0000000..93e1911 --- /dev/null +++ b/roles/pi-musicmouse/tasks/main.yml @@ -0,0 +1,38 @@ +--- +- name: Packages + apt: + name: + - python3 + - python3-pip + - python3-vlc # also in venv - but this installs vlc + deps + - samba +- name: Checkout Musicmouse repo + ansible.builtin.git: + repo: 'ssh://git@git.bauer.tech:2222/martin/musicmouse.git' + dest: '/opt/musicmouse' + version: 'release/1.1' + accept_hostkey: true +- name: Create and update virtual env + ansible.builtin.pip: + requirements: /opt/musicmouse/espmusicmouse/host_driver/requirements.txt + virtualenv: /opt/musicmouse_venv + virtualenv_command: "/usr/bin/python3 -m venv" +- name: Create media directory + file: + path: /media/musicmouse + state: directory +- name: Install config file + copy: src=config.yml dest=/media/musicmouse/config.yml +- name: Install systemd service file + copy: src=musicmouse.service dest=/etc/systemd/system/ +- name: Add script to autostart and start now + systemd: name=musicmouse state=restarted enabled=yes daemon_reload=yes +- name: Samba setup + copy: src=smb.conf dest=/etc/samba/ +- name: Restart samba + systemd: name=smbd state=restarted enabled=yes +# manual steps: +# - set samba passwords with smbpasswd +# - copy music into /media/musicmouse (or via samba share) +# - upload host driver? +# - manual patching of hassclient necessary :( loop has to be passed in, to not use running_event_loop diff --git a/working.yml b/working.yml index 52dba27..0c51ecc 100644 --- a/working.yml +++ b/working.yml @@ -1,20 +1,33 @@ --- -- hosts: server - roles: - - bluetooth-monitor +#- hosts: server +# roles: +# - bluetooth-monitor +# +#- hosts: musikserverwohnzimmeroben +# roles: +# - bluetooth-monitor +# +#- hosts: kitchenpi +# roles: +# - pi-disable-onboard-bluetooth +# - bluetooth-monitor +# +#- hosts: bedroompi +# roles: +# - pi-disable-onboard-bluetooth +# - bluetooth-monitor -- hosts: musikserverwohnzimmeroben - roles: - - bluetooth-monitor +#- hosts: musicmouse +# roles: +# - pi-standard-setup +# - pi-hifiberry-amp +# - pi-musicmouse +# - pi-squeezelite-custom +# - pi-shairport +# - pi-lirc +# - bluetooth-monitor -- hosts: kitchenpi +- hosts: homeassistant roles: - - pi-disable-onboard-bluetooth - - bluetooth-monitor - -- hosts: bedroompi - roles: - - pi-disable-onboard-bluetooth - - bluetooth-monitor - + - bluetooth-monitor \ No newline at end of file