예제 #1
0
    async def list_accessories_and_characteristics(self):
        """
        This retrieves a current set of accessories and characteristics behind this pairing.

        :return: the accessory data as described in the spec on page 73 and following
        :raises AccessoryNotFoundError: if the device can not be found via zeroconf
        """
        await self._ensure_connected()

        response = await self.connection.get_json("/accessories")

        accessories = response["accessories"]

        for accessory in accessories:
            for service in accessory["services"]:
                service["type"] = service["type"].upper()
                try:
                    service["type"] = ServicesTypes.get_uuid(service["type"])
                except KeyError:
                    pass

                for characteristic in service["characteristics"]:
                    characteristic["type"] = characteristic["type"].upper()
                    try:
                        characteristic["type"] = CharacteristicsTypes.get_uuid(
                            characteristic["type"])
                    except KeyError:
                        pass

        self.pairing_data["accessories"] = accessories
        return accessories
예제 #2
0
파일: sensor.py 프로젝트: yangbo1979/core
     key=CharacteristicsTypes.Vendor.VOCOLINC_OUTLET_ENERGY,
     name="Power",
     device_class=SensorDeviceClass.POWER,
     state_class=SensorStateClass.MEASUREMENT,
     native_unit_of_measurement=POWER_WATT,
 ),
 CharacteristicsTypes.TEMPERATURE_CURRENT:
 HomeKitSensorEntityDescription(
     key=CharacteristicsTypes.TEMPERATURE_CURRENT,
     name="Current Temperature",
     device_class=SensorDeviceClass.TEMPERATURE,
     state_class=SensorStateClass.MEASUREMENT,
     native_unit_of_measurement=TEMP_CELSIUS,
     # This sensor is only for temperature characteristics that are not part
     # of a temperature sensor service.
     probe=(lambda char: char.service.type != ServicesTypes.get_uuid(
         ServicesTypes.TEMPERATURE_SENSOR)),
 ),
 CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT:
 HomeKitSensorEntityDescription(
     key=CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT,
     name="Current Humidity",
     device_class=SensorDeviceClass.HUMIDITY,
     state_class=SensorStateClass.MEASUREMENT,
     native_unit_of_measurement=PERCENTAGE,
     # This sensor is only for humidity characteristics that are not part
     # of a humidity sensor service.
     probe=(lambda char: char.service.type != ServicesTypes.get_uuid(
         ServicesTypes.HUMIDITY_SENSOR)),
 ),
 CharacteristicsTypes.AIR_QUALITY:
 HomeKitSensorEntityDescription(
예제 #3
0
    },
    CharacteristicsTypes.Vendor.KOOGEEK_REALTIME_ENERGY: {
        "name": "Real Time Energy",
        "device_class": DEVICE_CLASS_POWER,
        "state_class": STATE_CLASS_MEASUREMENT,
        "unit": "watts",
    },
    CharacteristicsTypes.get_uuid(CharacteristicsTypes.TEMPERATURE_CURRENT): {
        "name": "Current Temperature",
        "device_class": DEVICE_CLASS_TEMPERATURE,
        "state_class": STATE_CLASS_MEASUREMENT,
        "unit": TEMP_CELSIUS,
        # This sensor is only for temperature characteristics that are not part
        # of a temperature sensor service.
        "probe": lambda char: char.service.type
        != ServicesTypes.get_uuid(ServicesTypes.TEMPERATURE_SENSOR),
    },
}


class HomeKitHumiditySensor(HomeKitEntity, SensorEntity):
    """Representation of a Homekit humidity sensor."""

    _attr_device_class = DEVICE_CLASS_HUMIDITY
    _attr_unit_of_measurement = PERCENTAGE

    def get_characteristic_types(self):
        """Define the homekit characteristics the entity is tracking."""
        return [CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT]

    @property
예제 #4
0
    },
    CharacteristicsTypes.Vendor.EVE_DEGREE_AIR_PRESSURE: {
        "name": "Air Pressure",
        "device_class": DEVICE_CLASS_PRESSURE,
        "state_class": STATE_CLASS_MEASUREMENT,
        "unit": PRESSURE_HPA,
    },
    CharacteristicsTypes.get_uuid(CharacteristicsTypes.TEMPERATURE_CURRENT): {
        "name": "Current Temperature",
        "device_class": DEVICE_CLASS_TEMPERATURE,
        "state_class": STATE_CLASS_MEASUREMENT,
        "unit": TEMP_CELSIUS,
        # This sensor is only for temperature characteristics that are not part
        # of a temperature sensor service.
        "probe": lambda char: char.service.type
        != ServicesTypes.get_uuid(ServicesTypes.TEMPERATURE_SENSOR),
    },
    CharacteristicsTypes.get_uuid(CharacteristicsTypes.RELATIVE_HUMIDITY_CURRENT): {
        "name": "Current Humidity",
        "device_class": DEVICE_CLASS_HUMIDITY,
        "state_class": STATE_CLASS_MEASUREMENT,
        "unit": PERCENTAGE,
        # This sensor is only for humidity characteristics that are not part
        # of a humidity sensor service.
        "probe": lambda char: char.service.type
        != ServicesTypes.get_uuid(ServicesTypes.HUMIDITY_SENSOR),
    },
}


class HomeKitHumiditySensor(HomeKitEntity, SensorEntity):
예제 #5
0
def test_get_uuid_no_service():
    with pytest.raises(Exception):
        ServicesTypes.get_uuid("public.hap.service.NO_A_SERVICE")
예제 #6
0
def test_get_uuid():
    assert (
        ServicesTypes.get_uuid("public.hap.service.doorbell")
        == "00000121-0000-1000-8000-0026BB765291"
    )