Returns the power state of the smart power strip in raw format.
487318
def check_power_raw(self):
    """"""
    packet = bytearray(16)
    packet[0x00] = 0x0a
    packet[0x02] = 0xa5
    packet[0x03] = 0xa5
    packet[0x04] = 0x5a
    packet[0x05] = 0x5a
    packet[0x06] = 0xae
    packet[0x07] = 0xc0
    packet[0x08] = 0x01

    response = self.send_packet(0x6a, packet)
    err = response[0x22] | (response[0x23] << 8)
    if err == 0:
      payload = self.decrypt(bytes(response[0x38:]))
      if type(payload[0x4]) == int:
        state = payload[0x0e]
      else:
        state = ord(payload[0x0e])
      return state
465884
def raw(self):
        
        if self._raw is None:
            self._raw = HttpStream(self)
        return self._raw
362667
def power(self):
        """"""
        power = self._state['powerUsage']
        return PowerUsage(power.get('avgDayValue'),
                          power.get('avgValue'),
                          power.get('dayCost'),
                          power.get('dayUsage'),
                          power.get('isSmart'),
                          power.get('meterReading'),
                          power.get('value'),
                          power.get('meterReadingLow'),
                          power.get('dayLowUsage'))
164641
def GetStatus(self):
        
        # status packet format
        STATUS_FORMAT = ">BBBhhhHhhhHBBBxBbHBHHHHBbbHHBBBbbbbbbbbbBH"
        STATUS_FIELDS = [
            "packetType",
            "firmwareVersion",
            "protocolVersion",
            "mainFineCurrent",
            "usbFineCurrent",
            "auxFineCurrent",
            "voltage1",
            "mainCoarseCurrent",
            "usbCoarseCurrent",
            "auxCoarseCurrent",
            "voltage2",
            "outputVoltageSetting",
            "temperature",
            "status",
            "leds",
            "mainFineResistor",
            "serialNumber",
            "sampleRate",
            "dacCalLow",
            "dacCalHigh",
            "powerUpCurrentLimit",
            "runTimeCurrentLimit",
            "powerUpTime",
            "usbFineResistor",
            "auxFineResistor",
            "initialUsbVoltage",
            "initialAuxVoltage",
            "hardwareRevision",
            "temperatureLimit",
            "usbPassthroughMode",
            "mainCoarseResistor",
            "usbCoarseResistor",
            "auxCoarseResistor",
            "defMainFineResistor",
            "defUsbFineResistor",
            "defAuxFineResistor",
            "defMainCoarseResistor",
            "defUsbCoarseResistor",
            "defAuxCoarseResistor",
            "eventCode",
            "eventData",
        ]

        self._SendStruct("BBB", 0x01, 0x00, 0x00)
        while 1:  # Keep reading, discarding non-status packets
            read_bytes = self._ReadPacket()
            if not read_bytes:
                return None
            calsize = struct.calcsize(STATUS_FORMAT)
            if len(read_bytes) != calsize or read_bytes[0] != 0x10:
                logging.warning("Wanted status, dropped type=0x%02x, len=%d",
                                read_bytes[0], len(read_bytes))
                continue
            status = dict(
                zip(STATUS_FIELDS, struct.unpack(STATUS_FORMAT, read_bytes)))
            p_type = status["packetType"]
            if p_type != 0x10:
                raise MonsoonError("Package type %s is not 0x10." % p_type)
            for k in status.keys():
                if k.endswith("VoltageSetting"):
                    status[k] = 2.0 + status[k] * 0.01
                elif k.endswith("FineCurrent"):
                    pass  # needs calibration data
                elif k.endswith("CoarseCurrent"):
                    pass  # needs calibration data
                elif k.startswith("voltage") or k.endswith("Voltage"):
                    status[k] = status[k] * 0.000125
                elif k.endswith("Resistor"):
                    status[k] = 0.05 + status[k] * 0.0001
                    if k.startswith("aux") or k.startswith("defAux"):
                        status[k] += 0.05
                elif k.endswith("CurrentLimit"):
                    status[k] = 8 * (1023 - status[k]) / 1023.0
            return status
592578
def getStates(self):
        

        cust_attr = (self.raw_data.get("rtc_cm:state")
                         .get("@rdf:resource")
                         .split("/")[-2])
        return self.rtc_obj._get_paged_resources("State",
                                                 projectarea_id=self.contextId,
                                                 customized_attr=cust_attr,
                                                 page_size="50")
