Mastodon Politics, Power, and Science: Adding CC to Vizio Control

Monday, March 23, 2026

Adding CC to Vizio Control

J. Rogers, SE Ohio

Below are the exact, minimal changes needed across the four files to add the Closed Captions (CC) button. It places the button in the empty top-right space of the D-Pad cluster in both the Pygame GUI and the Web GUI, without moving any existing buttons.

1. vizio_control.py (Core Logic & CLI)

Step A: Add the CC command to the TV class.
Find the key_info method (around line 326) and add the cc method right below it:

    def key_info(self):
        """Press Info"""
        return self.send_key(4, 6)
    
    # --- ADD THIS NEW METHOD ---
    def cc(self):
        """Toggle Closed Captions"""
        return self.send_key(13, 0)

Step B: Add the command to the CLI handler.
Find the elif command == "info": block in the main() function (around line 630) and add the CC block below it:

        elif command == "info":
        success = tv.key_info()
        if success:
            print("✓ Info")
        sys.exit(0 if success else 1)

    # --- ADD THIS BLOCK ---
    elif command == "cc":
        success = tv.cc()
        if success:
            print("✓ CC")
        sys.exit(0 if success else 1)

2. vizio_flask.py (Web Server Backend)

Add the command to the Flask API router.
Find the elif command == "info": line in the execute_command function (around line 52) and add the CC line below it:

        elif command == "info":
            success = tv.key_info()
            
        # --- ADD THIS ---
        elif command == "cc":
            success = tv.cc()

3. vizio_gui.py (Desktop App GUI)

Step A: Draw the button in the D-Pad cluster.
Find the D-Pad section in create_buttons() (around line 114). Define the cc_btn and update the self.buttons.extend list to include it:

                # OK (center)

        ok_btn = Button(dpad_center_x - small_btn//2, dpad_center_y - small_btn//2+30, 
                       small_btn, small_btn, "OK", lambda: self.execute_command("ok"), ACCENT_COLOR)
        
        # --- ADD THIS BUTTON ---
        cc_btn = Button(dpad_center_x + small_btn + 20, dpad_center_y - small_btn, 
                       50, 40, "CC", lambda: self.execute_command("cc"))
        
        # --- UPDATE THIS LINE TO INCLUDE cc_btn ---
        self.buttons.extend([up_btn, down_btn, left_btn, right_btn, ok_btn, cc_btn])

Step B: Handle the command click.
Find the elif command == "info": line in the execute_command method (around line 177) and add the CC line below it:

        elif command == "info":
            success = self.tv.key_info()
                
        # --- ADD THIS ---
        elif command == "cc":
            success = self.tv.cc()

4. templates/remote.html (Web App GUI)

Step A: Add the CSS grid coordinates.
Find the .dpad-down CSS rule in the <style> section (around line 96) and add the .dpad-cc rule directly below it. (This safely uses the empty top-right grid square):

        .dpad-up { grid-column: 2; grid-row: 1; }
        .dpad-left { grid-column: 1; grid-row: 2; }
.dpad-ok { grid-column: 2; grid-row: 2; } .dpad-right { grid-column: 3; grid-row: 2; } .dpad-down { grid-column: 2; grid-row: 3; } /* --- ADD THIS LINE --- */ .dpad-cc { grid-column: 3; grid-row: 1; font-size: 16px; }

Step B: Add the HTML button.
Find the <div class="dpad-container"> block (around line 186) and append the new button inside the container:

        <!-- D-Pad Navigation -->
        <div class="dpad-container">
            <button class="button dpad-button dpad-up" onclick="sendCommand('up')"></button>
            <button class="button dpad-button dpad-left" onclick="sendCommand('left')"></button>
            <button class="button dpad-button dpad-ok accent-button" onclick="sendCommand('ok')">OK</button>
            <button class="button dpad-button dpad-right" onclick="sendCommand('right')"></button>
            <button class="button dpad-button dpad-down" onclick="sendCommand('down')"></button>
            
            <!-- --- ADD THIS LINE --- -->
            <button class="button dpad-button dpad-cc" onclick="sendCommand('cc')">CC</button>
        </div>



Since Vizio doesn't publish an official list, you have to use these community-maintained sources to find the codes, like the following:

https://github.com/heathbar/vizio-smart-cast/blob/master/test/test-control.js

No comments:

Post a Comment

Measurement as Ratio: The Invariant Beyond Units and Constants

J. Rogers, SE Ohio This paper is at:  https://github.com/BuckRogers1965/Physics-Unit-Coordinate-System/tree/main/docs Abstract Measurement i...