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

Can not add range options for status graphics #113

Closed Enigmatheatre closed 4 years ago

Enigmatheatre commented 4 years ago

Environment and System Config

Describe the issue you are encountering I can not find a way to set a features Range option for status/graphics. In HS3 it was applied to the status/value but in HS4 from what I can see I need to set the status/graphics. I want to apply the Prefix and decimal value when creating a device but can not find a way that works. I have tried the following but it creates the range and adds the graphic but no options.

    Dim VR As ValueRange = New ValueRange(-45, 15)
    VR.Suffix = "°C"
    VR.DecimalPlaces = 1

    Dim SG As StatusGraphic = New StatusGraphic("/images/HomeSeer/status/Thermometer-00.png", VR)

    hs.AddStatusGraphicToFeature(509, SG)

Expected behaviour I would expect it to add to the device and change the status so it displays in the device manager.


spudwebb commented 4 years ago

your code looks ok, do you mean suffix and decimalPlaces are not honored in the devices page?

I use this in a lot of plugins and it seems to work for me

Enigmatheatre commented 4 years ago

Well, I would say they are not set and not just honoured as if you open the status/graphics and click the option to edit them they are blank there too. You also can not set and save them on that page either as they just blank when you go back to them.

statusgraphic

I have had a quick look at the Tuya plugin but you are setting them on the status/controls in that, not the status/graphics. I only want to display a string and image and not have any controls on the device. How do I set the status/graphic options?

spudwebb commented 4 years ago

you're right about the edit popup that shows blank values. I will log this problem internally as a HS Core problem.

however the suffix and decimal options set by my plugins work as expected see for example this feature (which does not have any control, just a StatusGraphic)

image

the code I use to create it is:

                StatusGraphic statusGraphic;

                ValueRange range = new ValueRange(0, double.MaxValue);
                range.DecimalPlaces = 1;
                range.Suffix = " hours";

                statusGraphic = new StatusGraphic(ImagesStatusDir + "timers.png", range);
                _hs.AddStatusGraphicToFeature(featRef, statusGraphic);
Enigmatheatre commented 4 years ago

OK, I got this to work but not 100% sure how. I removed the device and added it again and it now shows fine. I must have set something else that was causing the problem during my testing. I think if we could get the UI fixed to be able to add the status/graphics this would help a lot of people as I think there is a lot of confusion over this moving from needing status/value set to status/graphics set to make the device status only and if you make a virtual device it is not possible to make its status only as it is created as a V3.2 device. (Rich is aware of this but not sure he sees the problem that users are experiencing) Thank you for your help.