The application cannot control the expanded / collapsed state or a notification. It is handled by the android system. It will automatically expand a notification based on the space available.
Now if you manually collapse a notification, it ideally stays collapsed, until the notification is updated. In case of power toggles, the notification would be getting updated due to changes in any of the toggles (for example you clicked a toggle) or any system state change. In that case android thinks of it as a new notification and expands it again.
There is no API to change the notification state (collapsed or expanded) as of now. I will keep it updated as soon as something is available.
Tip: You can add a 'Second Notification Row' toggle in the first row of the notification widget and just enable or disable it to keep the widget expanded or collapsed.