Open soundprojects opened 2 years ago
So with some help of the Homekit Accessory Simulator, I figured out what was missing
This might be useful to put in the documentation:
In the example above, the IOS home app expects the 'status_active' of the temperature and humidity sensor to be set to true and most importantly, it expects the 'is_configured' value of the valve to be set to true as well
The Active and In Use values characteristics then indicate whether the Valve is Active and (if either manually or some automatic program you develop is running) you set the In Use to true. These two values set to true make the switch visible in the 'on' state and the labels set to 'on'
When this is set using the following code:
if let Some(ref mut conf) = hydro.valve.is_configured{
conf.set_value(Value::Number(Number::from(1))).await.unwrap();
}
if let Some(ref mut conf) = hydro.temperature_sensor.status_active{
conf.set_value(Value::Number(Number::from(1))).await.unwrap();
}
if let Some(ref mut conf) = hydro.tds_sensor.status_active{
conf.set_value(Value::Number(Number::from(1))).await.unwrap();
}
The application works as expected. There might be a prettier way of setting the values instead of the above and I think it would be nice if you could just have methods on the services and characteristics that make more sense instead of the generic 'set_value'. Maybe we could create some macro to generate methods like 'set_active' / 'set_inactive' that could be used within an async update_method to update a service without the need for a running timed loop...?
Good find!
There might be a prettier way of setting the values instead of the above and I think it would be nice if you could just have methods on the services and characteristics that make more sense instead of the generic 'set_value'. Maybe we could create some macro to generate methods like 'set_active' / 'set_inactive' that could be used within an async update_method to update a service without the need for a running timed loop...?
And good point! Feel free to experiment on that. I'm happy to accept API improvements that make sense to you!
When adding accessories to the Ios Home app, pressing the accessory with force or touch or clicking accessory details does not make anything happen. It is like the app is experiencing some error. It only happens with the services I add with hap-rs
For example here is my custom irrigation system code:
It connects properly but the valve is absent from the configuration and pressing the accessory to show its details does not do anything at all.
What would be a good starting point to look into this? The dnssd seems to work properly. Debug shows that TCP streams are setup. How can you verify that what the service needs to send as configuration is what the ios app is expecting?
Thanks