BrobstonCreations / yet-another-smart-vent

GNU Affero General Public License v3.0
469 stars 14 forks source link

Add tilt control #14

Closed tagno25 closed 2 years ago

tagno25 commented 2 years ago

Add the ability to move the vent to a specific position between 0% and 100%. Also added the ability to see what the position is, for if/when a lever gets added later.

TonyBrobston commented 2 years ago

Thanks for adding this!

Both of the things you mentioned and added have been on my mind.

I'll give this a test when I have a minute. I need to finish updating documentation for installing using ESPHome and then I'll merge this branch, shouldn't be more than a few days.

Thanks for your contribution.

TonyBrobston commented 2 years ago

This is working great!

Thanks again!

TonyBrobston commented 2 years ago

I did notice that when I manually move the louvers, the position updates correctly. However, where ESPHome thinks the servo is doesn't match up with that. I haven't investigated, but I imagine there's a way to update that too.

To reproduce, tell the vent to close; manually move the vent to open, then click close again; it goes to shut super fast, but should do it slowly.

tagno25 commented 2 years ago

It looks like that issue is because the protected value of "currentvalue" for the servo is not updated. And it does not seem to be able to be updated without moving the servo electrically.

The fix I would think would work best, would be to extend the servo component to have a feedback variable, similar to the cover template with a lambda.

TonyBrobston commented 2 years ago

It may also be possible to read the potentiometer value, map that to a servo value and tell the servo to move to that position. In theory, it would either not move or barely move. I'm not sure this would be a good approach, only because I don't know what event handler to use that wouldn't try and fire essentially all the time.

I'm pretty new to ESPHome and C/C++, but not development. What does extending the servo component look like? Is that possible without changes to ESPHome itself?

IMO this bug isn't a show stopper, so I'll move this stuff forward either way. But, when I do add a lever, it would be nice to have this working properly. I do have a design in mind for a lever, I just need to print and test it; but it's a bit lower on my list.

Thanks again for the help!