Example #1
0
    def __init__(self, address):
        Thing.__init__(
            self,
            'urn:dev:ops:temperature-sensor',
            'Temperature Sensor',
            ['TemperatureSensor'],
        )

        self.sensor = DS18B20(address)

        self.temperature = Value(self.read_celsius())
        self.add_property(
            Property(self,
                     'temperature',
                     self.temperature,
                     metadata={
                         '@type': 'TemperatureProperty',
                         'title': 'Temperature',
                         'type': 'number',
                         'description': 'The current temperature in °C',
                         'minimum': -50,
                         'maximum': 70,
                         'unit': '°C',
                         'readOnly': True,
                     }))

        logging.debug('starting the sensor update looping task')
        self.timer = tornado.ioloop.PeriodicCallback(self.update, 3000)
        self.timer.start()
Example #2
0
    def __init__(self, gpio: int, urn: str, title: str, description: str):
        Thing.__init__(
            self,
            urn,
            title,
            ['OnOffSwitch', 'Light'],
            description
        )

        self.add_property(
            Property(self,
                     'on',
                     Value(False, lambda v:
                         self.toggle_level(gpio,v)
                         ),
                     metadata={
                         '@type': 'OnOffProperty',
                         'title': 'On/Off',
                         'type': 'boolean',
                         'description': 'Sprinkler state',
                     }))

        self.add_property(
            Property(self,
                     'brightness',
                     Value(120, lambda v: logging.info('Timeout is now %d min. %d sec.',  v / 60 , v % 60)),
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Durée',
                         'type': 'integer',
                         'description': 'Time of sprinkle from 60 to 300 seconds',
                         'minimum': 60,
                         'maximum': 300,
                         'unit': 'second',
                     }))
    def __init__(self):
        Thing.__init__(self, 'My Humidity Sensor', 'multiLevelSensor',
                       'A web connected humidity sensor')

        self.add_property(
            Property(self,
                     'on',
                     Value(True),
                     metadata={
                         'type': 'boolean',
                         'description': 'Whether the sensor is on',
                     }))

        self.level = Value(0.0)
        self.add_property(
            Property(self,
                     'level',
                     self.level,
                     metadata={
                         'type': 'number',
                         'description': 'The current humidity in %',
                         'unit': '%',
                     }))

        logging.debug('starting the sensor update looping task')
        self.sensor_update_task = \
            get_event_loop().create_task(self.update_level())
 def __init__(self, id, description, data_to_measure, measures_tick):
     # Create the device
     Thing.__init__(self, 'urn:dev:ops:' + id, description,
                    ['MultiLevelSensor'], 'A web connected sensor')
     # create a variable that will be update in each measure
     self.level = Value(0.0)
     # add level property to the thing
     self.add_property(
         Property(self,
                  'level',
                  self.level,
                  metadata={
                      '@type': 'LevelProperty',
                      'title': data_to_measure,
                      'type': 'number',
                      'description':
                      'The current ' + data_to_measure + ' in %',
                      'minimum': 0,
                      'maximum': 100,
                      'unit': 'percent',
                      'readOnly': True,
                  }))
     # create a timer that will call update_level periodically
     logging.debug('starting the sensor update looping task')
     self.timer = tornado.ioloop.PeriodicCallback(self.update_level,
                                                  measures_tick)
     self.timer.start()
Example #5
0
    def __init__(self, uri_id, title, description, value_receiver):
        Thing.__init__(self, uri_id, title, ["Light"], description)

        self.add_property(
            Property(thing=self,
                     name="switch",
                     value=Value(
                         False,
                         create_value_forwarder(value_receiver, lambda x: "on" if x else "off")
                     ),
                     metadata={
                         "title": "Switch",
                         "description": "Light on/off switch",
                         "@type": "OnOffProperty",
                         "type": "boolean",
                         "readOnly": False
                     }))
        self.add_property(
            Property(thing=self,
                     name="color",
                     value=Value(
                         "#ffffff",
                         # TODO use hex value directly as arduino input?
                         create_value_forwarder(value_receiver, lambda x: int(x[1:], 16))  # convert #0000ff to 255
                     ),
                     metadata={
                         "title": "Color",
                         "description": "Light rgb color",
                         "@type": "ColorProperty",
                         "type": "string",
                         "readOnly": False
                     }))
    def __init__(self, name):
        self.name = name
        Thing.__init__(self, 'urn:dev:ops:'+name, name, ['OnOffSwitch', 'Light'], 'A virtual Unity light')
        self.add_property(
            Property(self,
                     'on',
                     Value(True, lambda v: print('On-State is now', v)),
                     metadata={
                         '@type': 'OnOffProperty',
                         'title': 'On/Off',
                         'type': 'boolean',
                         'description': 'Whether the lamp is turned on',
                     }))

        self.add_property(
            Property(self,
                     'brightness',
                     Value(50, lambda v: print('Brightness is now', v)),
                     metadata={
                         '@type': 'BrightnessProperty',
                         'title': 'Brightness',
                         'type': 'integer',
                         'description': 'The level of light from 0-100',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                     }))
Example #7
0
    def __init__(self, gpio_number, name, description):
        Thing.__init__(self, 'urn:dev:ops:illuminanceSensor-1',
                       'Illuminance ' + name + ' Sensor', ['MultiLevelSensor'],
                       description)

        self.bright = Value(0)
        self.add_property(
            Property(self,
                     'brightness',
                     self.bright,
                     metadata={
                         '@type': 'BrightnessProperty',
                         'title': 'Brightness',
                         "type": "integer",
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                         'description': '"The level of light from 0-100',
                         'readOnly': True,
                     }))

        self.ioloop = tornado.ioloop.IOLoop.current()
        logging.info('bind to gpio ' + str(gpio_number))
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(gpio_number, GPIO.IN)
        GPIO.add_event_detect(gpio_number,
                              GPIO.BOTH,
                              callback=self.__update,
                              bouncetime=5)
        self.__update(gpio_number)
Example #8
0
    def __init__(self, poll_delay):
        Thing.__init__(
            self,
            "urn:dev:ops:tsl2561-lux-sensor",
            "TSL2561 Lux Sensor",
            ["MultiLevelSensor"],
            "A web connected light/lux sensor",
        )

        self.level = Value(0.0)
        self.add_property(
            Property(
                self,
                "level",
                self.level,
                metadata={
                    "@type": "LevelProperty",
                    "title": "Lux",
                    "type": "number",
                    "description": "The current light in lux",
                    "minimum": 0,
                    "maximum": 200,  # apparently 1000 is an Overcast day; typical TV studio lighting
                    "unit": "lux",
                    "readOnly": True,
                },
            )
        )

        logging.debug("starting the sensor update looping task")
        self.timer = tornado.ioloop.PeriodicCallback(self.update_level, poll_delay)
        self.timer.start()
Example #9
0
    def __init__(self, uri_id, title, description, value_receiver):
        Thing.__init__(self, uri_id, title, ["MultiLevelSwitch"], description)

        self.add_property(
            Property(thing=self,
                     name="switch",
                     value=Value(
                         False,
                         create_value_forwarder(value_receiver, lambda x: "on" if x else "off")
                     ),
                     metadata={
                         "title": "Switch",
                         "description": "Display on/off switch",
                         "@type": "OnOffProperty",
                         "type": "boolean",
                         "readOnly": False
                     }))
        self.add_property(
            Property(thing=self,
                     name="digit",
                     value=Value(
                         0,
                         create_value_forwarder(value_receiver)
                     ),
                     metadata={
                         "title": "Digit",
                         "description": "Display digit",
                         "@type": "LevelProperty",
                         "type": "integer",
                         "minimum": 0,
                         "maximum": 19,
                         "readOnly": False
                     }))
