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
|
2017-11-03 20:08:17 +01:00
|
|
|
def on(self):
|
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
|
2017-11-03 20:08:17 +01:00
|
|
|
def off(self):
|
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
|
2017-11-03 20:08:17 +01:00
|
|
|
def toggle(self):
|
2022-04-30 01:07:00 +02:00
|
|
|
"""Toggle the light status (on/off)"""
|
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
@action
|
|
|
|
@abstractmethod
|
|
|
|
def status(self):
|
|
|
|
"""
|
|
|
|
Get the current status of the lights.
|
|
|
|
"""
|
2017-11-03 20:08:17 +01:00
|
|
|
raise NotImplementedError()
|
|
|
|
|
|
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|