2021-09-16 17:53:40 +02:00
|
|
|
from abc import ABC, abstractmethod
|
2017-11-03 20:08:17 +01:00
|
|
|
|
2022-04-30 01:07:00 +02:00
|
|
|
from platypush.entities import manages
|
|
|
|
from platypush.entities.lights import Light
|
|
|
|
from platypush.plugins import Plugin, action
|
2020-10-28 23:19:16 +01:00
|
|
|
|
2021-02-19 02:54:12 +01:00
|
|
|
|
2022-04-30 01:07:00 +02:00
|
|
|
@manages(Light)
|
|
|
|
class LightPlugin(Plugin, ABC):
|
2018-06-25 00:49:45 +02:00
|
|
|
"""
|
|
|
|
Abstract plugin to interface your logic with lights/bulbs.
|
|
|
|
"""
|
|
|
|
|
2018-07-06 02:08:38 +02:00
|
|
|
@action
|
2021-09-16 17:53:40 +02:00
|
|
|
@abstractmethod
|
2022-05-01 15:31:45 +02:00
|
|
|
def on(self, lights=None, *args, **kwargs):
|
2022-04-30 01:07:00 +02:00
|
|
|
"""Turn the light on"""
|
2017-11-03 20:08:17 +01:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
2018-07-06 02:08:38 +02:00
|
|
|
@action
|
2021-09-16 17:53:40 +02:00
|
|
|
@abstractmethod
|
2022-05-01 15:31:45 +02:00
|
|
|
def off(self, lights=None, *args, **kwargs):
|
2022-04-30 01:07:00 +02:00
|
|
|
"""Turn the light off"""
|
2017-11-03 20:08:17 +01:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
2018-07-06 02:08:38 +02:00
|
|
|
@action
|
2021-09-16 17:53:40 +02:00
|
|
|
@abstractmethod
|
2022-05-01 15:31:45 +02:00
|
|
|
def toggle(self, lights=None, *args, **kwargs):
|
2022-04-30 01:07:00 +02:00
|
|
|
"""Toggle the light status (on/off)"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
@action
|
|
|
|
@abstractmethod
|
2022-05-01 15:31:45 +02:00
|
|
|
def set_lights(self, lights=None, *args, **kwargs):
|
|
|
|
"""
|
|
|
|
Set a set of properties on a set of lights.
|
|
|
|
|
|
|
|
:param light: List of lights to set. Each item can represent a light
|
|
|
|
name or ID.
|
|
|
|
:param kwargs: key-value list of the parameters to set.
|
|
|
|
"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
@action
|
|
|
|
@abstractmethod
|
|
|
|
def status(self, *args, **kwargs):
|
2022-04-30 01:07:00 +02:00
|
|
|
"""
|
|
|
|
Get the current status of the lights.
|
|
|
|
"""
|
2017-11-03 20:08:17 +01:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|