This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.
Closed

Finding out when a users deletes a device

Hi developers,

I'm trying to find an event I can subscribe to from my driver that let's me know if a user deletes a device (from the Zones & Devices page). Anyone had any luck with doing that?

Comments

  • read the library. 


    module.exports.deleted = function( device_data ) { // run when the user has deleted the device from Homey }
  • MikeOneMikeOne Member
    I guess I mis-worded my question and failed to explain what I already tried (and doesn't work).

    module.exports.deleted (doesn't do anything)
    module.exports.delete (in case the above was a typo..)

    socket.on('delete')
    socket.on('delete_device')
    socket.on('delete_devices');
    socket.on('deleted')
    socket.on('device_delete')
    socket.on('devices_delete')
    socket.on('devices_deleted')
    socket.on('device_deleted')

    (and I'm probably missing a few)..

    And many more things (hooking into the driver events directly etc). 

    So before I raise an Issue in Github, I'm trying to find out if anyone as ever gotten the documented methods to work. 


     
  • RamonBaasRamonBaas Member
    edited May 2016
  • be sure you put it in your driver.js!
    Its just like documented:
    ```
      deleted: function (device, callback) {
        Homey.log('delete device', device)
        callback()
      },
    ```
  • MikeOneMikeOne Member
    It is what I thought, it should be simple.

    In my driver.js I now put the simplest of examples:

    module.exports.deleted = function(device, callback){
        Homey.log("deleted device", device);
        callback();
    }

    NOTHING logged in the output. I don't get it..

    What version are you guys on? I'm on 0.8.29.. 



  • MikeOneMikeOne Member
    Right... I see now what the issue is - not exactly transparant :-)

    I didn't have the callback() in init()... Once I put it there, the deleted started working.... Right..

    Thanks guys!
  • ErikVanDongen said:
    be sure you put it in your driver.js!
    Its just like documented:
    ```
      deleted: function (device, callback) {
        Homey.log('delete device', device)
        callback()
      },
    ```
    According to the documentatiom deleted doesn't have a callback: https://developers.athom.com/library/drivers/
  • RamonBaas said:
    ErikVanDongen said:
    be sure you put it in your driver.js!
    Its just like documented:
    ```
      deleted: function (device, callback) {
        Homey.log('delete device', device)
        callback()
      },
    ```
    According to the documentatiom deleted doesn't have a callback: https://developers.athom.com/library/drivers/
    Thanx!
This discussion has been closed.