mirror of
https://github.com/fmtr/haco.git
synced 2026-10-26 19:01:51 -04:00
Implement Fan object
This commit is contained in:
parent
257b68d8d5
commit
613006bf91
2 changed files with 58 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ from haco import tuya
|
|||
from .button import Button
|
||||
from .callback import Response
|
||||
from .climate import Climate
|
||||
from .fan import Fan
|
||||
from .number import Number
|
||||
from .pulldown import Select
|
||||
from .sensor import Sensor
|
||||
|
|
@ -21,6 +22,7 @@ __all__ = [
|
|||
"Password",
|
||||
"Update",
|
||||
"Climate",
|
||||
"Fan",
|
||||
"Response",
|
||||
"tuya"
|
||||
]
|
||||
|
|
|
|||
56
haco/fan.py
Normal file
56
haco/fan.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
from haco import constants
|
||||
from haco.control import Control
|
||||
from haco.schema import Schema, Capability, AnnounceTopic, Tasmota, ControlType, HomeAssistant
|
||||
from haco.tools import get_range_pair, invert_bool
|
||||
|
||||
|
||||
class Fan(Control):
|
||||
NAME = 'fan'
|
||||
|
||||
@classmethod
|
||||
def get_schema(cls):
|
||||
schema = Schema(
|
||||
capabilities=[
|
||||
Capability(
|
||||
ha=HomeAssistant(announce_data=AnnounceTopic(key='{io_ha}_topic')),
|
||||
tasmota=Tasmota(announce_data=AnnounceTopic(key='{io_ha}_topic'))
|
||||
),
|
||||
Capability(
|
||||
name='preset_mode',
|
||||
type=str
|
||||
),
|
||||
Capability(
|
||||
name='percentage',
|
||||
type=int
|
||||
),
|
||||
Capability(
|
||||
name='oscillation',
|
||||
type=ControlType
|
||||
)
|
||||
|
||||
]
|
||||
)
|
||||
return schema
|
||||
|
||||
def __init__(self, name=None, preset_modes=None, icon=None, speed_range=None):
|
||||
self.temperature_unit = speed_range
|
||||
self.speed_min, self.speed_max = get_range_pair(speed_range)
|
||||
self.preset_modes = preset_modes
|
||||
|
||||
super().__init__(name, icon=icon)
|
||||
|
||||
def get_config_ha_ex(self):
|
||||
data = {
|
||||
'speed_range_min': self.speed_min,
|
||||
'speed_range_max': self.speed_max,
|
||||
'preset_modes': self.preset_modes,
|
||||
'payload_oscillation_on': constants.ON,
|
||||
'payload_oscillation_off': constants.OFF,
|
||||
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@property
|
||||
def control_type(self):
|
||||
return invert_bool
|
||||
Loading…
Add table
Add a link
Reference in a new issue