def open_cover(self, **kwargs): """Open the cover.""" if self._way == '1': self._closed = False mac = self._mac.split('#') CMD_OPEN[2], CMD_OPEN[3] = int(mac[0], 16), int(mac[1], 16) CMD_OPEN[6], CMD_OPEN[7] = int(mac[0], 16), int(mac[1], 16) CMD_OPEN[-2] = 0x1 CMD_OPEN[-3] = 0x1 resu_crc = checkcrc.xorcrc_hex(CMD_OPEN) CMD_OPEN[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_OPEN }) elif self._way == '2': self._closed = False mac = self._mac.split('#') CMD_OPEN[2], CMD_OPEN[3] = int(mac[0], 16), int(mac[1], 16) CMD_OPEN[6], CMD_OPEN[7] = int(mac[0], 16), int(mac[1], 16) CMD_OPEN[-3] = 0x3 CMD_OPEN[-2] = 0x1 resu_crc = checkcrc.xorcrc_hex(CMD_OPEN) CMD_OPEN[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_OPEN })
def close_cover(self, **kwargs): """Close the cover.""" if self._way == '1': self._closed = True mac = self._mac.split('#') CMD_CLOSE[2], CMD_CLOSE[3] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[6], CMD_CLOSE[7] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[-3] = 0x2 CMD_CLOSE[-2] = 0x1 resu_crc = checkcrc.xorcrc_hex(CMD_CLOSE) CMD_CLOSE[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_CLOSE }) if self._way == '2': self._closed = True mac = self._mac.split('#') CMD_CLOSE[2], CMD_CLOSE[3] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[6], CMD_CLOSE[7] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[-3] = 0x4 CMD_CLOSE[-2] = 0x1 resu_crc = checkcrc.xorcrc_hex(CMD_CLOSE) CMD_CLOSE[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_CLOSE })
def dongle_softsence_service(call): sence_id = call.data.get('id') data = [0x80, 0x00, 0xFF, 0xFF, 0x07, 0x44, 0xFF, 0xFF, 0x9C, 0xFF, 0xFF, 0x0D, 0xe3] data[-2] = int(sence_id) resu_crc = checkcrc.xorcrc_hex(data) data[-1] = resu_crc hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": data})
def stop_cover(self, **kwargs): """Stop the cover.""" mac = self._mac.split('#') CMD_COVER_STOP[2], CMD_COVER_STOP[3] = int(mac[0], 16), int(mac[1], 16) CMD_COVER_STOP[6], CMD_COVER_STOP[7] = int(mac[0], 16), int(mac[1], 16) resu_crc = checkcrc.xorcrc_hex(CMD_COVER_STOP) CMD_COVER_STOP[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": CMD_COVER_STOP})
def edit_dongle_conf_service(call): channel = call.data.get('channel') net = call.data.get('net') net_arry = net.split(':') CMD_EDIT_DONGLE[8] = int(channel, 10) CMD_EDIT_DONGLE[9] = int(net_arry[0], 16) CMD_EDIT_DONGLE[10] = int(net_arry[1], 16) resu_crc = checkcrc.xorcrc_hex(CMD_EDIT_DONGLE) CMD_EDIT_DONGLE[-1] = resu_crc hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": CMD_EDIT_DONGLE})
def stop_cover(self, **kwargs): """stop the cover.""" # 0x80, 0x00, 0x1f, 0xa4, 0x10, 0x44, 0x1f, 0xa4, 0x60, 0x3, 0x0, 0x2, 0x0, # 0x7, 0x0, 0x6, 0x0, 0x5, 0x0, 0x4, 0x1, 0xb4 self._closed = True mac = self._mac.split('#') BYTES_STOP[2], BYTES_STOP[3] = int(mac[0], 16), int(mac[1], 16) BYTES_STOP[6], BYTES_STOP[7] = int(mac[0], 16), int(mac[1], 16) BYTES_STOP[-2] = 0x1 resu_crc = checkcrc.xorcrc_hex(BYTES_STOP) BYTES_STOP[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": BYTES_STOP}) time.sleep(0.4) BYTES_STOP[2], BYTES_STOP[3] = int(mac[0], 16), int(mac[1], 16) BYTES_STOP[6], BYTES_STOP[7] = int(mac[0], 16), int(mac[1], 16) BYTES_STOP[-2] = 0x0 resu_crc = checkcrc.xorcrc_hex(BYTES_STOP) BYTES_STOP[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": BYTES_STOP})
def open_cover(self, **kwargs): """Open the cover.""" # 0x80, 0x00, 0x1f, 0xa4, 0x10, 0x44, 0x1f, 0xa4, 0x60, 0x3, 0x0, 0x2, 0x0, # 0x7, 0x0, 0x6, 0x1, 0x5, 0x0, 0x4, 0x0, 0xb4 self._closed = False mac = self._mac.split('#') BYTES_OPEN[2], BYTES_OPEN[3] = int(mac[0], 16), int(mac[1], 16) BYTES_OPEN[6], BYTES_OPEN[7] = int(mac[0], 16), int(mac[1], 16) BYTES_OPEN[-5] = 0x1 resu_crc = checkcrc.xorcrc_hex(BYTES_OPEN) BYTES_OPEN[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": BYTES_OPEN}) time.sleep(0.4) BYTES_OPEN[2], BYTES_OPEN[3] = int(mac[0], 16), int(mac[1], 16) BYTES_OPEN[6], BYTES_OPEN[7] = int(mac[0], 16), int(mac[1], 16) BYTES_OPEN[-5] = 0x0 resu_crc = checkcrc.xorcrc_hex(BYTES_OPEN) BYTES_OPEN[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": BYTES_OPEN})
def stop_cover(self, **kwargs): """Stop the cover.""" mac = self._mac.split('#') if self._way == '1': CMD_CLOSE[2], CMD_CLOSE[3] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[6], CMD_CLOSE[7] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[-3] = 0x1 CMD_CLOSE[-2] = 0x0 resu_crc = checkcrc.xorcrc_hex(CMD_CLOSE) CMD_CLOSE[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_CLOSE }) elif self._way == '2': CMD_CLOSE[2], CMD_CLOSE[3] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[6], CMD_CLOSE[7] = int(mac[0], 16), int(mac[1], 16) CMD_CLOSE[-3] = 0x3 CMD_CLOSE[-2] = 0x0 resu_crc = checkcrc.xorcrc_hex(CMD_CLOSE) CMD_CLOSE[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, { "data": CMD_CLOSE })
def open_cover(self, **kwargs): """Open the cover.""" if self._position == 100: return elif self._position is None: self._closed = False self.schedule_update_ha_state() return self._listen_cover() self._requested_closing = False self.schedule_update_ha_state() mac = self._mac.split('#') CMD_COVER_OPEN[2], CMD_COVER_OPEN[3] = int(mac[0], 16), int(mac[1], 16) CMD_COVER_OPEN[6], CMD_COVER_OPEN[7] = int(mac[0], 16), int(mac[1], 16) resu_crc = checkcrc.xorcrc_hex(CMD_COVER_OPEN) CMD_COVER_OPEN[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": CMD_COVER_OPEN})
def set_cover_position(self, position, **kwargs): """Move the cover to a specific position.""" if self._position == position: return self._position = position self.schedule_update_ha_state() mac = self._mac.split('#') CMD_COVER_POS[2], CMD_COVER_POS[3] = int(mac[0], 16), int(mac[1], 16) CMD_COVER_POS[6], CMD_COVER_POS[7] = int(mac[0], 16), int(mac[1], 16) CMD_COVER_POS[14] = position crc16 = checkcrc.calculateCRC(CMD_COVER_POS[9:15]) crc16_h = eval(hex(crc16)[0:4]) crc16_l = '0x{}'.format(hex(crc16)[4:6]) crc16_l = eval(crc16_l) CMD_COVER_POS[15] = crc16_l CMD_COVER_POS[16] = crc16_h resu_crc = checkcrc.xorcrc_hex(CMD_COVER_POS) CMD_COVER_POS[-1] = resu_crc self._hass.services.call(POLY_ZIGBEE_DOMAIN, POLY_ZIGBEE_SERVICE, {"data": CMD_COVER_POS})