Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fan light support #186

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .homeycompose/app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "com.tuya",
"version": "1.2.3",
"compatibility": ">=12.0.0",
"compatibility": ">=12.0.1",
"brandColor": "#FF4800",
"sdk": 3,
"platforms": [
Expand Down
9 changes: 9 additions & 0 deletions .homeycompose/capabilities/fan_swing_horizontal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "boolean",
"title": {
"en": "Fan Swing Horizontal"
},
"getable": true,
"setable": true,
"uiComponent": "button"
}
9 changes: 9 additions & 0 deletions .homeycompose/capabilities/fan_swing_vertical.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "boolean",
"title": {
"en": "Fan Swing Vertical"
},
"getable": true,
"setable": true,
"uiComponent": "button"
}
35 changes: 35 additions & 0 deletions .homeycompose/capabilities/legacy_fan_speed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"type": "enum",
"title": {
"en": "Fan Speed"
},
"getable": true,
"setable": true,
"uiComponent": "picker",
"values": [
{
"id": "4",
"title": {
"en": "4"
}
},
{
"id": "3",
"title": {
"en": "3"
}
},
{
"id": "2",
"title": {
"en": "2"
}
},
{
"id": "1",
"title": {
"en": "1"
}
}
]
}
66 changes: 65 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"_comment": "This file is generated. Please edit .homeycompose/app.json instead.",
"id": "com.tuya",
"version": "1.2.3",
"compatibility": ">=12.0.0",
"compatibility": ">=12.0.1",
"brandColor": "#FF4800",
"sdk": 3,
"platforms": [
Expand Down Expand Up @@ -2452,6 +2452,17 @@
},
"id": "fan",
"settings": [
{
"id": "enable_light_support",
"type": "checkbox",
"label": {
"en": "Enable light support"
},
"hints": {
"en": "Some fans have light capabilities (built-in lamp) and some don't. This is not always detected correctly: if the automatic detection failed you can adjust this setting."
},
"value": false
},
{
"id": "deviceSpecification",
"type": "label",
Expand Down Expand Up @@ -3600,6 +3611,24 @@
"uiComponent": "button",
"icon": "assets/capabilities/eco.svg"
},
"fan_swing_horizontal": {
"type": "boolean",
"title": {
"en": "Fan Swing Horizontal"
},
"getable": true,
"setable": true,
"uiComponent": "button"
},
"fan_swing_vertical": {
"type": "boolean",
"title": {
"en": "Fan Swing Vertical"
},
"getable": true,
"setable": true,
"uiComponent": "button"
},
"fault": {
"type": "string",
"title": {
Expand All @@ -3609,6 +3638,41 @@
"setable": false,
"uiComponent": "sensor"
},
"legacy_fan_speed": {
"type": "enum",
"title": {
"en": "Fan Speed"
},
"getable": true,
"setable": true,
"uiComponent": "picker",
"values": [
{
"id": "4",
"title": {
"en": "4"
}
},
{
"id": "3",
"title": {
"en": "3"
}
},
{
"id": "2",
"title": {
"en": "2"
}
},
{
"id": "1",
"title": {
"en": "1"
}
}
]
},
"ptz_control_horizontal": {
"type": "enum",
"title": {
Expand Down
40 changes: 40 additions & 0 deletions drivers/fan/TuyaFanConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
export const FAN_CAPABILITIES_MAPPING = {
switch: 'onoff',
fan_switch: 'onoff',
fan_speed_percent: 'dim',
// fan_speed can be both dim and legacy_fan_speed
switch_vertical: 'fan_swing_vertical',
switch_horizontal: 'fan_swing_horizontal',
child_lock: 'child_lock',
temp: 'target_temperature',
temp_current: 'measure_temperature',
// light
work_mode: 'light_mode',
light: 'onoff.light',
switch_led: 'onoff.light',
bright_value: 'dim.light',
temp_value: 'light_temperature',
// colour_data is split between light_hue, light_saturation and dim.light
} as const;

export const FAN_CAPABILITIES = {
read_write: [
'switch',
'fan_switch',
'fan_speed_percent',
'switch_horizontal',
'switch_vertical',
'child_lock',
'temp',
// Light
'light',
'switch_led',
],
read_only: ['temp_current'],
} as const;

export type HomeyFanSettings = {
enable_light_support: boolean;
};

export type TuyaFanSettings = Record<string, never>;
Loading
Loading