mitv

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mitv talks to the LAN remote API of Xiaomi HyperOS displays and TVs: the HTTP server on port 6095 that switches inputs and changes volume.

Index

Constants

View Source
const (
	SourceDP   = 29
	SourceUSBC = 30
)

The ids of the monitor-only inputs.

View Source
const Port = 6095

Port is where the remote API listens.

Variables

View Source
var ErrNotFound = errors.New("mitv: no monitor found")

ErrNotFound means no HyperOS monitor answered on the local network.

View Source
var ErrRejected = errors.New("mitv: request rejected")

ErrRejected means the device answered but refused the request.

Functions

func Discover

func Discover() (string, error)

Discover returns the IPv4 address of a HyperOS monitor by probing every address of the local /24 subnets for the remote API. (The device answers mDNS only by multicast to port 5353, which the system's own responder holds, so a scan is the portable way.)

Types

type Link struct {
	Host string
	// contains filtered or unexported fields
}

Link is a client for one device.

func New

func New(host string) *Link

func (*Link) DeviceName

func (l *Link) DeviceName() (string, error)

DeviceName answers whether the device is reachable, with its name.

func (*Link) IsMonitor added in v1.4.1

func (l *Link) IsMonitor() bool

IsMonitor tells a monitor from the other devices with the same remote API, such as TVs: MonitorBar must never switch a TV in another room. A monitor's name says so, unless its owner renamed it (#5); then its DP or USB-C input does, which TVs don't have.

func (*Link) Press

func (l *Link) Press(key string) error

Press sends a remote key such as "volumeup", "volumedown", "home" or "back".

func (*Link) Select

func (l *Link) Select(sourceID int) error

Select switches input. changesource2 takes the numeric id, so it also reaches DP and USB-C, which the name-based changesource rejects.

func (*Link) SetCompetitive added in v1.5.0

func (l *Link) SetCompetitive(on bool) error

SetCompetitive turns the 320Hz competitive mode of dual-mode monitors such as the G Pro 27U on or off: it trades 4K 160Hz for 1080p 320Hz by changing the EDID the monitor offers (#8). No API sets it, so this walks the game bar the menu key opens, where the mode is the sixth item.

func (*Link) Sources

func (l *Link) Sources() ([]Source, error)

func (*Link) Volume

func (l *Link) Volume() (int, error)

Volume reads the volume on a 0...100 scale.

type Source

type Source struct {
	ID   int
	Name string
}

Source is an input of the display, such as HDMI1 (23) or DP (29).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL