forked from platypush/platypush
66d78c8615
- Using `@action` annotation to indicate methods that are allowed to be executed as actions - The output and errors of an action are automatically wrapped into a `Response` object without any response build required on the plugin side
33 lines
705 B
Python
33 lines
705 B
Python
from platypush.plugins import Plugin, action
|
|
|
|
class SwitchPlugin(Plugin):
|
|
"""
|
|
Abstract class for interacting with switch devices
|
|
"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
|
|
@action
|
|
def on(self, args):
|
|
""" Turn the device on """
|
|
raise NotImplementedError()
|
|
|
|
@action
|
|
def off(self, args):
|
|
""" Turn the device off """
|
|
raise NotImplementedError()
|
|
|
|
@action
|
|
def toggle(self, args):
|
|
""" Toggle the device status (on/off) """
|
|
raise NotImplementedError()
|
|
|
|
@action
|
|
def status(self):
|
|
""" Get the device state """
|
|
raise NotImplementedError()
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|
|
|