switch.tplink
#
- class platypush.plugins.switch.tplink.SwitchTplinkPlugin(*_, **__)[source]#
Bases:
RunnablePlugin
,SwitchEntityManager
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: Mapping[str, str] | List[str] | None = None, bulbs: Mapping[str, str] | List[str] | None = None, strips: Mapping[str, str] | List[str] | None = 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.
- status(*_, **__) List[dict] [source]#
Retrieve the current status of the devices. Return format:
[ { "current_consumption": 0.5, "id": "192.168.1.123", "ip": "192.168.1.123", "host": "192.168.1.123", "hw_info": "00:11:22:33:44:55", "name": "My Switch", "on": true, } ]
- toggle(device, **_)[source]#
Toggle the state of a device (on/off)
- Parameters:
device (str) – Device IP, hostname or alias
- transform_entities(entities: Collection[pyHS100.SmartDevice])[source]#
This method takes a list of entities in any (plugin-specific) format and converts them into a standardized collection of Entity objects. Since this method is called by
publish_entities()
before entity updates are published, you may usually want to extend it to pre-process the entities managed by your extension into the standard format before they are stored and published to all the consumers.