@alindner19, in ways of introdutions I am the one who made the changes to the api to support all shade types. Your changes loog pretty good overall, from my experience in the submission of the v2 changes to core there could be some refactoring required to get this in, but that last 5% is always the hardest
Not near my hub to test but a quick clance over your code i can see a couple of issues.
We need to keep the data in the position data for means of HA, not means of the hub. The hub will ignore the additional data but HA needs it to know where the secondary shades are
HA uses PowerviewShadeMove
to store the data for some shades secondary position based on known behaviors. ie, when a tilt shade command is set we know the main will close/open for certain types but HA wont without this info.
both of the below will cause inconsistencies in HA so we need to add the other values back in
Query where this info came from - V2 have a MAX_BATTERY of 4, and previous math was to convert say 3/4 to 75% strength
Doesnt look to be any other breaking changes in the aiopvapi other than the ones regarding open/close position so if you want to submit a PR for those I can get that into a release (the original owner of the api has provided myself and another HA developer admin to the repo)
Once we get that in we can start work on getting it into HA - I had started work on this many months ago but yours is much more progressed. I was looking to make alot more of the changes in the upstream api as they like to clear up HA code as much as possible
ie instead of
return PowerviewShadeMove(
self._shade.convert_to_v2(
{
ATTR_PRIMARY: MIN_POSITION,
}
),
self._shade.convert_to_v2(
{
ATTR_SECONDARY: MAX_POSITION,
ATTR_TILT: MIN_POSITION,
}
),
)
In my changes i was making the upstream API do the calculating changing PowerviewShadeMove
to take 0-100, ie true percentages which is what HA calculates them to anyway.
So rather than processing the 0/65355 for v2 an 0/1 for v3 we send the upstream a percentage value and the upstream can calcluate for the api version. Ideally the code in HA is preferred to be as simple as possible.
Doing the above makes the above code example (from yours) into something like the below that should never need to change, and only the upstream would
return PowerviewShadeMove(
{
ATTR_PRIMARY: 0,
},
{
ATTR_SECONDARY: 100,
ATTR_TILT: 0,
},
)
If you want to submit the aiopvapi for pull I can do an actual review of the code, and then help with the HA integration side from there. I only have v2 hub but as i wrote most of the existing code i do know where things may break.
If the HA integration is submitted in its current state, i suspect the merge to take months just for them to review - it is preferred for each commit to be as small as possible, while still being functional.
For instance - we will probably need to break your HA commit into many smaller ones, adding functionality to each. First adding detection with shades only - next commit to include sensors, scenes, buttons etc - this will get it into HA much quicker
Will still need to move a couple things to upstream but nothing wrong with it being 3.0.something when we are ready for core integration
Send me a PM or just hit back here so we can start getting it into core without breaking the current functionality