fixed rest server bugs and pir sensor bugs