API

class hisensetv.HisenseTv(hostname: str, *, port: int = 36669, username: str = 'hisenseservice', password: str = 'multimqttservice', timeout: Union[int, float] = 10.0, enable_client_logger: bool = False, ssl_context: Optional[ssl.SSLContext] = None)

Hisense TV.

Parameters:
  • hostname – TV hostname or IP.
  • port – Port of the MQTT broker on the TV, typically 36669.
  • username – Username for the MQTT broker on the TV, typically “hisenseservice”.
  • password – Password for the MQTT broker on the TV, typically “multimqttservice”.
  • timeout – Duration to wait for a response from the TV for API calls.
  • enable_client_logger – Enable MQTT client logging for debug.
  • ssl_context – SSL context to utilize for the connection, None to skip SSL usage (required for some models).
get_sources() → List[Dict[str, str]]

Gets the video sources from the TV.

Returns:List of source dictionaries.

Example:

[
    {
        "displayname": "TV",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "1",
        "sourceid": "1",
        "sourcename": "TV",
    },
    {
        "displayname": "HDMI 1",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "0",
        "sourceid": "2",
        "sourcename": "HDMI 1",
    },
    {
        "displayname": "HDMI 2",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "0",
        "sourceid": "3",
        "sourcename": "HDMI 2",
    },
    {
        "displayname": "HDMI 3",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "0",
        "sourceid": "4",
        "sourcename": "HDMI 3",
    },
    {
        "displayname": "PC",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "1",
        "sourceid": "5",
        "sourcename": "HDMI 4",
    },
    {
        "displayname": "Composite",
        "hotel_mode": "0",
        "is_lock": "false",
        "is_signal": "0",
        "sourceid": "6",
        "sourcename": "Composite",
    },
]
get_volume() → dict

Gets the volume level on the TV.

Returns:Dictionary with keys for volume_type and volume_value.

Example:

{"volume_type": 0, "volume_value": 0}
send_authorization_code(code: Union[int, str])

Sends the authorization code to the TV.

Parameters:code – 4-digit code as displayed on the TV.
Raises:HisenseTvAuthorizationError – Failed to authenticate with the TV.
send_key(keyname: str)

Sends a keypress to the TV, as if it had been pressed on the IR remote.

Parameters:keyname – Name of the key press to send.
send_key_0()

Sends a keypress of the 0 key to the TV.

send_key_1()

Sends a keypress of the 1 key to the TV.

send_key_2()

Sends a keypress of the 2 key to the TV.

send_key_3()

Sends a keypress of the 3 key to the TV.

send_key_4()

Sends a keypress of the 4 key to the TV.

send_key_5()

Sends a keypress of the 5 key to the TV.

send_key_6()

Sends a keypress of the 6 key to the TV.

send_key_7()

Sends a keypress of the 7 key to the TV.

send_key_8()

Sends a keypress of the 8 key to the TV.

send_key_9()

Sends a keypress of the 9 key to the TV.

send_key_amazon()

Sends a keypress of the Amazon key to the TV.

send_key_back()

Sends a keypress of the back key to the TV.

send_key_channel_down()

Sends a keypress of the channel down key to the TV.

send_key_channel_up()

Sends a keypress of the channel up key to the TV.

send_key_down()

Sends a keypress of the down key to the TV.

send_key_exit()

Sends a keypress of the exit key to the TV.

send_key_fast_forward()

Sends a keypress of the fast forward key to the TV.

send_key_home()

Sends a keypress of the home key to the TV.

send_key_left()

Sends a keypress of the left key to the TV.

send_key_menu()

Sends a keypress of the menu key to the TV.

send_key_mute()

Sends a keypress of the mute key to the TV.

send_key_netflix()

Sends a keypress of the Netflix key to the TV.

send_key_ok()

Sends a keypress of the OK key to the TV.

send_key_pause()

Sends a keypress of the pause key to the TV.

send_key_play()

Sends a keypress of the play key to the TV.

send_key_power()

Sends a keypress of the powerkey to the TV.

send_key_rewind()

Sends a keypress of the rewind key to the TV.

send_key_right()

Sends a keypress of the right key to the TV.

send_key_source_0()

Sets TV to Input 0

send_key_source_1()

Sets TV to Input 1

send_key_source_2()

Sets TV to Input 2

send_key_source_3()

Sets TV to Input 3

send_key_source_4()

Sets TV to Input 4

send_key_source_5()

Sets TV to Input 5

send_key_source_6()

Sets TV to Input 6

send_key_source_7()

Sets TV to Input 7

send_key_stop()

Sends a keypress of the stop key to the TV.

send_key_subtitle()

Sends a keypress of the subtitle key to the TV.

send_key_up()

Sends a keypress of the up key to the TV.

send_key_volume_down()

Sends a keypress of the volume down key to the TV.

send_key_volume_up()

Sends a keypress of the volume up key to the TV.

send_key_youtube()

Sends a keypress of the YouTube key to the TV.

set_source(sourceid: Union[int, str], sourcename: str)

Sets the video source on the TV.

Parameters:
  • sourceid – Numeric source identier.
  • sourcename – Human readable source name.
set_volume(volume: int)

Sets the volume level on the TV.

Parameters:volume – Volume level from 0-100.
Raises:ValueError – Volume level is out of range.
start_authorization()

Starts the authorization flow.

exception hisensetv.HisenseTvAuthorizationError

Raised upon authorization failures.

exception hisensetv.HisenseTvError

Base exception for all exceptions raise by this API.

exception hisensetv.HisenseTvNotConnectedError

Raised when an API function is called without a connection.

exception hisensetv.HisenseTvTimeoutError

Raised upon a failure to receive a response in the timeout period.