HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

SubTANumber not reflected by SelectedSubActionIndex #75

Closed wvuyk closed 4 years ago

wvuyk commented 4 years ago

Please check issue #69 for this. I cannot reopen this by myself but there are still issues converting ald actions.

Check my last post on this issue. The remark was that the field SelectedSubActionIndex would be filled with the information from the original ActInfo.SubTANumber . What ever I tried, that is not working. All action items are presented correctly in the plugin, but not this ActInfo.SubTANumber which is needed to do the conversion 100%. At this point I am guestimating the subaction used, but that cannot be right as several actions use the same item.

How can I get the ActInfo.SubTANumber presented in HS4? The data is there....

Wim

wvuyk commented 4 years ago

Any chance to get at least an answer to this issue?

rjhelmke commented 4 years ago

I will have someone get an answer for you.

spudwebb commented 4 years ago

@wvuyk have you implemented the constructor with the subTypeNumber parameter in your action class?

protected AbstractActionType(int id, int subTypeNumber, int eventRef, byte[] dataIn, ActionTypeCollection.IActionTypeListener listener)

wvuyk commented 4 years ago

I had to implement three constructors, missing one throws errors (in VB)

Public Sub New()
        MyBase.New
        '  Log("new called without params")
 End Sub

Public Sub New(ByVal id As Integer, ByVal eventRef As Integer, ByVal dataIn As Byte(), oListener As ActionTypeCollection.IActionTypeListener, Optional logDebug As Boolean = False)
        MyBase.New(id, eventRef, dataIn, oListener, logDebug)
End Sub

Public Sub New(ByVal id As Integer, ByVal SelectedSubActionIndex As Integer, ByVal eventRef As Integer, ByVal dataIn As Byte(), oListener As ActionTypeCollection.IActionTypeListener, Optional logDebug As Boolean = False)
        MyBase.New(id, SelectedSubActionIndex, eventRef, dataIn, oListener)

End Sub

I have tried to check when which constructor is called, but it is called very often during execution or edit of actions. It seems quite random on which constructor is called, not something I really understand what and why this is needed.

wvuyk commented 4 years ago

Maybe another point I noticed here, if an (HS3) action is entering the ProcessData routine, SelectedSubActionIndex is aways 0, never -1 or other values, like the documentation states. Don't know if that is giving clues in this area.....

jldubz commented 4 years ago

@wvuyk Thanks for your patience with this. I'll refrain from adding this to the original issue and just post it on this one so we can continue that issue here.

I've outlined the whole lifecycle for actions and triggers in the API Reference https://homeseer.github.io/Plugin-SDK-Docs/api/HomeSeer.PluginSdk.Events.AbstractActionType.html?tabs=cs

I successfully made this work for upgrading actions from HS3 to HS4 with no issues. To access the SubTANumber you MUST implement this constructor signature protected MyCustomActionType(int id, int subTypeNumber, int eventRef, byte[] dataIn, ActionTypeCollection.IActionTypeListener listener)

The constructor you posted here:

Public Sub New(ByVal id As Integer, ByVal SelectedSubActionIndex As Integer, ByVal eventRef As Integer, ByVal dataIn As Byte(), oListener As ActionTypeCollection.IActionTypeListener, Optional logDebug As Boolean = False)
        MyBase.New(id, SelectedSubActionIndex, eventRef, dataIn, oListener)

End Sub

is not one of the valid constructor signatures and so it is never captured and called by the ActionTypeCollection. When the constructor with the signature protected MyCustomActionType(int id, int subTypeNumber, int eventRef, byte[] dataIn, ActionTypeCollection.IActionTypeListener listener) is not implemented by the action type, either of the other two signatures is used based on whether logDebug is flagged or not. You are probably not seeing the SelectedSubActionIndex populate as you expect because you are not implementing the right constructor.

Try adding this to your class:

Public Sub New(ByVal id As Integer, ByVal SelectedSubActionIndex As Integer, ByVal eventRef As Integer, ByVal dataIn As Byte(), oListener As ActionTypeCollection.IActionTypeListener)
        MyBase.New(id, SelectedSubActionIndex, eventRef, dataIn, oListener)

End Sub

And let me know if you are still not seeing it populate.

wvuyk commented 4 years ago

Jon-Luke,

Sorry for the delay here. Was distracted by other issues in life, which seem to settle now here.

Finally was able to test today and it looks like it is working now. I expected the logdebug parameter would be valid for all constructors, so added it, not realizing this was the cause behind this issue.

Thanks for the explanation. Will be back on the other issues soon.

Wim

jldubz commented 4 years ago

@wvuyk let me know if you have any more questions on this issue. It sounds like you've got it. Referenced by PSDK-32