794910
async def get_power_parameters_for(
            cls, system_ids: typing.Sequence[str]):
        
        if len(system_ids) == 0:
            return {}
        data = await cls._handler.power_parameters(id=system_ids)
        return data
177462
async def get_power_parameters(self):
        """"""
        data = await self._handler.power_parameters(system_id=self.system_id)
        return data
571878
def set_state(self, state):
        
        if self.index() == 0:
            values = {"outlets": [{"desired_state": {"powered": state}}, {}]}
        else:
            values = {"outlets": [{}, {"desired_state": {"powered": state}}]}

        response = self.api_interface.set_device_state(self, values, id_override=self.parent_id(),
                                                       type_override="powerstrip")
        self._update_state_from_response(response)
643816
def check_power(self):
    """"""
    packet = bytearray(16)
    packet[0] = 1
    response = self.send_packet(0x6a, packet)
    err = response[0x22] | (response[0x23] << 8)
    if err == 0:
      payload = self.decrypt(bytes(response[0x38:]))
      if type(payload[0x4]) == int:
        if payload[0x4] == 1 or payload[0x4] == 3 or payload[0x4] == 0xFD:
          state = True
        else:
          state = False
      else:
        if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3 or ord(payload[0x4]) == 0xFD:
          state = True
        else:
          state = False
      return state
1271450
def status_light(self):
        
        result = self.deviceProperties.GetLEDState()
        LEDState = result["CurrentLEDState"]  # pylint: disable=invalid-name
        return True if LEDState == "On" else False
57396
def StateOfCharge(self):
        
        return (self.bus.read_byte_data(self.address, 0x02) + self.bus.read_byte_data(self.address, 0x03) * 256)
914807
def get_device_state(self):
        
        log.debug("getting device state...")
        cmd, url = DEVICE_URLS["get_device_state"]
        return self._exec(cmd, url)
846234
def get_power_metrics
      chassis = rest_get('/redfish/v1/Chassis/')
      chassis_uri = response_handler(chassis)['links']['Member'][0]['href']
      power_metrics_uri = response_handler(rest_get(chassis_uri))['links']['PowerMetrics']['href']
      response = rest_get(power_metrics_uri)
      metrics = response_handler(response)
      power_supplies = []
      metrics['PowerSupplies'].each do |ps|
        power_supply = {
          'LineInputVoltage' => ps['LineInputVoltage'],
          'LineInputVoltageType' => ps['LineInputVoltageType'],
          'PowerCapacityWatts' => ps['PowerCapacityWatts'],
          'PowerSupplyType' => ps['PowerSupplyType'],
          'Health' => ps['Status']['Health'],
          'State' => ps['Status']['State']
        }
        power_supplies.push(power_supply)
      end
      {
        @host => {
          'PowerCapacityWatts' => metrics['PowerCapacityWatts'],
          'PowerConsumedWatts' => metrics['PowerConsumedWatts'],
          'PowerSupplies' => power_supplies
        }
      }
    end
931377
def dump_state(self):
        

        superstate = super(ReferenceController, self).dump_state()

        superstate.update({
            'state_name': self.STATE_NAME,
            'state_version': self.STATE_VERSION,
            'app_info': self.app_info,
            'os_info': self.os_info,

            # Dump all of the subsystems
            'remote_bridge': self.remote_bridge.dump(),
            'tile_manager': self.tile_manager.dump(),
            'config_database': self.config_database.dump(),
            'sensor_log': self.sensor_log.dump()
        })

        return superstate
1290619
def get_providing_power_source_type(self):
        
        power_status = SYSTEM_POWER_STATUS()
        if not GetSystemPowerStatus(pointer(power_status)):
            raise WinError()
        return POWER_TYPE_MAP[power_status.ACLineStatus]
1220579
def set_power(self, state):
    """"""
    packet = bytearray(16)
    packet[0] = 2
    if self.check_nightlight():
      packet[4] = 3 if state else 2
    else:
      packet[4] = 1 if state else 0
    self.send_packet(0x6a, packet)
839522
def get_consumption(self):
        """"""
        self.get_status()
        try:
            self.consumption = self.data['power']
        except TypeError:
            self.consumption = 0

        return self.consumption