homebridge-examples
homebridge-examples copied to clipboard
How can i show in Homekit that a plugin has no actual values?
Current Situation
I have written a hb-plugin for intes pools. The plugin connects with an api and get the values (state) from my pool. Sometimes the api is not reachable. How can i show this in homekit accessories? For example the temperature sensor shows 34° and if the sensor get no new value after the interval the value is not valid and i want to set the accessory to error (not reachable). How can i do this! Thank you a lot for answering. Peter
Logs
Not important
Configuration
Not important
Environment
Not important
Process Supervisor
not applicable
Additional Context
No response
The common pattern for indicating that a device is not returning any data is to use the updatecharacteristic method, and return an error value. See this
https://developers.homebridge.io/#/api/service#serviceupdatecharacteristic
Okay. But i have no updateCharacteristic Function. I have used the static platform example and the api sample for a temperature sensor... I use this function to set the value which i got from my pool. I have no "no response=!" in the sensor... /**
- Handle requests to set the "Temperature Display Units" characteristic */ handleCurrentTemperatureSet(value) { value = new Error('A placeholder error object'); //this.updateCharacteristic(this.Characteristic.CurrentTemperature, new Error('A placeholder error object')); this.log.debug("Triggered SET CurrentTemperature: ", value); //this.switchService.getCharacteristic(this.Characteristic.CurrentTemperature).updateValue(value); this.curValue = value; this.tempsensorService.getCharacteristic(this.Characteristic.CurrentTemperature).setValue(value); }
updateValue also works the same way.
In your code, the setValue is not needed. updateValue updates the value within homebridge/homekit
Okay. I tried this, but the values doesn't change and there is no ! sign on the temperature sensors... handleCurrentTemperatureSet(value) { this.log.debug("now error Triggered SET CurrentTemperature: ", value); value = new Error('A placeholder error object'); this.log.debug("Triggered SET CurrentTemperature: ", value); this.curValue = value; this.tempsensorService.getCharacteristic(this.Characteristic.CurrentTemperature).updateValue(value);
Something odd must be occurring in your code as this pattern works very well as I use it with my homebridge-tasmota plugin
https://github.com/NorthernMan54/homebridge-tasmota/blob/master/src/TasmotaService.ts#L184
The reference to this.characteristic
is the primary service/characteristic of the accessory.