Sunsa Blinds Wands Integration

Thanks for confirming there was indeed an issue on Sunsa’s end. I just now re-entered the UID/key and this time, it accepted it. So all good for now.

Meanwhile, I’m working with Sunsa support on why website auth is failing - but that’s really not relevant now to this issue.

EDIT: The credentials for the Sunsa mobile app are unique to it and have no relevance to the sunsawands website. So that explains why the website auth was failing. Next time there is a glitch like this, I need to verify if the Sunsa mobile app can connect or not. I haven’t actually used that app in well over a year and had forgotten about it too!

Thanks @odwide for building this! It’s great to finally have my Sunsa wands in HA!

1 Like

Hi, i wanted to ask a quick question, I was able to add the integration and it found the sunsa cover. I just wanted to know in regards to intended behavior, if the integration only allows for open and close in a single direction.

Example would be, currently the device goes from open to closed in the down position but there is not a way ive seen for it to be closed in the up direction.

I wanted to use the integration with this integration GitHub - basbruss/adaptive-cover: An Adaptive Cover component for HomeAsisstant to control covers based on the sun's position

When I chose tilt blinds as an option with it, none of the blinds added through the sunsa integration were shown.

I looked at the adaptive-cover integration and it seems to be relying on specific functionality. See adaptive-cover/custom_components/adaptive_cover/config_flow.py at 888ebc85c1b2ba3399eb164c2ed37ccf3144114a · basbruss/adaptive-cover · GitHub

It seems to be looking for set tilt functionality. The integration for this blinds uses the cover.set_position service instead of cover.set_tilt_position along with the position terminology instead of tilt terminology.

Could this be changed to more accurately reflect this type of blind usage with home assistant?

HA doesn’t support setting the absolute position of blinds (movement offset in any direction), only in one direction. The integration closes the blinds based on the Default Smart Home Direction setting in the Sunsa app. However, you can use the service sunsa.set_absolute_position to move them from -100 to 100.

Thanks for the suggestion. I tested with _tilt features and the main benefit is that the position of the blinds is represented with a nice visual gradient in the frontend.

|

image

But switching to _tilt would break existing installations until users manually change the service and attribute calls. Unless _tilt features are instead added with the current non-_tilt ones, which would allow to use either. The problem then is that it’ll be confusing to tell what’s the difference (there’s no functional difference) and, even worse, the More info screen will show both sliders:

A breaking change notice could be added in the release notes a few months in advance of removing the non-_tilt features.

I really like the visual gradient that _tilt provides and think the change is worth it. If someone else agrees, let me know.

I personally like the changes with tilt. I was previously manually adding sunsa blinds via rest commands and templates and used the tilt.

Appreciate the info. Sorry for what may be a basic question, new to HA, have messed with editing things but haven’t had to learn this yet.

I saw the service.yaml in the Sunsa folder, so I add service sunsa.set_absolute_position to configuration.yaml as a new line? Or would I use this elsewhere. Thanks

No need to get in the config. To use the service you just call it from an automation action or a script action. To see how it works, use Developer Tools > Services:

Here’s a sample script to move blinds to an absolute position:

alias: Move Blinds
sequence:
  - repeat:
      sequence:
        - alias: Execute action
          if:
            - condition: template
              value_template: "{{ blind_action in ['open', 'close'] }}"
              alias: Action is open or close
          then:
            - service: cover.{{ blind_action }}_cover
              target:
                entity_id: "{{ repeat.item }}"
              data: {}
              alias: Open or close
          else:
            - service: sunsa.set_absolute_position
              metadata: {}
              data:
                position: "{{ position }}"
              target:
                entity_id: "{{ repeat.item }}"
              alias: Set absolute position
      for_each: "{{ blinds }}"
description: Move blinds only if they are not locked.
mode: parallel
icon: mdi:blinds-vertical-closed
fields:
  blinds:
    name: Blinds
    selector:
      entity:
        filter:
          integration: sunsa
          domain: cover
        multiple: true
    required: true
  blind_action:
    name: Blind action
    required: true
    selector:
      select:
        options:
          - label: Open
            value: open
          - label: Close
            value: close
          - label: Move
            value: move
  position:
    name: Position
    default: 0
    required: true
    description: "New position (0: open, -100: closed backwards, 100: closed forwards)."
    selector:
      number:
        min: -100
        max: 100
        step: 10
trace:
  stored_traces: 10

Any further thoughts into making the changes? If the answer is keep as is, could you provide a patch or point to changes I can make locally?

I like the idea but it seems that general interest in the this is low. I have to research how to make the changes without breaking existing installations.

But by all means you can fork the repo and make your own version. You simply have to replace the inherited methods and supported features in cover.py by the their _tilt counterparts.

Thanks for building this. I’ve been using a cobbled series of command line curl integrations which has worked but is not nearly as elegant. This is great!

1 Like

@odwide Am a little lost in the I like the idea but it seems that general interest in the this is low.

I am very interested in this integration. What is the requested change?

BTW - I just came across your work - thank you in advance for this.

2nd question - how does one (I am new to HA) learn about such good work with integrations?

Thanks!

It’s about switching to using _tilt services (from the current cover.open_cover, etc, to cover.open_cover_tilt and others). Check my comment above.

You can find third party integration like this by searching for them in HACS or simply using a search engine (search by the company or product name in relation to Home Assistant).

@odwide thanks. Re-read your comment. Yes, i would support your change to the visual gradiant that _tilt provides. Like it!

On another note, i can not get the sunsa app api key as each time i hit the toggle, the app closes. Not good. The app is fully functional otherwise.

I have an email into sunsa to ask why and how ro get the api key.

But in case you might know, any help is appreciated.
Thanks!

I saw that problem in the app once a few months ago but don’t remember how exactly I fixed. I think that I wiped data and reinstalled it (Android).

@odwide oh…that does not sound good. Ok - thanks. Will see what tech support at Sunsa provides. So - FYSA - I am on hold to install your integration until that happens.

@odwide I heard back from Sunsa Tech Support on the App failing on the API toggle. Their guidance was to “generate a new API” and just keep going. They further passed this issue on to their engineering team.

So - with that solved (sort of) moving to the next effort: With the new API and UserID, and already having HACS installed, followed your install guide (GitHub - r01k/ha_sunsa: Sunsa smart blinds integration for Home Assistant) and whamo! The Sunsa Integration was installed with no issues. I tested several functions: open, close, open a percentage, etc…all worked flawlessly. And in several cases, much faster than the Sunsa Android App.

so - THANKS !

Next - yes, I would now double vote for this suggestion/discussion: (Sunsa Blinds Wands Integration - #10 by odwide).

You just gotta like it when something just works!!

And again - THANKS !

Glad that you got all sorted out! Sunsa support is very responsive. Now, onto setting up your automations and organizing the dashboards.

Ok, now I have more motivation to find out how to make the change. I’ll ask other HA devs about it and report back about feasibility.

1 Like

I second @dwdonnelly in his request as well. It would be great to be able to use the full functionality of sunsa within HA dashboard (tilting in both directions/percentage). I havent found a good solution for this yet and I think its mainly due to how blinds are defined it HA. I have some automations set up using the service call but my wife likes more granular control so she ends up using the sunsa app. Not a deal breaker but it would be great to have it all within HA.