<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_nightlight(self, state):
 """Sets the night light state of the smart plug"""

    packet = bytearray(16)
    packet[0] = 2
    if self.check_power():
      packet[4] = 3 if state else 1
    else:
      packet[4] = 2 if state else 0
    self.send_packet(0x6a, packet)