Service improvements#84
Conversation
|
Change looks good. The RFC also looks good, but I would like to detach the callback from this method, because the callbacks are, most of the time, attached to the accessory, whereas you might want to configure the char in the loader or somewhere else. For them, I was thinking of something like: class MyAcc(AsyncAcc):
@getter_for("TemperatureSensor.CurrentTemperature")
def get_temp(self):
pass
@setter_for("TemperatureSensor.CurrentTemperature")
def set_temp(self, value):
passPS Do you think |
* Cleanup service (add_characteristic, to_HAP) * Removed iid_manager from to_HAP
|
I changed the method name to Regarding the Regarding the |
|
I agree. I think I didn't explain myself properly. My point is that in most cases you have class ...
def _set_services(self):
...
char.setter_callback = self.turn_bulb
def turn_bulb(self, value):
passYou can avoid the assignment and do it more explicit like: class ...
@setter_for("TemperatureSensor.CurrentTemperature")
def turn_bulb(self, value):
passAnyway, this can go in parallel with this change. Let's keep both ways for configuring the setters. |
pyhap/service.py
Outdated
| def to_HAP(self, iid_manager=None): | ||
| """Create a HAP representation of this Service. | ||
| def configure_char(char_name, properties=None, valid_values=None, | ||
| value=None, callback=None): |
There was a problem hiding this comment.
can we change it to setter_callback, as we expect to have a getter_callback as well?
Small improvements to the
serviceclass (see commit descriptions):add_characteristic,to_HAP)iid_managerfromto_HAPRFC: I would suggest to add a helper method
setup_char. This would simplify the process of configuring a characteristic: