Skip to content
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

Switchbot Blindtilt template example gives error #27168

Open
withay opened this issue Apr 27, 2023 · 22 comments
Open

Switchbot Blindtilt template example gives error #27168

withay opened this issue Apr 27, 2023 · 22 comments

Comments

@withay
Copy link

withay commented Apr 27, 2023

Feedback

When I do a simple copy/paste of the template into HA's Dev tools Template editor, I get: UndefinedError: 'None' has no attribute 'attributes'

When I change the example to using my own blind tilt name, I get: UndefinedError: 'position' is undefined

URL

https://www.home-assistant.io/integrations/switchbot/

Version

2023.4.6

Additional information

No response

@home-assistant
Copy link

Hey there @bdraco, @Danielhiversen, @RenierM26, @murtas, @Eloston, @dsypniewski, mind taking a look at this feedback as it has been labeled with an integration (switchbot) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of switchbot can trigger bot actions by commenting:

  • @home-assistant close Closes the feedback.
  • @home-assistant rename Awesome new title Renames the feedback.
  • @home-assistant reopen Reopen the feedback.
  • @home-assistant unassign switchbot Removes the current integration label and assignees on the feedback, add the integration domain after the command.

@dannytsang
Copy link
Contributor

Are you able to provide your template and confirm you have changed
{{ int(states.cover.example_blinds.attributes.current_tilt_position)*2 }} to use an entity in your setup?

@withay
Copy link
Author

withay commented Apr 28, 2023

Here is my template (I have seven blindtilts, this is the first one):


cover:
  - platform: template
    covers:
      living_room_blind_1:
        device_class: blind
        friendly_name: Living Room Blind 1
        open_cover:
          service: cover.set_cover_tilt_position
          data:
            tilt_position: 50
          target:
            entity_id: cover.living_room_blind_1
        close_cover:
          service: cover.set_cover_tilt_position
          data:
            tilt_position: 0
          target:
            entity_id: cover.living_room_blind_1
        position_template: >
          {{ int(states.cover.living_room_blind_1.attributes.current_tilt_position)*2 }}
        set_cover_position:
          service: cover.set_cover_tilt_position
          data:
            tilt_position: "{{position/2}}"
          target:
            entity_id: cover.living_room_blind_1

Also - this has created a new entity: cover.living_room_blind_1_2 and I'm assuming (my apologies, I'm new at this, and this is my first attempt at templates) that is the one I use, not the original entity.

@dannytsang
Copy link
Contributor

Correct. The old entity will exist because the new one would be using the values of the old one but you would use the new entity to control it.

Can you check in Developer Tools > States and see if cover.living_room_blind_1 has the attribute current_tilt_position please?

Here's an example from mine:
image

@withay
Copy link
Author

withay commented Apr 29, 2023

It does! cover.living_room_blinds_1 does. cover_living_room_blinds_1_2 does not.

devtlbt

@dannytsang
Copy link
Contributor

That sounds about right re: cover.living_room_blinds_1 does. cover_living_room_blinds_1_2 does not given the error message.

I'm afraid I'm at a loss as to why you're getting the error.

@withay
Copy link
Author

withay commented Apr 29, 2023

I appreciate you taking a look. Hopefully someone will chime in.

@withay
Copy link
Author

withay commented Apr 30, 2023

Oh, if it helps whoever next looks, randomly I get the below:
intblnd
What shows in Living Room Blind 4_2 (compared to 5_2) - I get current position, for anywhere from a split second - to a minute, or more. Not on every blind, and not all the time or every time.

@withay
Copy link
Author

withay commented May 1, 2023

Correct. The old entity will exist because the new one would be using the values of the old one but you would use the new entity to control it.

Oddly, if I use them in a script or automation, I get an error "XXX_2 does not support this function" but if I make a card with them on it and individually click the up or down arrow for each, it works fine.

@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved.
If this issue is still relevant, please let us know by leaving a comment 👍
This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale The PR had no activity for quite some time, and is marked as Stale label Jun 30, 2023
@withay
Copy link
Author

withay commented Jun 30, 2023

This is still an active, not-fixed issue.

@github-actions github-actions bot removed the Stale The PR had no activity for quite some time, and is marked as Stale label Jun 30, 2023
@github-actions
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved.
If this issue is still relevant, please let us know by leaving a comment 👍
This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale The PR had no activity for quite some time, and is marked as Stale label Aug 29, 2023
@withay
Copy link
Author

withay commented Aug 29, 2023

This is still an active, not-fixed issue.

@github-actions github-actions bot removed the Stale The PR had no activity for quite some time, and is marked as Stale label Aug 29, 2023
@LeiChat
Copy link

LeiChat commented Sep 23, 2023

Is this error related?
Cover position value must be between 0 and 100. Value was: 118

I'm using the simple template described on the HA Switchbot integration page.

{{ int(states.cover.blind_tilt_e9f3.attributes.current_tilt_position)*2 }} returns 118

@withay
Copy link
Author

withay commented Sep 23, 2023

I think you get that error because the blind is closing UP instead of DOWN. But we'll never be sure, because this issue is still opened with no sign of responses or fixing. If I knew HOW to do it, I would. I do not.

@LeiChat
Copy link

LeiChat commented Sep 23, 2023

I will try tilting it manually and observing the state values. Perhaps depending on the orientation of the blind we need an alternative calculation to multiplying the state value by 2 (where it's assuming 0 to 50)

Or could we suppress the error by getting it to consider any state value greater than 50 to be 100?

@withay
Copy link
Author

withay commented Sep 23, 2023

I wish I knew. I never want mine to be over 50. 50 is fully opened, 0 is fully closed. I THOUGHT the template made it so that's what HA thinks - that 50 IS 100. I dunno.

@LeiChat
Copy link

LeiChat commented Sep 23, 2023

I wondered if perhaps the service call to open the blind triggers the motor and it ends up running a little too far, due to lag (Bluetooth/HA?) ending up at 59, resulting in the 118 reported by the template. I will do some testing.

{{ min(100, int(states.cover.blind_tilt_e9f3.attributes.current_tilt_position)*2) }}

Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved.
If this issue is still relevant, please let us know by leaving a comment 👍
This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale The PR had no activity for quite some time, and is marked as Stale label Nov 22, 2023
@withay
Copy link
Author

withay commented Nov 24, 2023

No, this is not fixed yet.

@github-actions github-actions bot removed the Stale The PR had no activity for quite some time, and is marked as Stale label Nov 24, 2023
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved.
If this issue is still relevant, please let us know by leaving a comment 👍
This issue has now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added Stale The PR had no activity for quite some time, and is marked as Stale and removed Stale The PR had no activity for quite some time, and is marked as Stale labels Jan 23, 2024
@withay
Copy link
Author

withay commented Jan 23, 2024

This is still active. There is no activity because nothing has changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants