Skip to content

Support fan direction toggle & add EGLO Noosa RF codes #995

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions codes/fan/7240.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"manufacturer": "EGLO",
"supportedModels": [
"Noosa 202969",
"Noosa 202971",
"Noosa 202972",
"Noosa 202973",
"Noosa 204115",
"Noosa 204116",
"Noosa 204117",
"Noosa 204231",
"Noosa 204232",
"Noosa 204233"
],
"supportedController": "ESPHome",
"commandsEncoding": "Raw",
"speed": [
"1",
"2",
"3",
"4",
"5"
],
"commands": {
"off": "[341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"toggle_direction": "[341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"oscillate": "[341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"default": {
"1": "[341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"2": "[341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"3": "[341, -341, 682, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -341, 682, -682, 341, -341, 682, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"4": "[341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]",
"5": "[341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -8900, 341, -682, 341, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -682, 341, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -682, 341, -682, 341, -341, 682, -341, 682, -341, 682, -682, 341, -682, 341, -341, 682, -341, 682, -682, 341, -178000]"
}
}
}
29 changes: 19 additions & 10 deletions custom_components/smartir/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ def __init__(self, hass, config, device_data):
| FanEntityFeature.TURN_ON)

if (DIRECTION_REVERSE in self._commands and \
DIRECTION_FORWARD in self._commands):
self._direction = DIRECTION_REVERSE
DIRECTION_FORWARD in self._commands) \
or ('toggle_direction' in self._commands):
self._direction = DIRECTION_FORWARD
self._support_flags = (
self._support_flags | FanEntityFeature.DIRECTION)
if ('oscillate' in self._commands):
Expand All @@ -126,6 +127,7 @@ def __init__(self, hass, config, device_data):

self._temp_lock = asyncio.Lock()
self._on_by_remote = False
self._prev_direction = DIRECTION_FORWARD

#Init the IR/RF controller
self._controller = get_controller(
Expand Down Expand Up @@ -267,20 +269,27 @@ async def send_command(self):
async with self._temp_lock:
self._on_by_remote = False
speed = self._speed
direction = self._direction or 'default'
direction = 'default' if ('toggle_direction' in self._commands) else (self._direction or 'default')
oscillating = self._oscillating

if speed.lower() == SPEED_OFF:
command = self._commands['off']
self._prev_direction = DIRECTION_FORWARD
await self.send_single_command(self._commands['off'])
return
elif oscillating:
command = self._commands['oscillate']
await self.send_single_command(self._commands['oscillate'])
else:
command = self._commands[direction][speed]
await self.send_single_command(self._commands[direction][speed])

try:
await self._controller.send(command)
except Exception as e:
_LOGGER.exception(e)
if ('toggle_direction' in self._commands) and (self._direction != self._prev_direction):
self._prev_direction = self._direction
await self.send_single_command(self._commands['toggle_direction'])

async def send_single_command(self, command):
try:
await self._controller.send(command)
except Exception as e:
_LOGGER.exception(e)

async def _async_power_sensor_changed(self, entity_id, old_state, new_state):
"""Handle power sensor changes."""
Expand Down