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

SubActionTypeNames missing? #69

Closed wvuyk closed 4 years ago

wvuyk commented 4 years ago

I am trying to get the actIons and subactions to work in HS4. But although I do find a "SelectedSubActionIndex" property, I cannot set the names with something like "SubActionTypeNames". How should this work?

For triggers creating a list for "SubTriggerTypeNames" works fine, but it seems to be missing for actions?

wvuyk commented 4 years ago

Anyone cheking in now and then on the issues here? This one is a show stopper for the conversion of action for my plugin?

jldubz commented 4 years ago

You will have to handle SubActionTypeNames manually. The HS3 code has SubTriggerTypes integrated directly into the workflow, but Actions were never completely integrated in the same way. The SelectedSubActionIndex is for backward compatibility only right now because that information would otherwise be lost. The documentation will need to be updated to properly reflect this. Your best bet is to ignore it and manually handle it like another select list on your page because it is not processed automatically like the Triggers are.

wvuyk commented 4 years ago

Are you really saying it is not to be converted? Suggesting we leave users hanging on this offering NO conversion of their events?

image I never did anything special to list of names like above.other then creating the list in the plugin, HS3 did this! And I need it to convert for users..... unless you like to offer no conversion of their events?

Cannot be for real you are just closing issues like this?

jldubz commented 4 years ago

@wvuyk

There was no suggestion to leave users hanging in any way; so I'm not understanding your position here. There is no functionality to convert from the perspective of the SDK.

Sub-Actions were never implemented in the same way as Sub-Triggers as is evident by the existence of legacy members like ReadOnly Property SubTriggerName(ByVal TriggerNumber As Integer, ByVal SubTriggerNumber As Integer) As String and ReadOnly Property SubTriggerCount(ByVal TriggerNumber As Integer) As Integer but no matching members for Actions like SubActionName() or SubActionCount(). Any name matching you were doing was being performed by your plugin and not automatically by the HomeSeer platform.

I have done exactly what I am recommending for the Z-Wave plugin, and have run into no issues with it as a solution. Unless you are converting a legacy action you should be ignoring the SelectedSubActionIndex and implementing it manually as a select list on your configuration page as it is not handled by the ActionTypeCollection. During conversion, I query the SelectedSubActionIndex to identify which item is selected in the SelectList for the sub actions. In all other situations, I ignore the property because I handle it manually through the OnConfigItemUpdate() when I process changes for that SelectList. I am happy to share example code for you if you need it.

I closed this issue because there is no action item for it in terms of development necessary within the SDK at this time. The functionality was ported exactly as it was and verified to be working as expected. This is an improvement that we can look at moving forward; at which time we can reopen the issue.

wvuyk commented 4 years ago

@jldubz , Jon,

Here is all the code I needed in the hs3 version to show the magic window I posted in my earlier post:

`Region "Action Properties"

Sub SetActions()
    Dim o As Object = Nothing
    If actions.Count = 0 Then
        actions.Add(o, "JowiHue Actions")
        'actions.Add(o, "Set Scene")
        'actions.Add(o, "Start Animation")
        'actions.Add(o, "Stop running Animation")
    End If
End Sub

Sub SetSubActions()
    Dim o As Object = Nothing
    If subactions.Count = 0 Then
        subactions.Add(o, "(select an action)")
        subactions.Add(o, "Set Lights")
        subactions.Add(o, "Set Scene")
        subactions.Add(o, "Start Animation")
        subactions.Add(o, "Stop running Animation")
        subactions.Add(o, "Pause Polling")
        subactions.Add(o, "Dim running Animation")
    End If
End Sub

Function ActionCount() As Integer
    SetActions()
    Return actions.Count
End Function

ReadOnly Property ActionName(ByVal ActionNumber As Integer) As String
    Get
        SetActions()
        If ActionNumber > 0 AndAlso ActionNumber <= actions.Count Then
            Return IFACE_NAME & ": " & actions.Keys(ActionNumber - 1)
        Else
            Return ""
        End If
    End Get
End Property

ReadOnly Property SubActionName(ByVal SubActionNumber As Integer) As String
    Get
        SetSubActions()
        If SubActionNumber > 0 AndAlso SubActionNumber <= subactions.Count Then
            Return subactions.Keys(SubActionNumber - 1)
        Else
            Return ""
        End If
    End Get
End Property

`

All entries were prepared in the sample plugin for HS3. This resulted in the above image, which I did not have to program other then catching the SubActionNumber. When I use the current AbstractActionType the pluginSDK is offering, there is no way I can offer the same actionsubtypes to the user, let alone convert it. I have no knowledge on how to display this nor convert this for users.

Really, the plugin here is ready to show to users, including the conversion, except for this step. In ZWave also subactions are shown in HS3. What is needed other then the above code to use it in HS4?

Wim

wvuyk commented 4 years ago

Had a good night sleep and rechecked again this morning. Went over it several times in the past few weeks. But indeed, found it finally, I created this list myself! Sorry for that, it was my mistake!

Thanks!

wvuyk commented 4 years ago

@jldubz

I am testing what you described, earlier: Unless you are converting a legacy action you should be ignoring the SelectedSubActionIndex. I am now trying to convert the actions and helas, the SelectedSubActionIndex is always 0. In the HS3 plugin the ActInfo.SubTANumber is set and works fine there. It appears as this number is not copied to SelectedSubActionIndex.

Tried to guestimate the SubTANumber by looking at the fields that are set, but I have a challenge with 3 of the actions as they all contain the same fields, so I really would need this value?

Any suggestions on this?