bscpylgtv

repository·master·Indexed 43 days ago

https://github.com/chros73/bscpylgtv

A high-performance Python library for controlling webOS-based LG TVs. An enhanced version of aiopylgtv optimized for command-line usage, featuring advanced capabilities for HDR10 and Dolby Vision calibration, 1D and 3D LUT management, service menu access, and SDR profiling.

Tokens
327.8K
Snippets
325
Records
387
Agent score
56%

What's inside bscpylgtv

  1. Calibration functionality overview

    master

    The calibration API allows for advanced image processing adjustments on LG WebOS TVs with Alpha 7 and Alpha 9 chipsets. This includes uploading 1D/3D LUTs, resetting factory calibration data, uploading custom tone mapping parameters (>=2019 models), and using the internal test pattern generator (iTPG).

    WARNING: Messing with calibration data could brick your TV, potentially requiring a mainboard replacement. While currently implemented functions are intended to be safe, they have only been extensively tested for 2018 Alpha 7/9 and 2019/2021/2022 Alpha 9 models. Use with caution.

    Key Concepts

    • Calibration Mode: Most calibration commands can only be run while in calibration mode, which is controlled via start_calibration and end_calibration.
    • Picture Modes: Calibration data is specific to each picture mode. Modes are independent for SDR, HDR10+HLG, and Dolby Vision. You must send the TV a signal corresponding to the mode you wish to calibrate (e.g., play an HDR10 file to access HDR10 modes).
    • LUT Formats: Supported input formats are IRIDAS .cube for 1D and 3D LUTs, and ArgyllCMS .cal files for 1D LUTs.
  2. Configure SDR bypass modes

    master

    To prepare the TV for SDR profiling, you must start the calibration session for a specific preset and enable bypass modes.

    Warning: The start_calibration command automatically sets the color temperature to Warm (50). If your target preset requires Cold (50), you must manually change it back after starting calibration.

    Use the following command sequence (replacing 192.168.1.18 with your TV's IP and cinema with your preset name):

    bscpylgtvcommand 192.168.1.18 start_calibration cinema
    bscpylgtvcommand 192.168.1.18 set_bypass_modes_sdr -s
    bscpylgtvcommand 192.168.1.18 end_calibration
  3. Update Dolby Vision config via USB

    master

    To update Tmax and Tprimaries in the DolbyVision_UserDisplayConfiguration.txt file:

    1. Copy the config file to the root of a USB thumbdrive.
    2. Plug the drive into the TV while in SDR mode.
    3. Play any Dolby Vision content (e.g., via an internal app).
    4. A DoVi popup will appear allowing you to update or reset the configuration.

    Warning: If a 1D LUT has already been uploaded via the calibration API to a specific DoVi preset, the USB configuration update popup is disabled. To fix this, you must either update the config before uploading the LUT, or reset the preset via the UI/API, update the config via USB, and then re-upload the 1D LUT.

  4. Use the compatibility manifest for webOS26+

    master

    When working with webOS26 or later versions, you can use the manifest-comp.json manifest file with the -m switch. This manifest provides limited functionality to ensure compatibility with newer webOS versions.

    # Example usage with the -m switch
    # (Note: exact command structure depends on the CLI implementation)
    python -m bscpylgtv -m manifest-comp.json
  5. Calibrate HDR10 using white balance or 1D LUT

    master

    HDR10 calibration in bscpylgtv focuses on modifying the white balance rather than the 3D LUT. You can achieve this by either adjusting the 22pt white balance controls via the TV's UI using calibration software (to correct white balance or gamma 2.2) or by uploading a custom 1D LUT.

    Important Note: The start_calibration command automatically sets the color temperature to Warm (50). If your calibration workflow requires the Cool preset, you must manually change it back to Cold (50) before executing the get_1d_lut command.

  6. Extract 1D LUT from TV

    master

    To retrieve the factory 1D LUT from the TV, use the start_calibration command with the dolby_cinema_dark parameter.

    Important Note on Color Temperature: The start_calibration command automatically sets the color temperature to Warm (50). If your current preset is set to Cool, you must manually change it back to Cold (50) before running the get_1d_lut command.

    To ensure a clean state, it is recommended to upload an empty LUT [] before fetching the factory file.

    bscpylgtvcommand 192.168.1.18 start_calibration dolby_cinema_dark
    # Reset any uploaded 1dlut, just in case
    bscpylgtvcommand 192.168.1.18 upload_1d_lut []
    bscpylgtvcommand 192.168.1.18 get_1d_lut "dovi_cinema_factory.1dlut"
  7. Create a new available_settings_*.md file

    master

    To generate a new settings documentation file for a specific model, use the merge_settings.py script. This helps identify available Inputs, Presets, Dynamic ranges, and category settings.

    1. Create a new directory named after the model (e.g., C2).
    2. Copy the following files into that directory:
      • etc/palm/defaultSettings.json
      • etc/palm/description.json
      • usr/palm/services/com.webos.service.apiadapter/adapters/settings/valid-settings.js
    3. Run the script passing the directory name as an argument.

    The script will output a merged Markdown file, such as C2/available_settings_C2.md.

    merge_settings.py C2