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

Building buttons along with dropdown adds the button values to the dropdown #294

Closed rmasonjr closed 2 years ago

rmasonjr commented 2 years ago

Environment

HomeSeer

OS

[Windows,]

HS Version

[v4.2.13.0]

Development

PSDK Version

[v1.4.1.0]

Language

[VB]

IDE

[VS2017]

Dev OS

[Windows]

Plugin

What plugin is this issue for? OMNI

Problem

There are 2 screenshots attached. Screenshot1 shows where I add an Off/On/Toggle button along with a dropdown to Dim/Brighten a device. The Off/On is added to the dropdown although I'm creating the SortedDictionary separately.

I need them separated since their EControlUse are all different.

Also, why doesn't the Toggle button show in the GUI? I have it on the correct row/col but it's not displaying.

Thanks Rob

Screenshots

screenshot2 screenshot1

rmasonjr commented 2 years ago

More Info:

When you use Alexa/GH for voice control, I am under the impression that the EControlUse drives the process. For example, "Alexa, Dim the lamp to 10%" would use the device's EControlUse.Dim property to dim the device. Also, "Alexa, turn off the lamp" would use the device's EControlUse.Off property to turn off the device.

Now, I have a device where I want 2 buttons, On and Off, with their EControlUse set to On/Off. I also want a dropdown with EControlUse.Dim, however, a dropdown control is adding On and Off to the select list. Since the dropdown can only have one EControlUse, I dont think my device will be controllable by Alexa/GH.

Sgt-Shultz commented 2 years ago

You should only need one set of values in the drop list, the 10% to 90%..., the verbs 'dim' and 'brighten' are handled by the voice command control (Alexa/GH) as either an absolute value (set to 20%), or a delta (brighten by 20%). The eControlUse enums should only be set one time per device..., this includes all the features of a device since they are all part of the overall object. So in your example you should have a root device that has no controls on it, then a feature with an On button, an Off button, and a drop list with a range from 10% to 90%. Each one of those objects would have a unique control use associated with it, so that the discovery and command processes can determine what traits the devices has and what value to set the device to. This means the drop list would have one control use of 'dim'. At a level of 0, the device is off so instead of the drop list, the off button would be used. Same for a level of 100.

For the toggle button, I'm thinking perhaps the value it is set to is also a value in another control..., maybe the drop list?

A screenshot of your enums would be helpful so I can see the values you using in the code.

rmasonjr commented 2 years ago

Thanks Sgt!

Here's the code I've been playing around with:

Dim ff = FeatureFactory.CreateFeature(OMNI_NAME). WithName(u.unitName). WithLocation(OMNI_NAME & " Units"). WithLocation2(OMNI_NAME). WithMiscFlags(withFlags). WithoutMiscFlags(withoutFlags). WithExtraData(PED). AsType(EFeatureType.Generic, 0).WithDefaultValue(0). AddButton(0, "Off", New ControlLocation(1, 1), EControlUse.Off). AddButton(255.0, "On", New ControlLocation(1, 2), EControlUse.On). AddButton(101.0, "Toggle", New ControlLocation(1, 3), EControlUse.OnAlternate). AddTextDropDown(GetUPBDropDownValues, New ControlLocation(2, 1, 3), EControlUse.Dim)

Private Function GetUPBDropDownValues() As SortedDictionary(Of String, Double) Dim sd As SortedDictionary(Of String, Double) = New SortedDictionary(Of String, Double)

    sd.Add("Dim", CDbl(HAI_Shared.enuUnitCommand.Dim))
    sd.Add("Dim 10%", CDbl(HAI_Shared.enuUnitCommand.Dim1))
    sd.Add("Dim 20%", CDbl(HAI_Shared.enuUnitCommand.Dim2))
    sd.Add("Dim 30%", CDbl(HAI_Shared.enuUnitCommand.Dim3))
    sd.Add("Dim 40%", CDbl(HAI_Shared.enuUnitCommand.Dim4))
    sd.Add("Dim 50%", CDbl(HAI_Shared.enuUnitCommand.Dim5))
    sd.Add("Dim 60%", CDbl(HAI_Shared.enuUnitCommand.Dim6))
    sd.Add("Dim 70%", CDbl(HAI_Shared.enuUnitCommand.Dim7))
    sd.Add("Dim 80%", CDbl(HAI_Shared.enuUnitCommand.Dim8))
    sd.Add("Dim 90%", CDbl(HAI_Shared.enuUnitCommand.Dim9))

    sd.Add("Brighten", CDbl(HAI_Shared.enuUnitCommand.Bright))
    sd.Add("Bright 10%", CDbl(HAI_Shared.enuUnitCommand.Bright1))
    sd.Add("Bright 20%", CDbl(HAI_Shared.enuUnitCommand.Bright2))
    sd.Add("Bright 30%", CDbl(HAI_Shared.enuUnitCommand.Bright3))
    sd.Add("Bright 40%", CDbl(HAI_Shared.enuUnitCommand.Bright4))
    sd.Add("Bright 50%", CDbl(HAI_Shared.enuUnitCommand.Bright5))
    sd.Add("Bright 60%", CDbl(HAI_Shared.enuUnitCommand.Bright6))
    sd.Add("Bright 70%", CDbl(HAI_Shared.enuUnitCommand.Bright7))
    sd.Add("Bright 80%", CDbl(HAI_Shared.enuUnitCommand.Bright8))
    sd.Add("Bright 90%", CDbl(HAI_Shared.enuUnitCommand.Bright9))

    Return sd
End Function

The enums from Dim start at 16 and go through 25 The enums for Bright start at 32 and go through 41

The On/Off/Toggle are all being added to the dropdown for some reason, even though the values are not duplicated. Only the Off button is displayed along with the dropdown.

see attached screenshot3 for the result screenshot3 s

Sgt-Shultz commented 2 years ago

I'm not seeing anything that looks off. Have you tried putting the droplist on a second feature? It's all the same device, but that might make a change in it's behavior.

rmasonjr commented 2 years ago

It's definitely a problem with the AddTextDropDown code.

I commented out the last line and replaced it with an AddSlider and it looks fine. See attached screenshot4

Dim ff = FeatureFactory.CreateFeature(OMNI_NAME). WithName(u.unitName). WithLocation(OMNI_NAME & " Units"). WithLocation2(OMNI_NAME). WithMiscFlags(withFlags). WithoutMiscFlags(withoutFlags). WithExtraData(PED). AsType(EFeatureType.Generic, 0).WithDefaultValue(0). AddButton(0, "Off", New ControlLocation(1, 1), EControlUse.Off). AddButton(255.0, "On", New ControlLocation(1, 2), EControlUse.On). AddButton(101.0, "Toggle", New ControlLocation(1, 3), EControlUse.OnAlternate). AddSlider(New ValueRange(10.0, 90.0), New ControlLocation(2, 1, 3), EControlUse.Dim) ''AddTextDropDown(GetUPBDropDownValues, New ControlLocation(2, 1, 3), EControlUse.Dim)

screenshot4

Sgt-Shultz commented 2 years ago

It's an issue somewhere in the page build for the drop list. Putting the drop list on a second feature of the device corrects the issue for both the drop list and the buttons. I'll put a ticket in for this so it can be looked at.

spudwebb commented 2 years ago

It's tracked as HS-1058 And it's a duplicate of #89, so I'm closing this issue