Hi, (type 51)
I set up a VM with ha. Put my log level to debug.
Now I don’t get an error message anymore, but the tilt function is not working. The up and down does work.
The logs show this:
2022-04-08 20:18:24 DEBUG (MainThread) [aiopvapi.helpers.aiorequest] url: http://<ip>/api/shades/42081
2022-04-08 20:18:24 DEBUG (MainThread) [aiopvapi.helpers.aiorequest] data: {'shade': {'id': 42081, 'positions': {'position1': 17694, 'posKind1': 3}}}
2022-04-08 20:18:25 DEBUG (MainThread) [custom_components.hunterdouglas_powerview_custom.cover] Raw data update: {'id': 42081, 'type': 51, 'capabilities': 2, 'batteryKind': 1, 'smartPowerSupply': {'status': 0, 'id': 0, 'port': 0}, 'batteryStatus': 4, 'batteryStrength': 180, 'roomId': 14640, 'firmware': {'revision': 2, 'subRevision': 5, 'build': 287, 'index': 280}, 'name': 'T2ZmaWNlIFdpbmRvdw==', 'groupId': 52387, 'positions': {'position1': 17694, 'posKind1': 3}, 'signalStrength': 4}
2022-04-08 20:18:25 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=cover.office_window, old_state=<state cover.office_window=open; current_position=1, current_tilt_position=0, roomName=Office, device_class=shade, friendly_name=Office Window, supported_features=255 @ 2022-04-08T20:17:02.282238+02:00>, new_state=<state cover.office_window=opening; current_position=1, current_tilt_position=27, roomName=Office, device_class=shade, friendly_name=Office Window, supported_features=255 @ 2022-04-08T20:18:25.927899+02:00>>
2022-04-08 20:18:25 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140034874143360] Sending {"id":2,"type":"event","event":{"c":{"cover.office_window":{"+":{"s":"opening","lc":1649441905.927899,"c":{"user_id":"<userid>","id":"09450680988b347516d06e3ba3312d83"},"a":{"current_tilt_position":27}}}}}}
2022-04-08 20:18:25 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140034780458576] Sending {"id":2,"type":"event","event":{"c":{"cover.office_window":{"+":{"s":"opening","lc":1649441905.927899,"c":{"user_id":"<userid>","id":"09450680988b347516d06e3ba3312d83"},"a":{"current_tilt_position":27}}}}}}
2022-04-08 20:18:25 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140034780458576] Sending {"id":44,"type":"result","success":true,"result":{"context":{"id":"09450680988b347516d06e3ba3312d83","parent_id":null,"user_id":"<userid>"}}}
2022-04-08 20:18:33 DEBUG (MainThread) [aiopvapi.helpers.aiorequest] Sending a get request
2022-04-08 20:18:33 DEBUG (MainThread) [aiopvapi.helpers.aiorequest] Sending GET request to: http://<ip>/api/shades/42081
2022-04-08 20:18:36 DEBUG (MainThread) [custom_components.hunterdouglas_powerview_custom.cover] Raw data update: {'id': 42081, 'type': 51, 'capabilities': 2, 'batteryKind': 1, 'smartPowerSupply': {'status': 0, 'id': 0, 'port': 0}, 'batteryStatus': 4, 'batteryStrength': 180, 'roomId': 14640, 'firmware': {'revision': 2, 'subRevision': 5, 'build': 287, 'index': 280}, 'name': 'T2ZmaWNlIFdpbmRvdw==', 'groupId': 52387, 'positions': {'posKind1': 1, 'position1': 898, 'posKind2': 3, 'position2': 0}, 'signalStrength': 4, 'timedOut': False}
2022-04-08 20:18:36 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=cover.office_window, old_state=<state cover.office_window=opening; current_position=1, current_tilt_position=27, roomName=Office, device_class=shade, friendly_name=Office Window, supported_features=255 @ 2022-04-08T20:18:25.927899+02:00>, new_state=<state cover.office_window=open; current_position=1, current_tilt_position=0, roomName=Office, device_class=shade, friendly_name=Office Window, supported_features=255 @ 2022-04-08T20:18:36.402120+02:00>>
2022-04-08 20:18:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140034874143360] Sending {"id":2,"type":"event","event":{"c":{"cover.office_window":{"+":{"s":"open","lc":1649441916.40212,"c":{"user_id":null,"id":"4d56ca7111f04222568b4fd9cfae4578"},"a":{"current_tilt_position":0}}}}}}
2022-04-08 20:18:36 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140034780458576] Sending {"id":2,"type":"event","event":{"c":{"cover.office_window":{"+":{"s":"open","lc":1649441916.40212,"c":{"user_id":null,"id":"4d56ca7111f04222568b4fd9cfae4578"},"a":{"current_tilt_position":0}}}}}}
Edit:
I tested the raw requests and the following command seems to function (based on V2 from the API manual)
Fully closed with tilt “down”
Invoke-WebRequest -Method PUT -ContentType "application/json" -UseBasicParsing -Uri http://IP/api/shades/ID -Body '{ "shade": { "positions": { "posKind2": 3, "position2": 65535, "posKind1": 1, "position1": 0 } } }'
Partly open with tilt “down”
Invoke-WebRequest -Method PUT -ContentType "application/json" -UseBasicParsing -Uri http://IP/api/shades/ID -Body '{ "shade": { "positions": { "posKind2": 3, "position2": 65535, "posKind1": 1, "position1": 10000 } } }'
I think it works the same as the ShadeBottomUpTiltAnywhere in the source of aio-powerview-api.
Edit 2:
I altered your custom component and now it’s working:
class PowerViewShadeWithTilt(PowerViewShade):
...
async def _async_tilt(self, target_hass_position):
"""Move the shade to a position."""
current_hass_position = self.current_cover_tilt_position
* current_position = self.current_cover_position
steps_to_move = abs(current_hass_position - target_hass_position)
self._async_schedule_update_for_transition(steps_to_move)
self._async_update_from_command(
await self._shade.move(
{
* ATTR_POSITION1: hass_position_to_hd(current_position),
* ATTR_POSKIND1: 1,
* ATTR_POSITION2: hass_position_to_hd(target_hass_position),
* ATTR_POSKIND2: 3,
}
)
)
self._is_opening = False
self._is_closing = False
if target_hass_position > current_hass_position:
self._is_opening = True
elif target_hass_position < current_hass_position:
self._is_closing = True
self.async_write_ha_state()
When opening or closing the blinds (up/down) , the tilt position is not updated in the gui (tilt slider in ha). It updates sometimes when the blinds are still in motion and then the data is wrong. The blinds tilt one way when the blinds are moving up and the other way when moving down. I sometimes see the slider for the tilt command change to the position it is when going up/down.
The _async_move command should also be different for my shades. It has to include the tilt position, otherwise it won’t tilt to the last known position when opening/closing. So it should call the same function as _async_tilt, but then with tilt position requested and position value as parameter to the function.
I added an override for it in the PowerViewShadeWithTilt, but I think it needs it’s own class.
class PowerViewShadeWithTilt(PowerViewShade):
...
async def _async_move(self, target_hass_position):
"""Move the shade to a position."""
* current_tilt_position = self.current_cover_tilt_position
current_hass_position = self.current_cover_position
steps_to_move = abs(current_hass_position - target_hass_position)
self._async_schedule_update_for_transition(steps_to_move)
self._async_update_from_command(
await self._shade.move(
{
ATTR_POSITION1: hass_position_to_hd(target_hass_position),
ATTR_POSKIND1: 1,
* ATTR_POSITION2: hass_position_to_hd(current_tilt_position),
* ATTR_POSKIND2: 3,
}
)
)
self._is_opening = False
self._is_closing = False
if target_hass_position > current_hass_position:
self._is_opening = True
elif target_hass_position < current_hass_position:
self._is_closing = True
self.async_write_ha_state()