Exemplo n.º 1
0
    # present. (More to this later)

    # ### 3.2.2 CommandField (type="command").
    #
    # This field allows us to directly control the linked IoT device by
    # sending commands.

    # To do this we need to add Commands to the CommandField.
    # A command has 1 property:
    # - name: The internal name that the specific device uses for this purpose
    from filip.semantics.semantics_models import Command
    c1 = Command(name="open")
    my_outlet.controlCommand.add(c1)

    my_floor.hasRoom.add(my_building)
    print(my_building.build_context_entity().json(indent=2))

    # After the current state was saved. We can interact with the command. It
    # offers three functions:
    # - c1.send(): Send the command to the device to execute it
    # - c1.get_info(): View the result of the executed command
    # - c1.get_status(): See the current status of the sent command

    # ### 3.2.3 Uniqueness
    #
    # A property (Command, DeviceAttribute) can only be added to one instance
    # A property will add fields to the Fiware instance, as field names need
    # to be unique, a name check is made if a new property is added to an
    # instance field.
    # If a required field of the new property is already existing an error is
    # raised