Skip to main content
Ctrl+K
Platypush Documentation - Home
  • Platypush
  • Home
  • Quick start
  • Installation
  • Plugins installation
  • APIs
  • Variables
  • Entities
  • Configuration
  • A full configuration example
  • The Web interface
  • Backends
    • http
    • nodered
    • redis
    • tcp
  • Plugins
    • adafruit.io
    • alarm
    • application
    • arduino
    • assistant.google
    • assistant.openai
    • assistant.picovoice
    • autoremote
    • bluetooth
    • calendar
    • calendar.ical
    • camera.android.ipcam
    • camera.cv
    • camera.ffmpeg
    • camera.gstreamer
    • camera.ir.mlx90640
    • camera.pi
    • camera.pi.legacy
    • clipboard
    • config
    • csv
    • cups
    • db
    • dbus
    • dropbox
    • entities
    • esp
    • ffmpeg
    • file
    • file.monitor
    • flic
    • foursquare
    • github
    • google.calendar
    • google.drive
    • google.mail
    • google.maps
    • google.pubsub
    • google.translate
    • gotify
    • gpio
    • gpio.zeroborg
    • gps
    • graphite
    • hid
    • http
    • http.webpage
    • ifttt
    • inspect
    • irc
    • joystick
    • kafka
    • lastfm
    • lcd.gpio
    • lcd.i2c
    • leap
    • light.hue
    • linode
    • log.http
    • logger
    • luma.oled
    • mail
    • mailgun
    • mastodon
    • matrix
    • media.chromecast
    • media.gstreamer
    • media.jellyfin
    • media.kodi
    • media.mplayer
    • media.mpv
    • media.plex
    • media.subtitles
    • media.vlc
    • media.webtorrent
    • midi
    • ml.cv
    • mobile.join
    • mqtt
    • music.mopidy
    • music.mpd
    • music.snapcast
    • music.spotify
    • music.tidal
    • nextcloud
    • nfc
    • ngrok
    • nmap
    • ntfy
    • openai
    • otp
    • pihole
    • ping
    • procedures
    • pushbullet
    • pwm.pca9685
    • qrcode
    • redis
    • rss
    • rtorrent
    • sensor.bme280
    • sensor.dht
    • sensor.distance.vl53l1x
    • sensor.envirophat
    • sensor.hcsr04
    • sensor.lis3dh
    • sensor.ltr559
    • sensor.mcp3008
    • sensor.pmw3901
    • serial
    • shell
    • slack
    • smartthings
    • sound
    • ssh
    • sun
    • switch.tplink
    • switch.wemo
    • switchbot
    • system
    • tcp
    • telegram
    • tensorflow
    • todoist
    • torrent
    • trello
    • tts
    • tts.google
    • tts.mimic3
    • tts.openai
    • tts.picovoice
    • tv.samsung.ws
    • twilio
    • udp
    • user
    • utils
    • variable
    • wallabag
    • weather.buienradar
    • weather.openweathermap
    • websocket
    • xmpp
    • youtube
    • zeroconf
    • zigbee.mqtt
    • zwave.mqtt
  • Events
    • adafruit
    • alarm
    • application
    • assistant
    • bluetooth
    • camera
    • chat.slack
    • clipboard
    • custom
    • dbus
    • distance
    • entities
    • file
    • flic
    • foursquare
    • geo
    • github
    • google
    • google.pubsub
    • gotify
    • gpio
    • gps
    • hid
    • http
    • http.hook
    • http.rss
    • inotify
    • irc
    • joystick
    • kafka
    • light
    • linode
    • log.http
    • mail
    • matrix
    • media
    • midi
    • mqtt
    • music
    • music.snapcast
    • music.tidal
    • nextcloud
    • nfc
    • ngrok
    • ntfy
    • ping
    • pushbullet
    • qrcode
    • rss
    • scard
    • sensor
    • sensor.ir
    • sensor.leap
    • sensor.light
    • serial
    • sound
    • stt
    • sun
    • telegram
    • tensorflow
    • torrent
    • trello
    • video
    • weather
    • web
    • web.widget
    • websocket
    • xmpp
    • zeroborg
    • zeroconf
    • zigbee.mqtt
    • zwave
  • Repository
  • Open issue
  • .rst

switch.tplink

Platypush documentation

  • Description
  • Configuration
  • Dependencies
  • Actions
  • Module reference
    • SwitchTplinkPlugin
      • SwitchTplinkPlugin.__init__()
      • SwitchTplinkPlugin.off()
      • SwitchTplinkPlugin.on()
      • SwitchTplinkPlugin.publish_entities()
      • SwitchTplinkPlugin.set()
      • SwitchTplinkPlugin.status()
      • SwitchTplinkPlugin.toggle()
      • SwitchTplinkPlugin.transform_entities()

switch.tplink#

Description#

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

Configuration#

switch.tplink:
  # [Optional]
  # 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.
  # plugs:   # type=Union[Mapping[str, str], List[str], NoneType]

  # [Optional]
  # 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.
  # bulbs:   # type=Union[Mapping[str, str], List[str], NoneType]

  # [Optional]
  # 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.
  # strips:   # type=Union[Mapping[str, str], List[str], NoneType]

  # [Optional]
  # How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
  # executed (default: 15 seconds). *NOTE*: For back-compatibility
  # reasons, the `poll_seconds` argument is also supported, but it's
  # deprecated.
  # poll_interval: 15  # type=Optional[float]

  # [Optional]
  # How long we should wait for any running
  # threads/processes to stop before exiting (default: 5 seconds).
  # stop_timeout: 5  # type=Optional[float]

  # [Optional]
  # If set to True then the plugin will not monitor
  # for new events. This is useful if you want to run a plugin in
  # stateless mode and only leverage its actions, without triggering any
  # events. Defaults to False.
  # disable_monitor: False  # type=bool

Dependencies#

pip

pip install pyHS100

Actions#

  • switch.tplink.off

  • switch.tplink.on

  • switch.tplink.status

  • switch.tplink.toggle

Module reference#

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).

__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.

off(device, **_)[source]#

Turn off a device

Parameters:

device (str) – Device IP, hostname or alias

on(device, **_)[source]#

Turn on a device

Parameters:

device (str) – Device IP, hostname or alias

publish_entities(entities: Collection[Any] | None, callback: Callable[[Entity], Any] | None = None, **kwargs) → Collection[Entity]#

Publishes a list of entities. The downstream consumers include:

  • The entity persistence manager

  • The web server

  • Any consumer subscribed to

    platypush.message.event.entities.EntityUpdateEvent events (e.g. web clients)

It also accepts an optional callback that will be called when each of the entities in the set is flushed to the database.

You usually don’t need to override this class (but you may want to extend transform_entities() instead if your extension doesn’t natively handle Entity objects).

set(entity: str, value: Any, **kwargs)#

Set the value of an entity.

Parameters:
  • entity – The entity to set the value for. It’s usually the ID of the entity provided by the plugin.

  • value – The value to set the entity to.

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.

previous

sun

next

switch.wemo

Platypush documentation
  • Description
  • Configuration
  • Dependencies
  • Actions
  • Module reference
    • SwitchTplinkPlugin
      • SwitchTplinkPlugin.__init__()
      • SwitchTplinkPlugin.off()
      • SwitchTplinkPlugin.on()
      • SwitchTplinkPlugin.publish_entities()
      • SwitchTplinkPlugin.set()
      • SwitchTplinkPlugin.status()
      • SwitchTplinkPlugin.toggle()
      • SwitchTplinkPlugin.transform_entities()

By Fabio Manganiello

© Copyright 2017-2024, Fabio Manganiello.