Add support for mPort input sensors

The mPort device has input pins that can be configured as digital or
analog inputs. We should support those as sensors.
This commit is contained in:
Dan Smith 2016-02-07 20:26:25 +00:00
parent 951fa603ff
commit 8f690ff077

View File

@ -18,10 +18,14 @@ REQUIREMENTS = ['mficlient==0.2.2']
_LOGGER = logging.getLogger(__name__)
STATE_ON = 'on'
STATE_OFF = 'off'
SENSOR_MODELS = [
'Ubiquiti mFi-THS',
'Ubiquiti mFi-CS',
'Outlet',
'Input Analog',
'Input Digital',
]
@ -69,7 +73,10 @@ class MfiSensor(Entity):
@property
def state(self):
return self._port.value
if self._port.model == 'Input Digital':
return self._port.value > 0 and STATE_ON or STATE_OFF
else:
return self._port.value
@property
def unit_of_measurement(self):
@ -77,6 +84,8 @@ class MfiSensor(Entity):
return TEMP_CELCIUS
elif self._port.tag == 'active_pwr':
return 'Watts'
elif self._port.model == 'Input Digital':
return 'State'
return self._port.tag
def update(self):