platypush/platypush/plugins/light/__init__.py
Fabio Manganiello 8d57cf06c2
Major refactor for the light.hue plugin.
- Added support for lights as native platform entities.
- Improved performance by using the JSON API objects whenever possible
  to interact with the bridge instead of the native Python objects,
  which perform a bunch of lazy API calls under the hood resulting in
  degraded performance.
- Fixed lights animation attributes by setting only the ones actually
  supported by a light.
- Several LINT fixes.
2022-04-30 01:07:00 +02:00

41 lines
855 B
Python

from abc import ABC, abstractmethod
from platypush.entities import manages
from platypush.entities.lights import Light
from platypush.plugins import Plugin, action
@manages(Light)
class LightPlugin(Plugin, ABC):
"""
Abstract plugin to interface your logic with lights/bulbs.
"""
@action
@abstractmethod
def on(self):
"""Turn the light on"""
raise NotImplementedError()
@action
@abstractmethod
def off(self):
"""Turn the light off"""
raise NotImplementedError()
@action
@abstractmethod
def toggle(self):
"""Toggle the light status (on/off)"""
raise NotImplementedError()
@action
@abstractmethod
def status(self):
"""
Get the current status of the lights.
"""
raise NotImplementedError()
# vim:sw=4:ts=4:et: