Example #1
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "angle")
     self.add_property(
         Property(name="angle",
                  type=PropertyType.INT,
                  value=0,
                  unit="°",
                  range=[0, 100]))
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "temperature")
     self.add_property(
         Property(name="temperature",
                  type=PropertyType.INT,
                  value=0,
                  unit="°C",
                  range=[0, 100]))
     self.add_property(
         Property(name="humidity",
                  type=PropertyType.INT,
                  value=0,
                  unit="%",
                  range=[0, 100]))
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin)
     self.add_action(Action("turn_on"))
     self.add_action(Action("turn_off"))
     self.add_action(
         Action("flash").add_parameter(
             Property(name="duration",
                      type=PropertyType.INT,
                      value=10,
                      range=[10, 100])).add_parameter(
                          Property(name="interval",
                                   type=PropertyType.INT,
                                   value=1,
                                   range=[1, 10])))
     self.working_thread = None
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "sound")
     self.add_property(
         Property(name="volume", type=PropertyType.INT, value=0, unit="dB"))
 def turn_off(self):
     Sensor.digital_write(self, Relay.OFF)
 def turn_on(self):
     Sensor.digital_write(self, Relay.ON)
 def update_state(self):
     data = Sensor.analog_read(self, "dht")
     if data is not None:
         self.update_property(temperature=data[0], humidity=data[1])
 def turn_on(self):
     Sensor.digital_write(self, Led.ON)
Example #9
0
 def turn_off(self):
     Sensor.digital_write(self, Buzzer.OFF)
Example #10
0
 def turn_on(self):
     Sensor.digital_write(self, Buzzer.ON)
 def update_state(self):
     data = Sensor.analog_read(self, "ultrasonic")
     if data is not None:
         self.update_property(distance=data)
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "distance")
     self.add_property(
         Property(name="distance", type=PropertyType.INT, unit="cm"))
 def update_state(self):
     data = Sensor.digital_read(self)
     if data is not None:
         self.update_property(pressed=(data > 0))
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "button")
     self.add_property(Property("pressed", PropertyType.BOOL))
Example #15
0
 def turn_off(self):
     Sensor.digital_write(self, Led.OFF)
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None and data is not 0:
         resistance = (1023 - data) * 10000.0 / data
         value = 1 / (math.log(resistance / 10000) / 4250 + 1 / 298.15) - 273.15 + 100
         self.update_property(temperature=value)
Example #17
0
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None:
         self.update_property(angle=data)
Example #18
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "lcd")
     self.add_action(Action("display", message=PropertyType.STRING))