DheerajKhajuria / pimatic-mysensors

mysensors
http://forum.mysensors.org/topic/797/pimatic-mysensors-controller-plugin
GNU General Public License v2.0
23 stars 24 forks source link

Extention for Pulse Watermeter #69

Closed mrdago closed 8 years ago

mrdago commented 8 years ago

Hi,

I've added a variable 'consumtion' to the Watermeter to measure the volume of the last water consumtion event. If the water flow returns to zero I calculate the last consumtion volume and send this value (V_VAR2) to the gateway. I guess that this measure is interesting for most of the people as this allow measuring water consumtion of every single withdrawal.

To have this function available after any update of the mysensors plugin I ask to implement this extension into the standard release.

class MySensorsWaterMeter extends env.devices.Device

constructor: (@config,lastState, @board) ->
  @id = config.id
  @name = config.name

...
  @_consumtion = lastState?.consumtion?.value
...

  env.logger.debug "MySensorsWaterMeter " , @id , @name
...
  @attributes.consumtion = {
    description: "Measure of last consumtion"
    type: "number"
    unit: ' l'
    acronym: 'last consumtion'
  }
...
        if result.type is V_VAR2
          env.logger.debug "<- MySensorsWaterMeter V_VAR2"
          @_consumtion = parseInt(result.value)
          @emit "consumtion", @_consumtion
...
getConsumtion: -> Promise.resolve @_consumtion

Here is the calculation of the last water consumtion in my Arduino sketch

   ...
   if(currentTime - lastPulse > 120000){
      flow = 0;    

      lastwc = (pulseCount - oldwc) / (unsigned long)ppl;  
      oldwc = pulseCount;     
      if(lastwc != 0){
        Serial.print("current Waterconsumtion:");
        Serial.println(lastwc);     
        gw.send(lastConsumtionMsg.setSensor(CHILD_ID).set(lastwc));      // Send consumtion value to gw
      }    
    } 
    ...
sweebee commented 8 years ago

Hm, don't know what to do with this. Its very nice, but the default water meter sketch doesn't have this.

But we could add it and set it by default hidden. Don't know how @DheerajKhajuria thinks about it.

So what this is doing is showing the consumed water (liter?) since you opened the tap?

mrdago commented 8 years ago

Yes, this enhancement provide the water consumtion between opening and closing a tap (consumtion for a shower, a flush, etc.) and allows you to control and change your behaviour in regard to your individual water consumtion.

Maybe it can be implemented similar as the measuring of the battery level, so that people can use it as an optional measurement.