Example #10
0
    def __init__(self, tet):
        Thing.__init__(self, 'Tetrahedron', ['OnOffSwitch', 'Light'],
                       'A tetrahedron shaped LED art installation.')

        self.on = False
        self.tetrahedron = tet

        self.add_property(
            Property(self,
                     'on',
                     Value(self.on, self.set_on_off),
                     metadata={
                         '@type': 'OnOffProperty',
                         'title': 'On/Off',
                         'type': 'boolean',
                         'description': 'Whether the tetrahedron is turned on',
                     }))

        self.add_property(
            Property(self,
                     'brightness',
                     Value(50),
                     metadata={
                         '@type': 'BrightnessProperty',
                         'title': 'Brightness',
                         'type': 'integer',
                         'description': 'The level of tetrahedron from 0-100',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                     }))
Example #11
0
    def __init__(self, deviceid):
        self.deviceid = deviceid
        Thing.__init__(self, 'myhumidsensor:{}'.format(self.deviceid),
                       'My {} Humidity Sensor'.format(self.deviceid),
                       ['MultiLevelSensor'], 'A web connected Humid sensor')

        self.level = Value(0.0)
        self.add_property(
            Property(self,
                     'level',
                     self.level,
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Humidity',
                         'type': 'number',
                         'description': 'The current humidity in %',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                         'readOnly': True,
                     }))

        logging.debug('starting the sensor update looping task')
        self.timer = tornado.ioloop.PeriodicCallback(self.update_level, 60000)
        self.timer.start()
    def __init__(self,
                 mqtt_name: str = "mqtt_abstract",
                 uri: str = "urn:dev:siis:abstract",
                 title: str = "Abstract Sensor",
                 capabilities: list = [],
                 desc: str = "An abstract device"):
        Thing.__init__(self,
                       id_=uri,
                       title=title,
                       type_=capabilities,
                       description=desc)
        # Variables
        self.auto_update: bool = True  # Whether the device should use the hardware polling to update itself
        self.name: str = mqtt_name
        self.scheduler_topic: str = cfg.scheduler_topic + self.name

        # MQTT client
        self.client: mqtt.Client = mqtt.Client(self.name)
        self.client.on_connect = self.on_connect
        self.client.on_message = self.on_message
        self.client.tls_set(ca_certs=cfg.cafile,
                            certfile=cfg.certfile,
                            keyfile=cfg.keyfile)
        self.connect()

        # Intruder module
        self.intruder: IntruderNode = IntruderNode(self.name, self.client)
Example #13
0
    def __init__(self):
        self.update_period: int = 1500
        Thing.__init__(
            self,
            'urn:dev:ops:my-humidity-sensor-1234',
            'My Humidity Sensor',
            ['MultiLevelSensor'],
            'A web connected humidity sensor'
        )

        self.level = Value(0.0)
        self.add_property(
            Property(self,
                     'level',
                     self.level,
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Humidity',
                         'type': 'number',
                         'description': 'The current humidity in %',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                         'readOnly': True,
                     }))

        logging.debug('starting the sensor update looping task')
        self.timer = tornado.ioloop.PeriodicCallback(
            self.update_level,
            self.update_period
        )
        self.timer.start()
Example #14
0
    def __init__(self, gpio_number, description):
        Thing.__init__(self, 'urn:dev:ops:eltakowsSensor-1', 'Wind Sensor',
                       ['MultiLevelSensor'], description)

        self.gpio_number = gpio_number
        self.start_time = time.time()
        self.num_raise_events = 0
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.gpio_number, GPIO.IN)
        GPIO.add_event_detect(self.gpio_number,
                              GPIO.RISING,
                              callback=self.__spin,
                              bouncetime=5)

        self.timer = tornado.ioloop.PeriodicCallback(self.__measure, 5000)

        self.windspeed = Value(0.0)
        self.add_property(
            Property(self,
                     'windspeed',
                     self.windspeed,
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Windspeed',
                         'type': 'number',
                         'minimum': 0,
                         'maximum': 200,
                         'description': 'The current windspeed',
                         'unit': 'km/h',
                         'readOnly': True,
                     }))
        self.timer.start()
