Characteristic¶
Characteristic Base class for a HAP Accessory Service
.
See also
pyhap.service.Service
-
class
pyhap.characteristic.
Characteristic
(display_name, type_id, properties, allow_invalid_client_values=False, unique_id=None)[source]¶ Represents a HAP characteristic, the smallest unit of the smart home.
A HAP characteristic is some measurement or state, like battery status or the current temperature. Characteristics are contained in services. Each characteristic has a unique type UUID and a set of properties, like format, min and max values, valid values and others.
-
client_update_value
(value, sender_client_addr=None)[source]¶ Called from broker for value change in Home app.
Change self.value to value and call callback.
-
classmethod
from_dict
(name, json_dict, from_loader=False)[source]¶ Initialize a characteristic object from a dict.
Parameters: json_dict (dict) – Dictionary containing at least the keys Format, Permissions and UUID
-
get_value
()[source]¶ This is to allow for calling getter_callback
Returns: Current Characteristic Value
-
notify
(sender_client_addr=None)[source]¶ Notify clients about a value change. Sends the value.
See also
accessory.publish
See also
accessory_driver.publish
-
override_properties
(properties=None, valid_values=None)[source]¶ Override characteristic property values and valid values.
Parameters: - properties (dict) – Dictionary with values to override the existing properties. Only changed values are required.
- valid_values (dict) – Dictionary with values to override the existing valid_values. Valid values will be set to new dictionary.
-
set_value
(value, should_notify=True)[source]¶ Set the given raw value. It is checked if it is a valid value.
If not set_value will be aborted and an error message will be displayed.
Characteristic.setter_callback You may also define a setter_callback on the Characteristic. This will be called with the value being set as the arg.
See also
Characteristic.value
Parameters: - value (Depends on properties["Format"]) – The value to assign as this Characteristic’s value.
- should_notify (bool) – Whether a the change should be sent to subscribed clients. Notify will be performed if the broker is set.
-