Power on/off as boolean instead of int (the HomeKit specs say it should be a bool).
Cached value used check changed to 'undefined' checks as they didn't work correctly with bools. "if (!cachedValue)" is also true for a false or 0 value.
Updated the device value cache only after successful Domoticz calls.
Always update the characteristic in their setters (even if they seem unchanged). Let HomeBridge handle the check if it should be processed to HomeKit.
Changes: