Esempio n. 1
0
 async def test_brighten(self):
     """Test brighten."""
     address = create("D", 9)
     topic = f"{address.id}.{str(X10Commands.BRIGHT)}"
     manager = X10DimBrightenManager(address)
     manager.subscribe(self.handle_on_off)
     pub.sendMessage(topic)
     assert self._last_value == 1
Esempio n. 2
0
 def test_dim(self):
     """Test dimming."""
     address = create("D", 9)
     topic = f"{address.id}.{str(X10Commands.DIM)}"
     manager = X10DimBrightenManager(address)
     manager.subscribe(self.handle_on_off)
     pub.sendMessage(topic)
     assert self._last_value == -1
Esempio n. 3
0
 async def test_all_units_off_manager(self):
     """Test all units off."""
     # Housecode B unitcode 3
     address = create("A", 7)
     topic = "x10{}.{}".format(address.housecode.lower(),
                               str(X10Commands.ALL_UNITS_OFF))
     manager = X10AllUnitsOffManager(address)
     manager.subscribe(self.handle_on_off)
     pub.sendMessage(topic)
     assert self._last_value == 0x00
Esempio n. 4
0
 async def test_all_lights_on_manager(self):
     """Test all lights on manager."""
     address = create("C", 5)
     topic = "x10{}.{}".format(address.housecode.lower(),
                               str(X10Commands.ALL_LIGHTS_ON))
     manager = X10AllLightsOnOffManager(address)
     manager.subscribe(self.handle_on_off)
     manager.subscribe_on(self.handle_on)
     manager.subscribe_off(self.handle_off)
     pub.sendMessage(topic)
     assert self._last_value == 0xFF
     assert self._on_event
     assert not self._off_event
Esempio n. 5
0
 def setUp(self):
     """Set up the test."""
     self.housecode = "C"
     self.housecode_byte = 0x02
     self.unitcode = 6
     self.unitcode_byte = 0x09
     self.address = X10Address((self.housecode_byte << 4) + self.unitcode_byte)
     self.address_create = create(self.housecode, self.unitcode)
     set_log_levels(
         logger="info",
         logger_pyinsteon="info",
         logger_messages="info",
         logger_topics=False,
     )
Esempio n. 6
0
 async def test_off(self):
     """Test off command."""
     address = create("F", 1)
     topic = "x10_received"
     manager = X10OnOffManager(address)
     manager.subscribe(self.handle_on_off)
     manager.subscribe_on(self.handle_on)
     manager.subscribe_off(self.handle_off)
     address_bytes = bytes(address)
     pub.sendMessage(topic,
                     raw_x10=int.from_bytes(address_bytes, byteorder="big"),
                     x10_flag=0x00)
     command = (address.housecode_byte << 4) + int(X10Commands.OFF)
     pub.sendMessage(topic, raw_x10=command, x10_flag=0x80)
     assert self._last_value == 0x00
     assert not self._on_event
     assert self._off_event
Esempio n. 7
0
 def test_for_all_units_lights_on_off(self):
     """Test creating an X10 address for use in the All Lights and All Units on off commands."""
     addr = create("a", 0)
     assert isinstance(addr, X10Address)