def turn_on(self, **kwargs): """Instruct the light to turn on.""" from dali.gear.general import DAPC with self.driver_lock: self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255) cmd = DAPC(self.addr, to_dali_level(self._brightness)) r = self.driver.send(cmd) self._state = True
def turn_on(self, **kwargs): """Instruct the light to turn on.""" from dali.gear.general import DAPC with self.driver_lock: try: self._brightness = kwargs.get(ATTR_BRIGHTNESS, 254) _LOGGER.debug("turn on {}".format(self._brightness)) cmd = DAPC(self.addr, 254 if self._brightness==255 else self._brightness) r = self.driver.send(cmd) if self._brightness > 0: self._state = True except usb.core.USBError as e: _LOGGER.error("Can't turn_on {}: {}".format(self._name, e)) self.schedule_update_ha_state()
#!/usr/bin/env python from dali.address import Broadcast from dali.address import Short from dali.gear.general import DAPC from dali.interface import DaliServer import sys if __name__ == "__main__": addr = Short(int(sys.argv[1])) if sys.argv[1] != "all" else Broadcast() level = int(sys.argv[2]) d = DaliServer("localhost", 55825) cmd = DAPC(addr, level) d.send(cmd)
async def dali_level(level: int): global dali_loop global dev await dev.connected.wait() await dev.send(DAPC(Broadcast(), level))
#!/usr/bin/env python from dali.address import Group from dali.gear.general import DAPC from dali.interface import DaliServer import sys if __name__ == "__main__": group = int(sys.argv[1]) level = int(sys.argv[2]) d = DaliServer("localhost", 55825) cmd = DAPC(Group(group), level) d.send(cmd)
def test_construct_length_16(self): driver = UnipiDALIDriver() command = DAPC(Short(1), 2) self.assertEqual(driver.construct(command), (512, 514))
driver.logger = logger print('Response: {}'.format(driver.send(command))) driver.backend.close() if __name__ == '__main__': """Usage: python tridonic.py sync|async address value.""" from dali.gear.general import DAPC, QueryActualLevel import sys # setup console logging logger = logging.getLogger('HassebDALIDriver') logger.setLevel(logging.DEBUG) handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.DEBUG) handler.setFormatter( logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(handler) # command to send cmd = DAPC(int(sys.argv[2]), int(sys.argv[3])) # sync interface if sys.argv[1] == 'sync': _test_sync(logger, cmd) # async interface elif sys.argv[1] == 'async': _test_async(logger, cmd)
signal.pause() if __name__ == '__main__': """Usage: python tridonic.py sync|async address value """ from dali.gear.general import DAPC import signal import sys import time # setup console logging logger = logging.getLogger('TridonicDALIDriver') logger.setLevel(logging.DEBUG) handler = logging.StreamHandler(sys.stdout) handler.setLevel(logging.DEBUG) handler.setFormatter( logging.Formatter( '%(asctime)s - %(name)s - %(levelname)s - %(message)s')) logger.addHandler(handler) # command to send command = DAPC(int(sys.argv[2]), int(sys.argv[3])) # sync interface if sys.argv[1] == 'sync': _test_sync(logger, command) # async interface elif sys.argv[1] == 'async': _test_async(logger, command)