Sunsa Blinds Wands Integration

Sunsa Smart Blinds Integration


Monitor and control your Sunsa blinds wands from Home Assistant.

  • Control the position of the blinds.
  • Monitor the wands battery level.
  • Monitor other wand sensors.
  • See wands diagnostic info.


The missing integration with Sunsa smart wands was a low-hanging fruit like what I’ve been sniping for a while in order to get my hands into putting together an integration. After realizing that no one had tackled such a fan project even with a REST API publicly available I wasted no time to get on it.

Installation

The easiest installation method is through HACS so that you can add the integration repository. For other methods and more info see the README.

Credit must be given to Sunsa for making themselves so accessible and helpful during the development of the integration.

Hope you find it useful!

4 Likes

This is wonderful, thank you so much!

After installing this yesterday everything was working great. This morning, the blinds did not open automatically - I found that the authentication with UID and APIkey to Sunsa failed. Re-entering these keys via the config failed as being invalid.

So I then tried to login to Sunsa’s website via my email account - and it too failed. Requested a password reset email and 10 minutes later, it has not shown up.

Anyone else having this problem?

Last night at 6:00 am UTC the integration asked me to reauthenticate. I simply reloaded it and it’s been fine since. Checking the logs, polling the cloud first timed out and then the API returned 401. Looks like a glitch on the Sunsa side.

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).