demirhanaydin / node-mi-flora

Node package for Xiaomi Mi Flora Plant Sensor
53 stars 21 forks source link

Fixing the odd value reading. #11

Closed bepitulaz closed 6 years ago

bepitulaz commented 6 years ago

This PR is based on issue #5. I'm also changing the default name of the device to Flower care. I think the newer device use this name.

This PR is tested with firmware version 3.1.8.

demirhanaydin commented 6 years ago

Thanks for the pr @bepitulaz. What I've read when I was writing the library in one of the forums is that the characteristic must be written true to make sure the flora sends realtime data. I've no idea how it behaves when you change that characteristic to false. Have you got a chance to test it? Does it send to updated values?

Also, changing the default name to 'Flower care' will break the old firmware device connection. @webnator developed a nice solution with making the initializer getting a config object. It will solve all those problems. Till the time pr will be merged, you can connect to your devices with the mac address like suggested here https://github.com/demirhanaydin/node-mi-flora/issues/5#issuecomment-280885780

bepitulaz commented 6 years ago

Yes, the flora still sends the real-time data. Here is the value:

true flag

data DeviceData {
  deviceId: 'c47c8d617678',
  temperature: 4804.2,
  lux: 2583686877,
  moisture: 39304,
  fertility: 26231 }
firmware { deviceId: 'c47c8d617678',
  batteryLevel: 100,
  firmwareVersion: '3.1.8' }
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
data DeviceData {
  deviceId: 'c47c8d617678',
  temperature: 4804.2,
  lux: 2583686877,
  moisture: 39304,
  fertility: 26231 }
firmware { deviceId: 'c47c8d617678',
  batteryLevel: 100,
  firmwareVersion: '3.1.8' }
Every 15 seconds, rescan devices

false flag:

data DeviceData {
  deviceId: 'c47c8d617678',
  temperature: 29.1,
  lux: 426,
  moisture: 52,
  fertility: 1230 }
firmware { deviceId: 'c47c8d617678',
  batteryLevel: 100,
  firmwareVersion: '3.1.8' }
Every 15 seconds, rescan devices
data DeviceData {
  deviceId: 'c47c8d617678',
  temperature: 29.1,
  lux: 424,
  moisture: 51,
  fertility: 1230 }
firmware { deviceId: 'c47c8d617678',
  batteryLevel: 100,
  firmwareVersion: '3.1.8' }
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
Every 15 seconds, rescan devices
data DeviceData {
  deviceId: 'c47c8d617678',
  temperature: 29.1,
  lux: 262,
  moisture: 51,
  fertility: 1230 }
firmware { deviceId: 'c47c8d617678',
  batteryLevel: 100,
  firmwareVersion: '3.1.8' }

The value when I use the false flag is the same as in the app.