cybermaggedon / pyvera

Python Vera interaction
GNU General Public License v3.0
3 stars 4 forks source link

Feature Request - MultiSensor - Light #3

Closed ilikedatapoints closed 6 years ago

ilikedatapoints commented 6 years ago

I have a multisensor from Monoprice that also has a sensor for measuring light in addition to humidity; temperature and motion. I'm able to poll temperature, humidity and even remaining battery but I'm not seeing a method for retrieving light levels (Lux?).

Would it be possible to request this to be added?

{'device_file': u'D_LightSensor1.xml', 'name': u'PIR MS One Light', 'room': <vera.Room object at 0x7f3bf3b31e90>, 'vera': <vera.VeraLocal object at 0x7f3bf3e3fb10>, 'invisible': False, 'device_json': u'D_LightSensor1.json', 'device_type': u'urn:schemas-micasaverde-com:device:LightSensor:1', 'services': set([u'urn:micasaverde-com:serviceId:LightSensor1', u'urn:micasaverde-com:serviceId:ZWaveDevice1']), 'model': u'', 'id': 538, 'manufacturer': u''}

Is there any information that I can provide to help get this added?

Thanks!

ilikedatapoints commented 6 years ago

Would this be acceptable?

def get_lux(self):
        """
        Get the current value of a light sensor device.  Returns a
        integer value representing % of lighting.
        """

        svc = "urn:micasaverde-com:serviceId:LightSensor1"
        if not svc in self.services:
            raise RuntimeError, "Device doesn't support the service"

        return self.get_variable(svc, "CurrentLevel")

I added that to vera.py and it seems to work:

In [2]: import vera
In [3]: ve = vera.VeraLocal("192.168.1.24")
In [4]: ve =vera.connect()
In [5]: dev2 = ve.get_device('PIR MS One Light')
In [6]: print dev2.get_lux()
17.59
In [7]: 

How bad did I screw up ? :)

ilikedatapoints commented 6 years ago

Created a pull request if that helps?

cybermaggedon commented 6 years ago

Looks perfect! Thanks for doing all the work 😄