switch.wemo
#
Description#
Plugin to control a Belkin WeMo smart switches (https://www.belkin.com/us/Products/home-automation/c/wemo-home-automation/)
This plugin previously used ouimeaux
for auto-discovery, but it’s
been dropped because:
Too slow
Too heavy
Auto-discovery failed too often
However, this also means that you now have to specify either:
devices
: The devices you want to control, as a static list/map
netmask
: The IP netmask that should be scanned for WeMo devices
Configuration#
switch.wemo:
# [Optional]
# List of IP addresses or name->address map containing
# the WeMo Switch devices to control.
# devices: # type=Union[Collection[str], Mapping[str, str], NoneType]
# [Optional]
# Alternatively to a list of static IP->name pairs, you
# can specify the network mask where the devices should be scanned
# (e.g. '192.168.1.0/24')
# netmask: # type=Optional[str]
# [Optional]
# Port where the WeMo devices are expected to expose the
# RPC/XML over HTTP service (default: 49153)
# port: 49153 # type=int
# [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
Actions#
Module reference#
- class platypush.plugins.switch.wemo.SwitchWemoPlugin(*_, **__)[source]#
Bases:
RunnablePlugin
,SwitchEntityManager
Plugin to control a Belkin WeMo smart switches (https://www.belkin.com/us/Products/home-automation/c/wemo-home-automation/)
- __init__(devices: Collection[str] | Mapping[str, str] | None = None, netmask: str | None = None, port: int = 49153, **kwargs)[source]#
This plugin previously used
ouimeaux
for auto-discovery, but it’s been dropped because:Too slow
Too heavy
Auto-discovery failed too often
However, this also means that you now have to specify either:
devices
: The devices you want to control, as a static list/mapnetmask
: The IP netmask that should be scanned for WeMo devices
- Parameters:
devices (list or dict) – List of IP addresses or name->address map containing the WeMo Switch devices to control.
netmask – Alternatively to a list of static IP->name pairs, you can specify the network mask where the devices should be scanned (e.g. ‘192.168.1.0/24’)
port – Port where the WeMo devices are expected to expose the RPC/XML over HTTP service (default: 49153)
- get_name(device: str)[source]#
Get the friendly name of a device
- Parameters:
device – Device name or address
- get_state(device: str)[source]#
Get the on state of a device (True/False)
- Parameters:
device – Device name or address
- 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.
- start()#
Start the plugin.
- status(device: str | Collection[str] | None = None, publish_entities: bool = True, **__) List[dict] [source]#
All derived classes should implement this method.
At the very least, this method should refresh the current state of the integration’s entities and call
publish_entities()
.It should also return the current state of the entities as a list of serialized entities, if possible.
- stop()#
Stop the plugin.
- toggle(device: str, *_, **__)[source]#
Toggle a device on/off state
- Parameters:
device – Device name or address
- transform_entities(entities: Collection[dict]) List[Entity] [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.
- wait_stop(timeout=None)#
Wait until a stop event is received.