Announcement

Collapse
No announcement yet.

Adding Category to a device

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding Category to a device

    I'm using the following code to add an existing category to a device using its reference ID:

    Code:
    Sub Main(Parm As Object)
        Dim Ref As Integer = 1234
        hs4.AddRefToCategory("Fans",Ref)
    End sub
    When run, no errors but the 'Fan' is not added to the device category list when you inspect its device settings?

    Is this a bug or am I doing this wrong?
    Jon


    #2
    Does category exist? You need CreateCategory() first.

    Click image for larger version

Name:	Screenshot 2022-07-28 232927.png
Views:	96
Size:	52.9 KB
ID:	1559518

    Comment


      #3
      Originally posted by alexbk66 View Post
      Does category exist? You need CreateCategory() first.
      As stated this is an existing category (default categories provided by HomeSeer)

      Click image for larger version

Name:	Capture.png
Views:	102
Size:	21.5 KB
ID:	1559525
      Jon

      Comment


        #4
        And BTW, there was a bug that you can add the same ref to the list, hence refs.Contains(RefId) check.

        Comment


          #5
          I believe that the first argument is not the name/alias of the category but the CategoryID of the Category.
          tenholde

          Comment


            #6
            Ahh...yes. Misread the docs. I can get the GUID using hs4.GetAllCategories() and extracting the Key.

            Thanks for the pointer!
            Jon

            Comment


              #7
              Yeah,

              Click image for larger version

Name:	Screenshot 2022-08-03 003336.png
Views:	47
Size:	29.5 KB
ID:	1560309

              Comment

              Working...
              X