Announcement

Collapse
No announcement yet.

Handling Deleted Devices

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

  • Handling Deleted Devices

    Hi plugin dev's.

    How are you handling a user deleting one of your devices from the device-list web interface? I know I can catch HSEvent and see that a device has been deleted and get its device ref, but how then do I know if it's one of mine? A call to hs.GetDeviceByRef(ref) returns nothing as the device has already been deleted.

    Are you maintaining a list of all your plugin's devices in a collection in your plugin and then referencing the deleted device against that?
    Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

  • #2
    Originally posted by beerygaz View Post
    Hi plugin dev's.

    How are you handling a user deleting one of your devices from the device-list web interface? I know I can catch HSEvent and see that a device has been deleted and get its device ref, but how then do I know if it's one of mine? A call to hs.GetDeviceByRef(ref) returns nothing as the device has already been deleted.

    Are you maintaining a list of all your plugin's devices in a collection in your plugin and then referencing the deleted device against that?
    Since I have to have a SQLite db for the config and log, I just save the Device Ref for all of the defined Zones in the security panel. If I match it up with the DevRef in HSevent, I just recreate it. That's probably overkill if you don't already have a db configured.

    Z

    Comment


    • #3
      As you mentioned in your post, I maintain a collection of all my plug-in's devices and use it for reference.

      Paul..

      Comment


      • #4
        I typically check all devices at startup, so if the plugin detects a device missing it will recreate it. I only do this for child devices, since I assume if a root (and its children) is deleted it probably was for a reason.
        HS Pro 3.0 | Linux Ubuntu 16.04 x64 virtualized under Proxmox (KVM)
        Hardware: Z-NET - W800 Serial - Digi PortServer TS/8 and TS/16 serial to Ethernet - Insteon PLM - RFXCOM - X10 Wireless
        Plugins: HSTouch iOS and Android, RFXCOM, BlueIris, BLLock, BLDSC, BLRF, Insteon PLM (MNSandler), Device History, Ecobee, BLRing, Kodi, UltraWeatherWU3
        Second home: Zee S2 with Z-Wave, CT101 Z-Wave Thermostat, Aeotec Z-Wave microswitches, HSM200 occupancy sensor, Ecolink Z-Wave door sensors, STI Driveway Monitor interfaced to Zee S2 GPIO pins.

        Comment


        • #5
          I check during startup and re-create them if missing.
          HS3Pro Running on a Raspberry Pi3
          64 Z-Wave Nodes, 168 Events, 280 Devices
          UPB modules via OMNI plugin/panel
          Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
          HSTouch Clients: 3 Android, 1 Joggler

          Comment


          • #6
            The startup check is one thing. But my plugin polls different external sources and then updates a device based on that. If the user removes the device from HS3 I need to stop polling and trying to update a non-existent device. Do I need to keep a list and check it every time the user deletes ANY device in case it's one of mine.


            Sent from my iPhone using Tapatalk
            Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

            Comment


            • #7
              Originally posted by beerygaz View Post
              The startup check is one thing. But my plugin polls different external sources and then updates a device based on that. If the user removes the device from HS3 I need to stop polling and trying to update a non-existent device. Do I need to keep a list and check it every time the user deletes ANY device in case it's one of mine.


              Sent from my iPhone using Tapatalk
              One of my plug-in's also polls external sources so at start-up I create a collection of these devices and it is this list that I iterate when doing the polling. In my device update routine I use hs.DeviceExistsRef function and if the device doesn't exist I throw a message into the log then remove it from the polling list.

              If a user adds, removes or otherwise alters a device that belongs to my plug-in, I re-run the list creation routine.

              Paul..

              Comment


              • #8
                Thanks Paul. That's what I'm doing now too. I hadn't spotted hs.DeviceExistsRef before though, thanks for that one.


                Sent from my iPhone using Tapatalk
                Author of Highpeak Plugins | SMS-Gateway Plugin | Blue Iris Plugin | Paradox (Beta) Plugin | Modbus Plugin | Yamaha Plugin

                Comment

                Working...
                X