josepramon / homebridge-mijia-camera

Homebridge plugin for the Xiaomi Mijia 1080P Smart IP Camera, also known as Mi Home Security Camera.
MIT License
38 stars 5 forks source link

State is shown off even when on #3

Closed daveramirez5 closed 5 years ago

daveramirez5 commented 5 years ago

Om home app State is shown off even when the camera is on. Switch will work fine on setting on and off but next time home app is opened the status reads again "OFF"

daveramirez5 commented 5 years ago

OK managed to have a workaround for this. I used a stateful "fake" switch using the plugin below to associate to the camera switch and then the state persistence is working homebridge-statefuldummy

williamli commented 5 years ago

@daveramirez5 how does your hack work? so you have a switch for the camera and a fake switch?

williamli commented 5 years ago

BTW, the original dummy switch plugin that homebridge-statefuldummy forked from has been updated to include statefulness

https://github.com/nfarina/homebridge-dummy/commits/master

williamli commented 5 years ago

@daveramirez5 issue resolved by my fork / pull request

https://github.com/josepramon/homebridge-mijia-camera/pull/5

DJay-X commented 5 years ago

@williamli Thanks. Unfortunately with the plugin here homebridge-mijia-camera v0.0.1 the cam can be turned on/off, but most of the time I have do the command twice to work. With Siri or manually in like the Eve app that's annoying but okay, with automation it's a no-go when the cam is not switching on the first time. So do you know if there is a fix with the Xiaomi Mijia 1080P Home Panoramic WiFi IP Camera to work more reliable? Thanks again.

daveramirez5 commented 5 years ago

@daveramirez5 issue resolved by my fork / pull request

5

Wow. Thank you Williamli !

williamli commented 5 years ago

@daveramirez5 @DJay-X sorry, there was a bug in handling the power status check in the code i posted yesterday (it was done using async / await), it blocks the whole homebridge status update process and makes homebridge unresponsive from time to time.

i have updated the code to make the whole process non-blocking now.

williamli commented 5 years ago

@DJay-X check out my fork / pull request, the code there resolves your problem. (It is caused by the original homebridge-mijia-camera code not knowing the correct status of the camera so it was returned as "OFF" most of the time, meaning you might need to press twice to get it to switch off... i.e.

Camera is ON, SWITCH think it's OFF press the switch to toggle it to ON (camera is already on, nothing changed) press again to toggle the switch to OFF, the camera follows and go to OFF.

Anyway, this issue should be resolved over at https://github.com/josepramon/homebridge-mijia-camera/pull/5

daveramirez5 commented 5 years ago

Trying your fork tonight. Will report back

daveramirez5 commented 5 years ago

@williamli Hello,

I tried to install your fork using pi@raspberrypi:~ $ sudo npm install -g git+https://github.com/williamli/homebridge-mijia-camera.git

I was unable to install; getting errors such as:

npm ERR! code 128 npm ERR! Command failed: /usr/bin/git submodule update -q --init --recursive npm ERR! fatal: Could not change back to '/root/.npm/_cacache/tmp/git-clone-2633048f': Permission denied

Also attempted by using the version “sudo npm install -g homebridge-mijia-camera@0.0.2” In this case i got an error saying no matching version found

And username; “sudo npm install -g williamli/homebridge-mijia-camera” Getting the same error about permission denied.

May be it was too soon and I needed the fork code to be validated? Regards,

williamli commented 5 years ago

@daveramirez5 homebridge-mijia-camera@0.0.2 doesn't exist in npm yet since it have not been merged to the actual library here

williamli commented 5 years ago

@daveramirez5 can you just try to manually swap out the plugin folder with mine?

daveramirez5 commented 5 years ago

@williamli Hey, I just did that; just downloaded your folder and replaced that on the /usr/lib/node-modules folder. Restarted homebridge. Works like a charm! It reads the state and its maintained after closing/opening the home app. Also no need to toggle twice as now it's working from first one. Thank you a lot!

williamli commented 5 years ago

@daveramirez5 for some reaspon, i see that it is making my homebridge unresponsive from time to time. i am not sure if it's this plugin or what... but i will update here once I find out.

if you notice anything, please let me know here as well.

daveramirez5 commented 5 years ago

Ok will be monitoring

daveramirez5 commented 5 years ago

Yep. Also happening here.

williamli commented 5 years ago

@daveramirez5 i will let you know once i find a solution

williamli commented 5 years ago

@daveramirez5 do you happen to have other Mi devices in homebridge that uses Miio?

daveramirez5 commented 5 years ago

I do have the vacuum robot using the plugin: “homebridge-xiaomi-mi-robot-vacuum” . I understand it also uses miio as is installed as part of the installation instructions

williamli commented 5 years ago

@daveramirez5 it's fixed now (everything works fine on my setup). please try the latest code in my PR.

daveramirez5 commented 5 years ago

Hello @williamli I just swapped the folder with your fork. Toogle works ok State persistance works ok Will be monitoring for 24 hours and report back

DJay-X commented 5 years ago

Thanks @williamli for your work. I'm not so familiar with replacing content of the plugin folder manually. Any chance to see a npm update available soon? Thanks again.

williamli commented 5 years ago

@DJay-X have to wait till @josepramon see our messages and approve the PR, or I post the update under a new name in npm.

josepramon commented 5 years ago

Thanks! The PR looks good, but I will not be able to test it until this weekend. Once tested, will merge it and publish the updated package.

josepramon commented 5 years ago

Thanks a lot for the PR. Just merged it and published the updated package.

daveramirez5 commented 5 years ago

I confirm it has been stable for more than 4 days now. Thank you guys.

williamli commented 5 years ago

@DJay-X you should try the updates now.

DJay-X commented 5 years ago

@williamli Thanks a lot. I did the update and tried it a couple of times with success on my Mijia 1080P Home Panoramic WiFi IP Camera. It seems to work smooth now. Fingers crossed. Thanks again to you and of course @josepramon for your work. It helps a lot. 👍🏻