Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: Add sync of Lightshows and Boombox #913

Open
gilesmartin opened this issue Jan 10, 2025 · 0 comments
Open

FR: Add sync of Lightshows and Boombox #913

gilesmartin opened this issue Jan 10, 2025 · 0 comments

Comments

@gilesmartin
Copy link

Describe the problem

In addition to synchronization of music I wanted to have the ability to sync lightshows and boombox files. I added a "lightshow" and "boombox" share on the same NAS that is hosting the "music" and "teslausb" shares. I then modified the following:

in teslausb_setup_variables.conf

export LIGHTSHOW_SHARE_NAME=lightshow
export BOOMBOX_SHARE_NAME=boombox

in envsetup.sh

  newnamefor[lightshowsharename]=LIGHTSHOW_SHARE_NAME
  newnamefor[boomboxsharename]=BOOMBOX_SHARE_NAME

in connect-archive.sh

  if [ -e "$BOOMBOX_ARCHIVE_MOUNT" ]
  then
    log "Ensuring boombox archive is mounted..."
    if ensure_mountpoint_is_mounted_with_retry "$BOOMBOX_ARCHIVE_MOUNT"
    then
      log "Ensured boombox archive is mounted."
    else
      log "Failed to mount boombox archive."
      return 1
    fi
  fi
  if [ -e "$LIGHTSHOW_ARCHIVE_MOUNT" ]
  then
    log "Ensuring lightshow archive is mounted..."
    if ensure_mountpoint_is_mounted_with_retry "$LIGHTSHOW_ARCHIVE_MOUNT"
    then
      log "Ensured lightshow archive is mounted."
    else
      log "Failed to mount lightshow archive."
      return 1
    fi
  fi

in disconnect-archive.sh

  if [ -e "$LIGHTSHOW_ARCHIVE_MOUNT" ]
  then
    log "unmounting $LIGHTSHOW_ARCHIVE_MOUNT"
    if ! umount -f -l "$LIGHTSHOW_ARCHIVE_MOUNT"
    then
      log "unmount failed"
    fi
  fi
  if [ -e "$BOOMBOX_ARCHIVE_MOUNT" ]
  then
    log "unmounting $BOOMBOX_ARCHIVE_MOUNT"
    if ! umount -f -l "$BOOMBOX_ARCHIVE_MOUNT"
    then
      log "unmount failed"
    fi
  fi

in archiveloop

export LIGHTSHOW_MOUNT=/mnt/lightshow
export LIGHTSHOW_ARCHIVE_MOUNT=/mnt/lightshowarchive
export BOOMBOX_ARCHIVE_MOUNT=/mnt/boomboxarchive
export BOOMBOX_MOUNT=/mnt/boombox
function ensure_lightshow_file_is_mounted () {
  log "Ensuring lightshow backing file is mounted..."
  disconnect_usb_drives_from_host
  ensure_mountpoint_is_mounted_with_retry "$LIGHTSHOW_MOUNT"
  log "Ensured lightshow drive is mounted."
}

function ensure_boombox_file_is_mounted () {
  log "Ensuring boombox backing file is mounted..."
  disconnect_usb_drives_from_host
  ensure_mountpoint_is_mounted_with_retry "$BOOMBOX_MOUNT"
  log "Ensured boombox drive is mounted."
}
function unmount_lightshow_file () {
  unmount_mount_point "$LIGHTSHOW_MOUNT"
}

function unmount_boombox_file () {
  unmount_mount_point "$BOOMBOX_MOUNT"
}
function copy_lightshow_files () {
  log "Starting lightshow sync..."

  ensure_lightshow_file_is_mounted

  /root/bin/copy-lightshow.sh

  # Trim the empty space from the music archive.
  trim_free_space "$LIGHTSHOW_MOUNT"

  unmount_lightshow_file
}

function copy_boombox_files () {
  log "Starting boombox sync..."

  ensure_boombox_file_is_mounted

  /root/bin/copy-boombox.sh

  # Trim the empty space from the music archive.
  trim_free_space "$BOOMBOX_MOUNT"

  unmount_boombox_file
}

  if timeout 5 [ -d "$LIGHTSHOW_ARCHIVE_MOUNT" -a -d "$LIGHTSHOW_MOUNT" ]
  then
    log "Copying lightshows..."
    if copy_lightshow_files
    then
      log "Finished copying lightshows."
    else
      log "Copying lightshows failed."
    fi
  else
    log "Lightshow archive not configured or unreachable"
  fi
  
  if timeout 5 [ -d "$BOOMBOX_ARCHIVE_MOUNT" -a -d "$BOOMBOX_MOUNT" ]
  then
    log "Copying boombox..."
    if copy_boombox_files
    then
      log "Finished copying boombox."
    else
      log "Copying boombox failed."
    fi
  else
    log "Boombox archive not configured or unreachable"
  fi

then in /etc/fstab I added:

//server/lightshow /mnt/lightshowarchive cifs noauto,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,vers=default, 0
//server/boombox /mnt/boomboxarchive cifs noauto,credentials=/root/.teslaCamArchiveCredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,vers=default, 0

Cool side note: I found that changing out the LockChime.wav file in the root of the boombox drive updates the sound the car uses without going back into toybox to configure. This is despite the car moving the file to memory (because the sound continues to work if the drive is removed).

Device

Raspberry Pi 4

OS Image

Prebuilt TeslaUSB image

Car Model

Model 3

USB connection

Center console

Logs

No response

Additional information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant