-
Notifications
You must be signed in to change notification settings - Fork 474
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
feat(fan): added support for gorilla fan v2 #1988
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4a8b77b
feat(fan): added support for gorilla fan v2
aravindjaimon 702d97d
Merge branch 'main' into feat/gorilla-fan
aravindjaimon 71e7a7d
Merge remote-tracking branch 'upstream/main' into feat/gorilla-fan
aravindjaimon d6f0c5c
refactor(fan): removed testcases for gorilla
aravindjaimon 1c1c12d
refactor(fan): improved gorilla fan implementation
aravindjaimon 7a99313
Gorilla fan: naming tweak
make-all File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Gorilla Fan V2 | ||
primary_entity: | ||
entity: fan | ||
dps: | ||
- id: 1 | ||
type: boolean | ||
name: switch | ||
icon: mdi:ceiling-fan | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- id: 2 | ||
type: string | ||
name: preset_mode | ||
mapping: | ||
- dps_value: normal | ||
value: Normal | ||
- dps_value: boost | ||
value: Boost | ||
- id: 3 | ||
type: integer | ||
name: speed | ||
range: | ||
min: 1 | ||
max: 5 | ||
|
||
secondary_entities: | ||
- entity: light | ||
name: Night Light | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
icon: mdi:ceiling-fan-light | ||
dps: | ||
- id: 15 | ||
type: boolean | ||
name: switch | ||
- entity: switch | ||
name: Boost | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
icon: mdi:car-turbocharger | ||
dps: | ||
- id: 115 | ||
type: boolean | ||
name: switch | ||
- entity: switch | ||
name: Sleep | ||
icon: mdi:sleep | ||
dps: | ||
- id: 113 | ||
type: boolean | ||
name: switch | ||
- entity: number | ||
name: Timer | ||
icon: mdi:timer-edit | ||
translation_key: timer | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
category: config | ||
dps: | ||
- id: 102 | ||
type: integer | ||
name: value | ||
unit: min | ||
range: | ||
min: 0 | ||
max: 360 |
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from homeassistant.components.fan import FanEntityFeature | ||
|
||
from ..const import FAN_PAYLOAD | ||
from ..helpers import assert_device_properties_set | ||
from .base_device_tests import TuyaDeviceTestCase | ||
|
||
SWITCH_DPS = "1" | ||
PRESET_DPS = "2" | ||
FANMODE_DPS = "3" | ||
|
||
class TestGorillaFanV2(TuyaDeviceTestCase): | ||
__test__ = True | ||
|
||
def setUp(self): | ||
self.setUpForConfig("gorilla_fan_v2.yaml", FAN_PAYLOAD) | ||
self.subject = self.entities.get("fan") | ||
|
||
def test_supported_features(self): | ||
self.assertEqual( | ||
self.subject.supported_features, | ||
( | ||
FanEntityFeature.PRESET_MODE | ||
| FanEntityFeature.SET_SPEED | ||
), | ||
) | ||
|
||
def test_preset_mode(self): | ||
self.dps[PRESET_DPS] = "normal" | ||
self.assertEqual(self.subject.preset_mode, "Normal") | ||
|
||
self.dps[PRESET_DPS] = "boost" | ||
self.assertEqual(self.subject.preset_mode, "Boost") | ||
|
||
def test_preset_modes(self): | ||
self.assertCountEqual(self.subject.preset_modes, ["normal", "boost"]) | ||
|
||
async def test_set_preset_mode_to_normal(self): | ||
async with assert_device_properties_set( | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.subject._device, | ||
{PRESET_DPS: "normal"}, | ||
): | ||
await self.subject.async_set_preset_mode("Normal") | ||
|
||
async def test_set_preset_mode_to_boost(self): | ||
async with assert_device_properties_set( | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.subject._device, | ||
{PRESET_DPS: "boost"}, | ||
): | ||
await self.subject.async_set_preset_mode("Boost") | ||
|
||
def test_speed(self): | ||
self.dps[PRESET_DPS] = "normal" | ||
self.dps[FANMODE_DPS] = 3 | ||
self.assertEqual(self.subject.percentage, 60) | ||
|
||
async def test_set_speed_in_normal_mode(self): | ||
self.dps[PRESET_DPS] = "normal" | ||
async with assert_device_properties_set(self.subject._device, {FANMODE_DPS: 3}): | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await self.subject.async_set_percentage(60) | ||
|
||
async def test_set_speed_in_boost_mode(self): | ||
self.dps[PRESET_DPS] = "boost" | ||
async with assert_device_properties_set(self.subject._device, {FANMODE_DPS: 5}): | ||
aravindjaimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await self.subject.async_set_percentage(100) | ||
|
||
async def test_set_speed_to_zero_turns_off(self): | ||
async with assert_device_properties_set( | ||
self.subject._device, {SWITCH_DPS: False} | ||
): | ||
await self.subject.async_set_percentage(0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferably there should be a products section here, with product id and name (with branding), and the top level name should be generic (Ceiling fan, for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see from #1971 that the brand is Atomberg, and the product name is Gorilla. The file naming and the name in the products section should reflect this. I'm not sure whether the V2 is part of the product name, or it is a misunderstanding that whatever config you originally installed this as is "V1" (but there is no atomberg or gorilla config, so there is no need to use v2 here as disambiguation if it is not part of the actual product name).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fan in question is from Atomberg and is referred to as the Renesa fan. However, this name is not present in any of our systems. In both the Tuya Dashboard and the Smart Life App, it is listed as the Gorilla Fan V2. Therefore, I used this name for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the product id? If you cannot get it from the cloud, it is also possible to read from
python -m tinytuya scan