Sync commit
This commit is contained in:
parent
f9fdffbdbd
commit
142439b7c3
8 changed files with 22 additions and 11 deletions
|
@ -1,5 +1,5 @@
|
|||
import logging
|
||||
from mash.core.bridge import Bridge
|
||||
from core import Bridge
|
||||
from phue import Bridge as phueBridge
|
||||
from time import sleep
|
||||
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
from mash.core.entities.light import Light
|
||||
from mash.core.utilities.glow import Glow
|
||||
from core import Entity
|
||||
|
||||
|
||||
class HueLight(Light):
|
||||
class HueLight(Entity):
|
||||
def __init__(
|
||||
self, *, id: str, name: str, room: str, groups: list[str] = ...
|
||||
) -> None:
|
||||
super().__init__(id=id, name=name, room=room, groups=groups)
|
||||
|
||||
def __on_change__(self, current_on: bool, current_glow: Glow):
|
||||
pass
|
||||
# TODO: Requires reference to bridge
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from core.entity import Entity
|
||||
from core import Entity
|
||||
import requests as r
|
||||
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
from .zigbee2mqtt_bridge import Z2mBridge
|
||||
from .entities.contact_sensor_z2m import ContactSensorZ2M
|
||||
from .contact_sensor_z2m import ContactSensorZ2M
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
from typing import Optional
|
||||
from core.bridge import Bridge
|
||||
from core import Bridge
|
||||
import paho.mqtt.client as mqtt
|
||||
import json
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ class Entity:
|
|||
self._room = room
|
||||
self._device_type = device_type
|
||||
self._groups = set(groups)
|
||||
self.__is_on__: bool | None = None
|
||||
|
||||
@property
|
||||
def id(self) -> str:
|
||||
|
@ -30,3 +31,18 @@ class Entity:
|
|||
|
||||
def __str__(self) -> str:
|
||||
return f"{self.name} [{self.id}, type {self.device_type}, room {self.room}, in {len(self.groups)} groups]"
|
||||
|
||||
def toggle_state(self):
|
||||
"""Turns entity on, if off, and vice versa, if supported."""
|
||||
if self.__is_on__ == False: # Neither True nor None
|
||||
self.turn_on()
|
||||
else:
|
||||
self.turn_off()
|
||||
|
||||
def turn_on(self):
|
||||
"""Turns entity on, if action supported."""
|
||||
self.__is_on__ = True # TODO: What if action unsuccessful?
|
||||
|
||||
def turn_off(self):
|
||||
"""Turns entity on, if action supported."""
|
||||
self.__is_on__ = False # TODO: What if action unsuccessful?
|
||||
|
|
Loading…
Reference in a new issue