Example #1
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "temperature")
     self.add_property(
         Property(name="temperature", unit="°C", range=[0, 100]))
     self.add_property(Property(name="humidity", unit="%", range=[0, 100]))
     self.temperature = 0
     self.humidity = 0
Example #2
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "led")
     self.add_action(Action("turn_on"))
     self.add_action(Action("turn_off"))
     self.add_action(Action("blink").
                     add_parameter(Property(name="duration", value=10, range=[10, 100])).
                     add_parameter(Property(name="interval", value=1, range=[1, 10])))
     self.working_thread = None
Example #3
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "sound")
     self.add_property(Property(name="volume", unit="dB"))
     self.volume = 0
Example #4
0
 def turn_off(self):
     Sensor.digital_write(self, Led.OFF)
Example #5
0
 def turn_on(self):
     Sensor.digital_write(self, Led.ON)
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "angle")
     self.add_property(Property(name="angle", unit="°", range=[0, 100]))
     self.angle = 0
 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
         self.value = 1 / (math.log(resistance / 10000) / 4250 +
                           1 / 298.15) - 273.15 + 100
Example #8
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "distance")
     self.add_property(Property(name="distance", unit="cm"))
     self.distance = 0
 def turn_off(self):
     Sensor.digital_write(self, Relay.OFF)
 def turn_on(self):
     Sensor.digital_write(self, Relay.ON)
Example #11
0
 def turn_off(self):
     Sensor.digital_write(self, Buzzer.OFF)
Example #12
0
 def turn_on(self):
     Sensor.digital_write(self, Buzzer.ON)
Example #13
0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "lcd")
     self.add_action(Action("display", message=PropertyTypeString))
Example #14
0
 def update_state(self):
     data = Sensor.analog_read(self, "dht")
     if data is not None:
         self.temperature = data[0]
         self.humidity = data[1]
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "light")
     self.add_property(Property(name="value", unit="Nit"))
     self.value = 0
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "button")
     self.add_property(Property("pressed", PropertyTypeBool))
     self.pressed = False
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None:
         self.value = data
 def update_state(self):
     data = Sensor.analog_read(self)
     if data is not None:
         self.pressed = data > 0
Example #19
0
 def update_state(self):
     data = Sensor.analog_read(self, "ultrasonic")
     if data is not None:
         self.distance = data
 def __init__(self, tid, name, pin):
     Sensor.__init__(self, tid, name, pin, "temperature")
     self.add_property(Property(name="value", unit="°C", range=[0, 100]))
     self.value = 0