platypush.plugins.switch.tplink

class platypush.plugins.switch.tplink.SwitchTplinkPlugin(plugs: Optional[Union[Dict[str, str], List[str]]] = None, bulbs: Optional[Union[Dict[str, str], List[str]]] = None, strips: Optional[Union[Dict[str, str], List[str]]] = None, **kwargs)[source]

Plugin to interact with TP-Link smart switches/plugs like the HS100 (https://www.tp-link.com/us/products/details/cat-5516_HS100.html).

Requires:

  • pyHS100 (pip install pyHS100)

__init__(plugs: Optional[Union[Dict[str, str], List[str]]] = None, bulbs: Optional[Union[Dict[str, str], List[str]]] = None, strips: Optional[Union[Dict[str, str], List[str]]] = None, **kwargs)[source]
Parameters
  • plugs – Optional list of IP addresses or name->address mapping if you have a static list of TpLink plugs and you want to save on the scan time.

  • bulbs – Optional list of IP addresses or name->address mapping if you have a static list of TpLink bulbs and you want to save on the scan time.

  • strips – Optional list of IP addresses or name->address mapping if you have a static list of TpLink strips and you want to save on the scan time.

off(device, **kwargs)[source]

Turn off a device

Parameters

device (str) – Device IP, hostname or alias

on(device, **kwargs)[source]

Turn on a device

Parameters

device (str) – Device IP, hostname or alias

property switches

This property must be implemented by the derived classes and must return a dictionary in the following format:

[
    {
        "name": "switch_1",
        "on": true
    },
    {
        "name": "switch_2",
        "on": false
    },
]

name and on are the minimum set of attributes that should be returned for a switch, but more attributes can also be added.

toggle(device, **kwargs)[source]

Toggle the state of a device (on/off)

Parameters

device (str) – Device IP, hostname or alias