[ANSWERED]: Script to Poll/Status of MimoLite Analog Sensor

Posted on
Thu Mar 24, 2016 7:06 pm
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

[ANSWERED]: Script to Poll/Status of MimoLite Analog Sensor

I have propane gauge that returns 0-5V related to tank storage amount.
I turn on power to the gauge and read the analog value using MimoLite.
My test work fine but I really only need to turn it on and read it at most once/day.

How can my script send a status request to read? If I read the indigo.devices[1681189956].sensorValue, it's stale until a status request.

Seems simple since there's a "button" but I don't see a method in dir(indigo.devices[1681189956]):

['allowOnStateChange', 'allowSensorValueChange', 'batteryLevel', 'buttonGroupCount', 'configured', 'description', 'deviceTypeId', 'displayStateId', 'displayStateImageSel', 'displayStateValRaw', 'displayStateValUi', 'enabled', 'energyAccumBaseTime', 'energyAccumTimeDelta', 'energyAccumTotal', 'energyCurLevel', 'errorState', 'folderId', 'globalProps', 'id', 'lastChanged', 'model', 'name', 'onState', 'ownerProps', 'pluginId', 'pluginProps', 'protocol', 'refreshFromServer', 'remoteDisplay', 'replaceOnServer', 'replacePluginPropsOnServer', 'sensorValue', 'setErrorStateOnServer', 'stateListOrDisplayStateIdChanged', 'states', 'subModel', 'supportsAllLightsOnOff', 'supportsAllOff', 'supportsStatusRequest', 'updateStateImageOnServer', 'updateStateOnServer', 'updateTimeStampOnServer', 'version']

Posted on
Fri Mar 25, 2016 6:30 am
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

Re: Script to Poll/Status of MimoLite Analog Sensor Value

Sorry, my mistake for not using this lately.
indigo.device.statusRequest(728249787) is what I want

Posted on
Fri Mar 25, 2016 6:45 am
stevemac00 offline
Posts: 79
Joined: Sep 02, 2013

Re: Script to Poll/Status of MimoLite Analog Sensor Value

In case anyone is interested...

The propane sensor module is a hall effect gauge when supplied with 5V(+/-0.5V) power will return 0-5 to indicate tank level. It's made to momentary press a switch to provide power for the sensor reading. So, I'm using the MimoLite power supply with a simple voltage divider to get 5VDC into the MimoLite relay. The script turns on the power, waits a couple seconds to settle before reading the value with a status request and turning off the relay.

I determine the list of values with an adjustable buck converter then read the MimoLite value. The sensor told me what voltage it should be in 10% increments. I fudge a little to estimate the remainder (between each 10% step).

Code: Select all
import time
indigo.device.turnOn(728249787) # relay turn on voltage to the sensor module
time.sleep(2)
indigo.device.statusRequest(1681189956)
val = int(round(indigo.devices[1681189956].sensorValue / 10.0))
indigo.device.turnOff(728249787)

list = [155,177,215,236,257,268,275,282,288]


if val < list[0]:
   indigo.server.log(u'Propanel Level Sensor Value Low! [%d] - Sending Alert!' % (val), isError=True)
   return
elif val > list[-1]:
   indigo.server.log(u'Propanel Level Sensor Value out of Range [%d]' % (val), isError=True)
   return

for x in range(0,len(list),1):
   pct = 20 + 10 * x # starting at 20% in 10% increments
   if list[x] > val:
      diff = list[x] - val
      if diff < 0: diff = 0
      add = int(float(diff) / (list[x] - list[x-1]) * 10.0)
      if add < 10: pct = pct + add
      break

indigo.server.log("sensorValue=%d, propane percent = %d%%" % (indigo.devices[1681189956].sensorValue, pct))

Posted on
Mon Mar 28, 2016 5:23 pm
matt (support) offline
Site Admin
User avatar
Posts: 21417
Joined: Jan 27, 2003
Location: Texas

Re: Script to Poll/Status of MimoLite Analog Sensor Value

Sorry for the slow reply on this one, and thanks for posting the script that you created.

Image

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 6 guests

cron