Example #15
0
 def __init__(self, _location, _w1_device_id_list):
     self.location = _location
     self.id = f'urn:dev:ops:{self.location}-vorraum-node'
     self.name = f'{self.location}-node_functions'
     self.w1_device_id_list = _w1_device_id_list
     Thing.__init__(self, self.id, self.name, ['EnergyMonitor'],
                    'A web connected node')
     self.ina219 = ina219.INA219(busnum=0, address=0x40)
     self.power = Value(0.0)
     self.add_property(
         Property(self,
                  f'{self.name}-power',
                  self.power,
                  metadata={
                      '@type': 'InstantaneousPowerProperty',
                      'title': f'{self.name}-Power',
                      'type': 'float',
                      'multipleOf': 0.01,
                      'description': 'the power used by this node',
                  }))
     self.volt = Value(0.0)
     self.add_property(
         Property(self,
                  f'{self.name}-voltage',
                  self.volt,
                  metadata={
                      '@type': 'VoltageProperty',
                      'title': f'{self.name}-Voltage',
                      'type': 'float',
                      'multipleOf': 0.01,
                      'description': 'the voltage used by this node',
                  }))
     self.current = Value(0.0)
     self.add_property(
         Property(self,
                  f'{self.name}-current',
                  self.current,
                  metadata={
                      '@type': 'CurrentProperty',
                      'title': f'{self.name}-Current',
                      'type': 'float',
                      'multipleOf': 0.01,
                      'description': 'the current used by this node',
                  }))
     self.temperature = Value(0.0)
     self.add_property(
         Property(self,
                  f'{self.name}-Temperature',
                  self.temperature,
                  metadata={
                      '@type': 'TemperatureProperty',
                      'title': f'{self.name}-Temperature',
                      'type': 'float',
                      'multipleOf': 0.01,
                      'description': 'the temperature in the case',
                  }))
     self.timer = tornado.ioloop.PeriodicCallback(self.get_sensors, 300000)
     self.timer.start()
Example #16
0
 def __init__(self):
     Thing.__init__(self, 'urn:dev:ops:my-picam-thing-1234',
                    'My PiCamera Thing', ['VideoCamera'],
                    'A web connected Pi Camera')
     self.terminated = False
     self.picam = picamera.PiCamera(resolution='720p', framerate=30)
     self.still_img = Value(None)
     self.add_property(
         Property(self,
                  'snapshot',
                  self.still_img,
                  metadata={
                      '@type':
                      'ImageProperty',
                      'title':
                      'Snapshot',
                      'type':
                      'null',
                      'readOnly':
                      True,
                      'links': [{
                          'rel': 'alternate',
                          'href': '/media/snapshot',
                          'mediaType': 'image/jpeg'
                      }]
                  }))
     #self.stream_active = Value(False)
     #self.add_property(
     #    Property(self, 'streamActive', self.stream_active,
     #            metadata = {
     #                        'title': 'Streaming',
     #                        'type': 'boolean',
     #                        }))
     self.stream = Value(None)
     self.add_property(
         Property(self,
                  'stream',
                  self.stream,
                  metadata={
                      '@type':
                      'VideoProperty',
                      'title':
                      'Stream',
                      'type':
                      'null',
                      'readOnly':
                      True,
                      'links': [{
                          'rel': 'alternate',
                          'href': '/media/stream',
                          'mediaType': 'video/x-jpeg'
                      }]
                  }))
     syslog.syslog('Starting the camera')
     self.cam_thr = threading.Thread(target=self.start_PiCam, args=())
     self.cam_thr.start()
    def __init__(self):
        Thing.__init__(self, 'urn:dev:ops:my-sense-hat-sensor-1234',
                       'SenseHat Sensor', [], 'A web connected sense hat')
        controller.set_imu_config(True, True, True)

        self.pitch = Value(0.0)
        self.add_property(
            Property(self,
                     'pitch',
                     self.pitch,
                     metadata={
                         'title': 'Pitch',
                         'type': 'number',
                         'description': 'Angle pitch',
                         'unit': 'd',
                         'minimum': 0,
                         'maximum': 360,
                         'readOnly': True,
                     }))

        self.roll = Value(0.0)
        self.add_property(
            Property(self,
                     'roll',
                     self.roll,
                     metadata={
                         'title': 'Roll',
                         'type': 'number',
                         'description': 'Angle',
                         'unit': 'd',
                         'minimum': 0,
                         'maximum': 360,
                         'readOnly': True,
                     }))

        self.yaw = Value(0.0)
        self.add_property(
            Property(self,
                     'yaw',
                     self.yaw,
                     metadata={
                         'title': 'Yaw',
                         'type': 'number',
                         'description': 'Angle',
                         'unit': 'd',
                         'minimum': 0,
                         'maximum': 360,
                         'readOnly': True,
                     }))

        logging.debug('info: starting the sensor update looping task')
        self.timer = tornado.ioloop.PeriodicCallback(self.update_properties,
                                                     1000)
        self.timer.start()
