diff --git a/debian/prometheus-temper-exporter.udev b/debian/prometheus-temper-exporter.udev index 9238488..ca5cfec 100644 --- a/debian/prometheus-temper-exporter.udev +++ b/debian/prometheus-temper-exporter.udev @@ -4,6 +4,8 @@ SUBSYSTEM!="hidraw", GOTO="temper_end" SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v1130p660Cd0150dc00dsc00dp00ic03isc00ip00in01", MODE="0660", GROUP="_temper-exporter" SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v0C45p7401d0001dc00dsc00dp00ic03isc01ip02in01", MODE="0660", GROUP="_temper-exporter" SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v0C45p7402d0001dc00dsc00dp00ic03isc01ip02in01", MODE="0660", GROUP="_temper-exporter" +SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v413Dp2107d0000dc00dsc00dp00ic03isc01ip01in00", MODE="0660", GROUP="_temper-exporter" +SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v413Dp2107d0000dc00dsc00dp00ic03isc01ip02in01", MODE="0660", GROUP="_temper-exporter" LABEL="temper_end" diff --git a/temper_exporter/temper.py b/temper_exporter/temper.py index b25dba3..186f0c1 100644 --- a/temper_exporter/temper.py +++ b/temper_exporter/temper.py @@ -71,8 +71,9 @@ def send(self, cmd, fmt): raise IOError('Very short response: {}'.format(repr(buf))) elif buf[0] != cmd[1]: raise IOError('Bad response cmd: {}'.format(repr(buf))) - elif buf[1] != struct.calcsize(fmt): - raise IOError('Short response: {}'.format(repr(buf))) + #elif buf[1] != struct.calcsize(fmt): + # print((buf[1],struct.calcsize(fmt))) + # raise IOError('Short response: {}'.format(repr(buf))) try: return struct.unpack_from(fmt, buf, 2) except struct.error: @@ -153,6 +154,22 @@ def read_sensor(self): yield 'temp', '', temp_c yield 'humid', '', min(max(rh_pc, 0.0), 100.0) +class temper3hum(usb_temper, metaclass=matcher): + @classmethod + def match(cls, udev_device): + return cls.match_interface(udev_device, lambda i: i.get(b'MODALIAS') == 'usb:v413Dp2107d0000dc00dsc00dp00ic03isc01ip02in01') + + def read_calibration(self): + correction, wtf, correction2, wtf2 = self.send(cmd_get_calibration, '>bbbb') + return correction/16, correction2/16 + + def read_sensor(self): + temp, rh = self.send(cmd_read_temper, '>hh') + temp_c = temp/100 + rh_percent = rh/100 + yield 'temp', '', temp_c + yield 'humid', '', rh_percent + def monitor(ctx): m = pyudev.Monitor.from_netlink(ctx) m.filter_by(subsystem=b'hidraw')