NOB just starting to write an adapter

I have written my first adapter and it install properly. However, I think I am confused by some semantics. I have a sensor which is exposed as a device. That device has a property ‘tripped’ that should be true when motion is expected. When a created the device I set the property to be read-only. However, when I detect motion I am using the SetProperty method on the device to change the property - and error is thrown in the log:
2019-08-29 21:31:45.264 INFO : dsc: Unhandled Rejection
2019-08-29 21:31:45.266 ERROR : dsc: Read-only property
Which makes sense. My question is shouldn’t the property of a sensor be readOnly and how do I modify the value of the property to reflect the actual sensor. I don’t think code will help much but here are two snippets.

  1. this is where I set up the property
    –> in device class
    this.properties.set(‘tripped’, new Property(this, ‘tripped’, {type: ‘boolean’, readOnly: true} ))

  2. this is where I try to reflect the new status ( I am reading form a serial port that is connected to the actual device)
    —> in adapter sub-class

    this.serialPort.pipe(new Readline()).on(‘data’, data => {
    console.log(‘from it100:’, data)

     const
         cmd = zoneCommands.get(data.slice(0,3)),
         zone = zones.get(data.slice(3,6))
     if( cmd  && zone ) {
         console.log(`setting prop ${cmd.prop} to ${cmd.value}`)
         **zone.setProperty(cmd.prop, cmd.value) <--- this is the problem**
     } else {
         console.log('unknown command skipping ', data.slice(0,3))
     }
    

    })

What you’ll want to use is setCachedValue(). Example: https://github.com/mozilla-iot/weather-adapter/blob/master/lib/weather-device.js#L224-L225

There’s also a setCachedValueAndNotify() method, which will handle both of the method calls from that example.

Here’s the code and documentation for both: https://github.com/mozilla-iot/gateway-addon-node/blob/master/lib/property.js#L102-L136