esphome icon indicating copy to clipboard operation
esphome copied to clipboard

[WIP] Piecewise transformation for time based cover position

Open alexbarcelo opened this issue 4 years ago • 3 comments

What does this implement/fix?

Add a mechanism to translate non-linearity of certain curtains (e.g. roller shutter blinds) into the time-based cover component.

Types of changes

  • [ ] Bugfix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] Other

Related issue or feature (if applicable):

Discussion on this feature started at: https://github.com/esphome/feature-requests/issues/739

Pull request in esphome-docs with documentation (if applicable):

TBD

Test Environment

  • [ ] ESP32
  • [ ] ESP32 IDF
  • [x] ESP8266

Example entry for config.yaml:

cover:
  - platform: time_based
    ...
    piecewise:
      # Map 0.0 (from time) to 0.0 (true value of openness)
      - 0.0 -> 0.0
      - 0.2 -> 0.1
      - 0.65 -> 0.5
      - 1.0 -> 1.0

Checklist:

  • [x] The code change is tested and works locally.
  • [ ] Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Pending stuff I stumbled upon

I have no idea how to address the restore mechanism. My first approach is to have position the real position of the cover and use a time_position to track the time. However, the component tracks the time_position, but this attribute is not stored in the restore structure, so it cannot be set. This means that the restore does not work as intended.

The decision to use position and time_position also do not sit well with the idea of the time_based cover that open and close can have diferent durations. Maybe my approach is wrong? Maybe I have to throw this and start from scratch? For my scenario of a "time symmetric" cover it works good enough, but that may not be flexible enough.

alexbarcelo avatar Apr 11 '22 18:04 alexbarcelo

Thx for doing something about it. For my german covers this could be the solution for 50% position be optically 50% as well...

I am using the current based cover (https://esphome.io/components/cover/current_based.html) that is very similar, cause it uses the current sensor for fully open / close (so the end stops). So I hope this could be integrated there as well in a while...

Bascht74 avatar Jun 14 '22 22:06 Bascht74

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Sep 13 '22 00:09 github-actions[bot]

How to proceed? Would be nice to have that possibility…

Bascht74 avatar Sep 13 '22 04:09 Bascht74

There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. Thank you for your contributions.

github-actions[bot] avatar Dec 14 '22 00:12 github-actions[bot]

@alexbarcelo It would be so great to have this. Please, please finish it!!!!

Bascht74 avatar Dec 14 '22 01:12 Bascht74

At the beginning I tried to cut some corners and make a quick MVP of the piecewise feature, but along the way I realized that there were some mistakes deeply rooted in my implementation. Tracking internally time and then displaying the transformation make the save/restore mechanism to not work properly, and the Time Based Cover is not really the right tool for the job now that we have the more complete and versatile Feedback Cover (which can be used as a drop-in replacement for the time-based one).

My implementation should be easy to port (is quite brief), but I became a bit frustrated in my internal tests at home (I am using my branch for my home covers) and wandered to other projects. I still plan to provide a PR for it, but probably will be into a new PR, from scratch, into the Feedback Cover. It will hopefully be more resilient and useful for everybody (e.g. just having the acceleration_wait_time available should be a "free" improvement for large covers, a feature that is provided already by the Feedback Cover).

I hope to be able to clear my mindset and do it properly this time. For now, I'll be closing this one. Sorry for raising hopes! I hope the next one will be quicker and better :smile_cat:

alexbarcelo avatar Dec 25 '22 08:12 alexbarcelo

Hi @alexbarcelo, Thx for your thoughts and for not giving up! What are the other projects you wandered to? Is it Tasmota?

Bascht74 avatar Dec 25 '22 08:12 Bascht74

No, I meant personal home automation, DIY and similar hobby projects. All the ESP* devices in my home are ESPhome and that will not change in the near future.

alexbarcelo avatar Dec 25 '22 08:12 alexbarcelo