Example #18
0
    def __init__(self, photos_path, static_path):
        """Initialize the thing."""
        Thing.__init__(self, 'urn:dev:ops:photo-cycler', 'Photo Cycler', [],
                       'Photo Cycler')

        self.photos_path = photos_path
        self.static_path = static_path
        self.update_rate = 5

        self.add_property(
            Property(self,
                     'updateRate',
                     Value(self.update_rate, self.set_update_rate),
                     metadata={
                         'type': 'integer',
                         'description': 'Photo cycle rate',
                         'minimum': 0,
                         'unit': 'second',
                         'title': 'Update Rate',
                     }))

        self.add_property(
            Property(self,
                     'image',
                     Value(None),
                     metadata={
                         '@type':
                         'ImageProperty',
                         'type':
                         'null',
                         'description':
                         'Current image',
                         'title':
                         'Image',
                         'readOnly':
                         True,
                         'links': [
                             {
                                 'rel': 'alternate',
                                 'href': '/static/current.jpg',
                                 'mediaType': 'image/jpeg',
                             },
                         ],
                     }))

        self.set_ui_href('/static/index.html')

        self.timer = None
        self.set_update_rate(self.update_rate)
    def __init__(self):
        Thing.__init__(self, 'urn:dev:ops:my-sense-hat-light-1234',
                       'SenseHat Light', ['OnOffSwitch', 'Light'],
                       'A web connected lamp')

        self.add_property(
            Property(self,
                     'on',
                     Value(True, lambda v: self.toggle(v)),
                     metadata={
                         '@type': 'OnOffProperty',
                         'title': 'On/Off',
                         'type': 'boolean',
                         'description': 'Whether the lamp is turned on',
                     }))
Example #20
0
    def __init__(self, uri_id, title, description, value):
        Thing.__init__(self, uri_id, title, ["TemperatureSensor"], description)

        self.add_property(
            Property(thing=self,
                     name="temperature",
                     value=value,
                     metadata={
                         "title": "Temperature",
                         "description": "The current temperature in °C",
                         "@type": "TemperatureProperty",
                         "type": "number",
                         "unit": "degree celsius",
                         "readOnly": True
                     }))
Example #21
0
    def __init__(self, uri_id, title, description, value, property_title, property_description):
        Thing.__init__(self, uri_id, title, ["MultiLevelSensor"], description)

        self.add_property(
            Property(thing=self,
                     name=property_title.lower(),
                     value=value,
                     metadata={
                         "title": property_title,
                         "description": property_description,
                         "@type": "LevelProperty",
                         "type": "number",
                         "unit": "percent",
                         "minimum": 0,
                         "maximum": 100,
                         "readOnly": True
                     }))
