forked from ikalchev/HAP-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFakeFan.py
More file actions
31 lines (21 loc) · 1.08 KB
/
FakeFan.py
File metadata and controls
31 lines (21 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""A fake fan that does nothing but to demonstrate optional characteristics."""
import logging
from pyhap.accessory import Accessory
from pyhap.const import CATEGORY_FAN
logger = logging.getLogger(__name__)
class FakeFan(Accessory):
"""A fake fan accessory that logs changes to its rotation speed and direction."""
category = CATEGORY_FAN
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add the fan service. Also add optional characteristics to it.
serv_fan = self.add_preload_service(
'Fan', chars=['RotationSpeed', 'RotationDirection'])
self.char_rotation_speed = serv_fan.configure_char(
'RotationSpeed', setter_callback=self.set_rotation_speed)
self.char_rotation_direction = serv_fan.configure_char(
'RotationDirection', setter_callback=self.set_rotation_direction)
def set_rotation_speed(self, value):
logger.debug("Rotation speed changed: %s", value)
def set_rotation_direction(self, value):
logger.debug("Rotation direction changed: %s", value)