def __init__(self): SIISThing.__init__( self, "smoke_1", 'urn:dev:siis:smoke', 'My Smoke Detector', ['Alarm'], 'A web connected smoke detector' ) self.state: Value = Value(False) self.update_period: float = 1000.0 self.add_property( Property(self, 'on', self.state, metadata={ '@type': 'AlarmProperty', 'title': 'Smoke detected', 'type': 'boolean', 'description': 'Whether smoke has been detected', 'readOnly': True, })) self.add_available_event( 'alarm', {'description': 'Smoke detected'} ) self.device = SmokeDetector(cfg.pin, self.activated, self.deactivated) self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_state, self.update_period ) self.timer.start()
def __init__(self): SIISThing.__init__(self, "sensor_1_hygro", 'urn:dev:siis:hygrometer', 'My Hygrometer', ['MultiLevelSensor'], 'A web connected hygrometer') self.humidity: Value = Value(50) self.update_period: float = 1000.0 self.add_property( Property(self, 'humidity', self.humidity, metadata={ '@type': 'LevelProperty', 'title': 'Humidity', 'type': 'number', 'unit': 'percent', 'description': 'Current air humdity', 'readOnly': True, 'multipleOf': 0.1, })) self.device = Barometer() self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_state, self.update_period) self.timer.start()
def __init__(self): SIISThing.__init__(self, "sensor_1_baro", 'urn:dev:siis:barometer', 'My Barometer', ['MultiLevelSensor'], 'A web connected barometer') self.pressure: Value = Value(1018.2) self.update_period: float = cfg.pin * 1000 self.add_property( Property(self, 'temperature', self.pressure, metadata={ '@type': 'LevelProperty', 'title': 'Pressure', 'type': 'number', 'minimum': 900, 'maximum': 1100, 'unit': 'hPa', 'description': 'Current atomspheric pressure', 'readOnly': True, 'multipleOf': 0.1, })) self.device = Barometer() self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_state, self.update_period) self.timer.start()
def __init__(self, name: str = "sensor_1"): SIISThing.__init__(self, name) self.temp_state_topic: str = cfg.base_topic + self.name + "/thermometer" + cfg.state_suffix self.humidity_state_topic: str = cfg.base_topic + self.name + "/hygrometer" + cfg.state_suffix self.pressure_state_topic: str = cfg.base_topic + self.name + "/barometer" + cfg.state_suffix self.thermometer = Thermometer() self.barometer = Barometer() self.hygrometer = Barometer()
def __init__(self): SIISThing.__init__(self, "outlet_1", 'urn:dev:siis:outlet', 'My Outlet', ['SmartPlug'], 'A web connected outlet') self.state: Value = Value(False, self.set_value) self.add_property( Property(self, 'on', self.state, metadata={ '@type': 'OnOffProperty', 'title': 'On state', 'type': 'boolean', 'description': 'Whether the outlet is on', })) self.device = Relay(cfg.pin)
def __init__(self): SIISThing.__init__(self, "tv_1", 'urn:dev:siis:tv', 'My TV', ['OnOffSwitch'], 'A web connected TV') self.state: Value = Value(False, self.set_state) self.add_property( Property(self, 'on', self.state, metadata={ '@type': 'OnOffProperty', 'title': 'On state', 'type': 'boolean', 'description': 'Whether the TV is on', 'readOnly': False, })) self.device = TV()
def __init__(self): SIISThing.__init__( self, "lock_1", 'urn:dev:siis:lock', 'My Lock', ['Lock'], 'A web connected lock' ) self.state: Value = Value("unlocked", self.set_state) self.add_property( Property(self, 'locked', self.state, metadata={ '@type': 'LockedProperty', 'title': 'Lock state', 'type': 'string', 'description': 'Whether the lock is locked', 'readOnly': True, 'enum': ['locked, unlocked'], })) self.add_available_action( "lock", { "title": "Lock", "description": "Set the lock to locked state", }, LockAction ) self.add_available_action( "unlock", { "title": "Unlock", "description": "Set the lock to unlocked state", }, UnlockAction ) self.device = ServoMotor(cfg.pin)
def __init__(self): SIISThing.__init__(self, "presence_1", 'urn:dev:siis:presence', 'My Presence Sensor', ['BinarySensor'], 'A web connected presence sensor') self.update_period: float = 10000.0 self.state: Value = Value(False) self.add_property( Property(self, 'state', self.state, metadata={ '@type': 'BooleanProperty', 'title': 'On/Off', 'type': 'boolean', 'description': 'Whether the switch is turned on', 'readOnly': True, })) self.device = PIR(cfg.pin, self.activated, self.deactivated)
def __init__(self, name: str = "hvac_1"): SIISThing.__init__(self, name) self.last_mode: str = "" self.last_action: str = "off" self.last_target: float = 0 self.last_temp: float = 20 self.outside_temp: float = 20 self.thermal_cond: float = 0.05 # 1/min self.heating_efficiency: float = 0.5 # C/min self.cooling_efficiency: float = 0.5 # C/min self.temp_state_topic: str = cfg.base_topic + self.name + "/temperature" + cfg.state_suffix self.action_state_topic: str = cfg.base_topic + self.name + "/action" + cfg.state_suffix self.mode_set_topic: str = cfg.base_topic + self.name + "/mode" + cfg.set_suffix self.mode_state_topic: str = cfg.base_topic + self.name + "/mode" + cfg.state_suffix self.target_temperature_set: str = cfg.base_topic + self.name + "/target_temperature" + cfg.set_suffix self.target_temperature_state: str = cfg.base_topic + self.name + "/target_temperature" + cfg.state_suffix self.thermometer: Thermometer = Thermometer() self.heater_cooler: Relay = Relay(cfg.pin)
def __init__(self): SIISThing.__init__(self, "switch_1", 'urn:dev:siis:switch', 'My Switch', ['BinarySensor'], 'A web connected lamp') self.update_period: float = cfg.update_delay * 1000 self.state: Value = Value(False) self.add_property( Property(self, 'state', self.state, metadata={ '@type': 'BooleanProperty', 'title': 'On/Off', 'type': 'boolean', 'description': 'Whether the switch is turned on', 'readOnly': True, })) self.device = Switch(cfg.pin) self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_state, self.update_period) self.timer.start()
def __init__(self): SIISThing.__init__(self, "sensor_1_therm", 'urn:dev:siis:thermometer', 'My Thermometer', ['TemperatureSensor'], 'A web connected thermometer') self.temp: Value = Value(20.0) self.update_period: float = cfg.pin * 1000 self.add_property( Property(self, 'temperature', self.temp, metadata={ '@type': 'TemperatureProperty', 'title': 'Temperature', 'type': 'number', 'description': 'Current temperature', 'readOnly': True, 'multipleOf': 0.1, })) self.device = Thermometer() self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_state, self.update_period) self.timer.start()
def __init__(self, name: str = "outlet_1"): self.name: str = name SIISThing.__init__(self, name) self.last_state: str = "OFF" self.device: Relay = Relay(cfg.pin)
def __init__(self): SIISThing.__init__(self, "light_1", 'urn:dev:siis:light', 'My Lamp', ['OnOffSwitch', 'Light'], 'A web connected lamp') self.on_state: Value = Value(False, self.set_state) self.add_property( Property(self, 'on', self.on_state, metadata={ '@type': 'OnOffProperty', 'title': 'On/Off', 'type': 'boolean', 'description': 'Whether the lamp is turned on', })) self.brightness_state: Value = Value(100, self.set_brightness) self.add_property( Property(self, 'brightness', self.brightness_state, metadata={ '@type': 'BrightnessProperty', 'title': 'Brightness', 'type': 'integer', 'description': 'The level of light from 0-100', 'minimum': 0, 'maximum': 100, 'unit': 'percent', })) self.color_state: Value = Value("#FFFFFF", self.set_color) self.add_property( Property(self, 'color', self.color_state, metadata={ '@type': 'ColorProperty', 'title': 'Color', 'type': 'string', 'description': 'The color of the light in hex RGB', })) self.temperature_state: Value = Value(2700, self.set_temperature) self.add_property( Property(self, 'temperature', self.temperature_state, metadata={ '@type': 'ColorTemperatureProperty', 'title': 'Temperature', 'type': 'integer', 'description': 'The temperature of the light in Kelvin', 'minimum': 2200, 'maximum': 6500, 'unit': 'kelvin', })) self.color_mode_state: Value = Value( "temperature", lambda v: logging.debug("Color mode is now %s" % v)) self.add_property( Property(self, 'colorMode', self.color_mode_state, metadata={ '@type': 'ColorModeProperty', 'title': 'Color Mode', 'type': 'string', 'description': 'The color mode of the light', 'enum': ['color', 'temperature'], 'readOnly': True })) self.device = RGBLight(cfg.pin)
def __init__(self, name: str = "presence_1"): SIISThing.__init__(self, name) self.last_state: str = "OFF" self.device: PIR = PIR(cfg.pin, self.activated, self.deactivated)
def __init__(self, name: str = "lock_1"): SIISThing.__init__(self, name) self.last_state: str = "" self.device: ServoMotor = ServoMotor(cfg.pin) self.connect()
def __init__(self, name: str = "smoke_1"): SIISThing.__init__(self, name) self.fixed_state: str self.device: SmokeDetector = SmokeDetector(cfg.pin, self.activated, self.deactivated)
def __init__(self, name: str = "light_1"): SIISThing.__init__(self, name) self.last_state: dict = {"state": "OFF"} self.device: RGBLight = RGBLight(cfg.pin)
def __init__(self, name: str = "tv_1"): SIISThing.__init__(self, name) self.last_state: str = "" self.device: TV = TV()
def __init__(self): SIISThing.__init__(self, "hvac_1", 'urn:dev:siis:hvac', 'My HVAC', ['Thermostat'], 'A web connected HVAC') self.current_temp: Value = Value(20.0) self.add_property( Property(self, 'temperature', self.current_temp, metadata={ '@type': 'TemperatureProperty', 'title': 'Temperature', 'type': 'number', 'unit': 'degree celsius', 'description': 'The current temperature', 'readOnly': True, 'multipleOf': 0.1, })) self.target_temp: Value = Value(18.0, self.set_target) self.add_property( Property(self, 'target_temperature', self.target_temp, metadata={ '@type': 'TargetTemperatureProperty', 'title': 'Target Temperature', 'type': 'number', 'unit': 'degree celsius', 'description': 'The desired temperature', 'readOnly': False, 'multipleOf': 0.1 })) self.state: Value = Value('off') self.add_property( Property(self, 'state', self.state, metadata={ '@type': 'HeatingCoolingMode', 'title': 'State', 'type': 'string', 'enum': ['off', 'heating', 'cooling'], 'description': 'The current state', 'readOnly': True, })) self.mode: Value = Value('off', self.set_mode) self.add_property( Property(self, 'mode', self.mode, metadata={ '@type': 'ThermostatModeProperty', 'title': 'Mode', 'type': 'string', 'enum': ['off', 'heat', 'cool', 'auto'], 'description': 'The current mode', 'readOnly': False, })) self.thermo = Thermometer() self.relay = Relay(cfg.pin) self.outside_temp: float = 20 self.heating_efficiency: float = 0.5 self.cooling_efficiency: float = 0.5 self.thermal_cond: float = 0.05 self.update_period: float = cfg.update_delay * 1000.0 self.timer: tornado.ioloop.PeriodicCallback = tornado.ioloop.PeriodicCallback( self.update_temp, self.update_period) self.timer.start()