Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

new cover options #79

Open
wants to merge 2 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ lib64/
parts/
sdist/
var/
.vscode/
wheels/
*.egg-info/
.installed.cfg
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this file

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ;)

"python.linting.pylintEnabled": false
}
8 changes: 8 additions & 0 deletions haaska.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,14 @@ def turn_on(self):
def turn_off(self):
self._call_service('cover/close_cover')

def set_percentage(self, val):
self._call_service('cover/set_cover_position', {'position': val})

def get_percentage(self):
state = self.ha.get('states/' + self.entity_id)
value = int(state['current_position'])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all covers report their current_position (specifically Somfy zwave blinds). I'm doing a terrible hack to make this work on my system:

    def get_percentage(self):
        return 50

    def set_percentage(self, val):
        if val > 50:
            self._call_service('cover/open_cover')
        if val < 50:
            self._call_service('cover/close_cover')

Definitely not saying to do that but you need to check if current_position is None to be safe here.

return value


class LockEntity(Entity):
def set_lock_state(self, state):
Expand Down