Announcement

Collapse
No announcement yet.

Having Issues with EProperty.Misc, EMiscFlag.NoLog

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

    Having Issues with EProperty.Misc, EMiscFlag.NoLog

    I'm having issues setting the NoLog property.....error says something about key being used already. it fails when I try to add ShowValues

    Any ideas?

    Code:
    // update device with reference data
    
                    Dictionary<EProperty, object> additionalData = new Dictionary<EProperty, object>();
    
                    additionalData.Add(EProperty.Interface, Utils.Id); //Don't change this, or the device won't be associated with your plugin
    
                    _hs.UpdateDeviceByRef(dvRef, additionalData);
    
    
    
                    additionalData = new Dictionary<EProperty, object>();
    
                    additionalData.Add(EProperty.Misc, EMiscFlag.NoLog); //As default, we don't want to log every device value change to the log
    
    
                    additionalData.Add(EProperty.Misc, EMiscFlag.ShowValues); //If not set, device control options will not be displayed
    
    
    
    
                    _hs.UpdateDeviceByRef(dvRef, additionalData);

    HS3 Pro Edition 3.0.0.435 (Windows 10 vmware)
    BLOccupied:,UltraNetCam3:,weatherXML:,RFXCOM:,Current Cost 3P:,UltraGCIR3:
    DMMQTT:,Kodi:,Z-Wave:,BLRadar:,EasyTrigger:,MySensors:,BLBackup:

    #2
    But this works.....making progress, wish I knew why one works and the other doesn't......

    Code:
            public int CreateBasicDevice(string name, string location, string location2)
    
            {
                Logger.LogTrace("CreateBasicDevice()");
    
                int dvRef = 0;
    
    
                try
    
                {
                    // EMiscFlag.NoLog : As default, we don't want to log every device value change to the log
    
                    // EMiscFlag.ShowValues : If not set, device control options will not be displayed
    
                    EMiscFlag[] hsFlags = new EMiscFlag[] { EMiscFlag.NoLog, EMiscFlag.ShowValues, EMiscFlag.SetDoesNotChangeLastChange};
    
    
                    // Create device object
    
                    DeviceFactory df = DeviceFactory.CreateDevice(Utils.Id);
    
                    df.WithName(name);
    
                    df.WithLocation(location);
    
                    df.WithLocation2(location2);
    
                    df.AsType(EDeviceType.Generic, 0);
    
                    df.WithMiscFlags(hsFlags);
    
    
                    // create new device in hs
    
                    NewDeviceData ndd = df.PrepareForHs();
    
                    dvRef = _hs.CreateDevice(ndd);
    
    
                    // update device with reference data
    
                    Dictionary<EProperty, object> additionalData = new Dictionary<EProperty, object>();
    
                    additionalData.Add(EProperty.Interface, Utils.Id); //Don't change this, or the device won't be associated with your plugin
    
                    _hs.UpdateDeviceByRef(dvRef, additionalData);
    
                }
    
                catch (Exception ex)
    
                {
                    Logger.LogError("Unable to create basic device. Error: " + ex.Message);
                }
    
    
                return dvRef;
    
            }
    HS3 Pro Edition 3.0.0.435 (Windows 10 vmware)
    BLOccupied:,UltraNetCam3:,weatherXML:,RFXCOM:,Current Cost 3P:,UltraGCIR3:
    DMMQTT:,Kodi:,Z-Wave:,BLRadar:,EasyTrigger:,MySensors:,BLBackup:

    Comment


      #3
      Originally posted by dmurphy View Post

      Code:
      _hs.UpdateDeviceByRef(dvRef, additionalData);
      I still wonder why HST didn't do it standard OO way - when they redesigned the API?
      I.e.
      Code:
      device.Update(additionalData)

      Comment

      Working...
      X