Example #22
0
 def __init__(self):
     self.listening = True
     self.volume = 50
     self.sensitivity = 45
     Thing.__init__(self, 'VoiceAssistant1', ['VoiceAssistant1'],
                    'CustomThing')
     self.add_property(
         Property(
             self,
             'on',
             #@https://discourse.mozilla.org/t/how-to-trigger-an-event-when-a-property-value-is-changed/34800/4
             Value(self.listening, self.setListen),
             metadata={
                 '@type': 'OnOffProperty',
                 'title': 'Listening',
                 'type': 'boolean',
                 'description':
                 'Whether the listening is muted on this object',
             }))
     self.add_property(
         Property(self,
                  'volume',
                  Value(self.volume, self.setVolume),
                  metadata={
                      '@type': 'BrightnessProperty',
                      'title': 'Volume',
                      'type': 'integer',
                      'description': 'The sound level from 0-100',
                      'minimum': 0,
                      'maximum': 100,
                      'unit': 'percent',
                  }))
     self.add_property(
         Property(self,
                  'sensitivity',
                  Value(self.sensitivity, self.setSensitivity),
                  metadata={
                      '@type': 'BrightnessProperty',
                      'title': 'Sensitivity',
                      'type': 'integer',
                      'description': 'The sensitivty level from 0-100',
                      'minimum': 20,
                      'maximum': 85,
                      'unit': 'percent',
                  }))
Example #23
0
    def __init__(self):
        Thing.__init__(self, 'ObserverIP Weather Sensor', ['MultiLevelSensor'],
                       'A web connected weather sensor')

        self.humidity = Value(0.0)
        self.add_property(
            Property(self,
                     'humidity',
                     self.humidity,
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Humidity',
                         'type': 'number',
                         'description': 'The current humidity in %',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                         'readOnly': True,
                     }))
Example #24
0
    def __init__(self, gpio_number, name, description):
        Thing.__init__(self, 'urn:dev:ops:motionSensor-1',
                       'Motion ' + name + ' Sensor', ['MotionSensor'],
                       description)

        self.gpio_number = gpio_number
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(self.gpio_number, GPIO.IN)
        GPIO.add_event_detect(self.gpio_number,
                              GPIO.BOTH,
                              callback=self.__update,
                              bouncetime=5)
        self.is_motion = False

        self.motion = Value(False)
        self.add_property(
            Property(self,
                     'motion',
                     self.motion,
                     metadata={
                         '@type': 'MotionProperty',
                         'title': 'Motion detected',
                         "type": "boolean",
                         'description':
                         'Whether ' + name + ' motion is detected',
                         'readOnly': True,
                     }))

        self.last_motion = Value(datetime.now().isoformat())
        self.add_property(
            Property(self,
                     'motion_last_seen',
                     self.last_motion,
                     metadata={
                         'title': 'Motion last seen',
                         "type": "string",
                         'unit': 'datetime',
                         'description':
                         'The ISO 8601 date time of last movement',
                         'readOnly': True,
                     }))
        self.ioloop = tornado.ioloop.IOLoop.current()
    def __init__(self, name):
        self.name = name
        Thing.__init__(
            self,
            'urn:dev:ops:my-humidity-sensor-'+name,
            name,
            ['OnOffSwitch'],
            'A web button'
        )

        self.add_property(
            Property(self,
                     'on',
                     Value(True, lambda v: print('On-State is now', v)),
                     metadata={
                         '@type': 'OnOffProperty',
                         'title': 'On/Off',
                         'type': 'boolean',
                         'description': 'Whether the lamp is turned on',
                     }))
