Skip to content

hololinked.metadata.td.interaction_affordance.PropertyAffordance

Bases: DataSchema, InteractionAffordance, PropertyMetadata

Implements property affordance schema from Property descriptor object.

Schema
UML Diagram

Source code in repo/hololinked/hololinked/metadata/td/interaction_affordance.py
class PropertyAffordance(DataSchema, InteractionAffordance, PropertyMetadata):
    """
    Implements property affordance schema from `Property` descriptor object.

    [Schema](https://www.w3.org/TR/wot-thing-description11/#propertyaffordance) <br>
    [UML Diagram](https://docs.hololinked.dev/UML/PDF/InteractionAffordance.pdf) <br>
    """

    # [Supported Fields]() <br>
    observable: Optional[bool] = None

    def __init__(self):
        super().__init__()

    @property
    def what(self) -> Enum:  # noqa: D102
        return ResourceTypes.PROPERTY

    @property
    def event_unique_identifier(self) -> str:
        """Unique identifier for the change event of an observable property."""
        return f"{self.thing_id}/{self.name}_change_event"

    def build(self) -> None:  # noqa: D102
        property = cast(Property, self.objekt)
        self.ds_build_from_property(property)
        if property.observable:
            self.observable = property.observable

    @classmethod
    def from_descriptor(cls, property: Property, owner: Thing | ThingMeta) -> "PropertyAffordance":  # noqa: D102
        if not isinstance(property, Property):
            raise TypeError(f"property must be instance of Property, given type {type(property)}")
        affordance = PropertyAffordance()
        affordance.owner = owner
        affordance.objekt = property
        affordance.build()
        affordance.build_non_compliant_metadata()
        return affordance

Attributes

event_unique_identifier property

event_unique_identifier: str

Unique identifier for the change event of an observable property.

TD Supported Fields

Apart from the fields supported InteractionAffordance and DataSchema, the following is supported

field supported meaning default usage
observable ✔️ true if Property pushes change events Property.observable value