Class FloatCharacteristic

    • Constructor Detail

      • FloatCharacteristic

        public FloatCharacteristic​(String type,
                                   String description,
                                   double minValue,
                                   double maxValue,
                                   double minStep,
                                   String unit,
                                   Optional<Supplier<CompletableFuture<Double>>> getter,
                                   Optional<ExceptionalConsumer<Double>> setter,
                                   Optional<Consumer<HomekitCharacteristicChangeCallback>> subscriber,
                                   Optional<Runnable> unsubscriber)
        Default constructor
        Parameters:
        type - a string containing a UUID that indicates the type of characteristic. Apple defines a set of these, however implementors can create their own as well.
        description - a description of the characteristic to be passed to the consuming device.
        minValue - the minimum supported value.
        maxValue - the maximum supported value
        minStep - the smallest supported step. Values will be rounded to a multiple of this.
        unit - a description of the unit this characteristic supports.
        getter - getter to retrieve the value
        setter - setter to set value
        subscriber - subscriber to subscribe to changes
        unsubscriber - unsubscriber to unsubscribe from chnages
    • Method Detail

      • makeBuilder

        protected CompletableFuture<javax.json.JsonObjectBuilder> makeBuilder​(int iid)
        Creates the JSON serialized form of the accessory for use over the HomeKit Accessory Protocol.
        Overrides:
        makeBuilder in class BaseCharacteristic<Double>
        Parameters:
        iid - the static id of the accessory.
        Returns:
        a future that will complete with the JSON builder for the object.
      • convert

        protected Double convert​(javax.json.JsonValue jsonValue)
        Converts from the JSON value to a Java object of the type T
        Specified by:
        convert in class BaseCharacteristic<Double>
        Parameters:
        jsonValue - the JSON value to convert from.
        Returns:
        the converted Java object.
      • getValue

        protected final CompletableFuture<Double> getValue()
        Retrieves the current value of the characteristic.. Calls the getDoubleValue method and applies rounding to the minStep supplied in the constructor.
        Specified by:
        getValue in class BaseCharacteristic<Double>
        Returns:
        a future that will complete with the current value.
      • getDefault

        public Double getDefault()
        Supplies a default value for the characteristic to send to connected clients when the real value. cannot be retrieved.
        Specified by:
        getDefault in class BaseCharacteristic<Double>
        Returns:
        a sensible default value.