Example #26
0
    def __init__(self, bus, address):
        Thing.__init__(
            self,
            'urn:dev:ops:humidity-temperature-sensor',
            'Humidity+Temperature Sensor',
            ['MultiLevelSensor', 'TemperatureSensor'],
        )

        # If you want icon to show humidity:
        #   - remove type `TemperatureSensor`, and
        #   - change temperature property @type to `LevelProperty`

        self.sensor = SHT20(bus, address)

        self.humidity = Value(self.sensor.humidity().RH)
        self.add_property(
            Property(self,
                     'humidity',
                     self.humidity,
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Humidity',
                         'unit': 'percent',
                         'readOnly': True,
                     }))

        self.temperature = Value(self.sensor.temperature().C)
        self.add_property(
            Property(self,
                     'temperature',
                     self.temperature,
                     metadata={
                         '@type': 'TemperatureProperty',
                         'title': 'Temperature',
                         'unit': '°C',
                         'readOnly': True,
                     }))

        logging.debug('starting the sensor update looping task')
        self.timer = tornado.ioloop.PeriodicCallback(self.update, 3000)
        self.timer.start()
    def __init__(self):
        Thing.__init__(
            self, 'urn:dev:ops:my-maaxboard-opencv-motion-sensor',
            'OpenCV motion sensor', ['MotionSensor'],
            'On device image processing for motion detection on MaaXBoard')

        self.motion = Value(0)
        self.add_property(
            Property(self,
                     'motion',
                     self.motion,
                     metadata={
                         '@type': 'MotionProperty ',
                         'title': 'MaaxBoard Opencv Motion',
                         'type': 'boolean',
                         'description': 'Whether the motion detected',
                         'readOnly': True,
                     }))

        self.timer = tornado.ioloop.PeriodicCallback(self.update_motion, 1000)
        self.timer.start()
Example #28
0
    def __init__(self, gpio_number: int, description: str):
        Thing.__init__(self, 'urn:dev:ops:dhtSensor-1',
                       'Humidity and Temperature Sensor',
                       ['TemperatureSensor', 'HumiditySensor'], description)

        self.sensor = Adafruit_DHT.DHT22
        self.gpio_number = gpio_number
        self.humidity = Value(0.0)
        self.add_property(
            Property(self,
                     'humidity',
                     self.humidity,
                     metadata={
                         '@type': 'HumidityProperty',
                         'title': 'Humidity',
                         'type': 'number',
                         'description': 'The current humidity from 0%-100%',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                         'readOnly': True,
                     }))

        self.temperature = Value(0)
        self.add_property(
            Property(self,
                     'temperature',
                     self.temperature,
                     metadata={
                         '@type': 'TemperatureProperty',
                         'title': 'Temperature',
                         'type': 'number',
                         'description': 'The current temperature',
                         'unit': 'degree celsius',
                         'readOnly': True,
                     }))

        self.timer = tornado.ioloop.PeriodicCallback(self.__measure,
                                                     (60 * 1000))  # 1 min
        self.timer.start()
Example #29
0
    def __init__(self, gpio: int, urn: str, title: str, description: str):
        Thing.__init__(
            self,
            urn,
            title,
            ['OnOffSwitch', 'Light'],
            description
        )

        ArroseurGPIO.__init__(self, gpio, urn, title, description)

        self.listofcolors = ['#89d8f8','#2078f3','#6841d8','#640156','#eb0b19','#fc7223']
        self.index = 5
        self.add_property(
            Property(self,
                     'color',
                     Value(self.listofcolors[ self.index ], lambda v:
                         logging.info('New color : %s', v)
                         ),
                     metadata={
                         '@type': 'ColorProperty',
                         'title': 'Couleur',
                         'type': 'string',
                         'description': 'Couleur du prochain arroseur',
                     }))

        self.add_property(
            Property(self,
                     'valindex',
                     Value(0, lambda v: self.update_index(v)),
                     metadata={
                         '@type': 'LevelProperty',
                         'title': 'Index',
                         'type': 'integer',
                         'description': 'Index courant de l\'arrosage',
                         'minimum': 0,
                         'maximum': 5,
                         'unit': 'second',
                     }))
    def __init__(self):
        Thing.__init__(self, 'My Humidity Sensor', ['MultiLevelSensor'],
                       'A web connected humidity sensor')

        self.level = Value(0.0)
        self.add_property(
            Property(self,
                     'level',
                     self.level,
                     metadata={
                         '@type': 'LevelProperty',
                         'label': 'Humidity',
                         'type': 'number',
                         'description': 'The current humidity in %',
                         'minimum': 0,
                         'maximum': 100,
                         'unit': 'percent',
                     }))

        logging.debug('starting the sensor update looping task')
        self.sensor_update_task = \
            get_event_loop().create_task(self.update_level())