EliasKotlyar / Xiaomi-Dafang-Hacks

4.19k stars 1k forks source link

SW Night Mode only working if Page is open #1145

Closed BMOtheConsole closed 4 years ago

BMOtheConsole commented 5 years ago

On my Dafang Pan/Tilt Auto Night Mode is not working correctly, it is working flawless if im in the SW Night Configuration Tab on my Camera, but as soon as i leave the Page the SW Night Mode is not working anymore and the Camera is Stuck in Whatever Mode it was last

G-Dewd commented 5 years ago

I am also facing this issue on my two Wyze V2 cameras.

saipsa commented 5 years ago

the process is being killed it seems. see what process is started when the page is opened and add it to chron job for every 15 minutes.

danmed commented 5 years ago

Also got this problem.. any actual solutions?

dixnor commented 5 years ago

The only way I found and seems rock solid is to move the /system/sdcard/www/sw_night_configure.html to another location after you had configured the sensor thresholds. This just to make sure that you never go back again to nightmode software configuration. It seems that this html page interfers with autonightmode process in a certain way after you hit the page. Probably because it locks the process when reading the light sensor values. Give it a try, works

mbaruzzo commented 5 years ago

I have a dafang camera and experiencing the same issue, tried dixnor method but no luck. Not sure what else to try...

davidpesce commented 5 years ago

Same issue here.

msmarks commented 5 years ago

I run /system/sdcard/controlscripts/auto-night-detection in ssh, then it works, i don‘t know why.

TRSx80 commented 5 years ago

I run /system/sdcard/controlscripts/auto-night-detection in ssh, then it works, i don‘t know why.

I did this method and it works.

That seems to be a script that (with no options supplied (it can also do some other things)) checks if auto-night-detection is already running, and if not, starts it. It also looks in a CONF_FILE which by default is /system/sdcard/config/autonight.conf and in my case contains: -S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8.

Those settings look pretty familiar. I think that once you tweak them in the SW detection web page, you press the save button on that page, and it dumps them to this file. Then they can be invoked this way.

Only question remaining is, do we execute this just once each time the camera starts, or periodically with a cron job to check the conditions? I guess I will find out when it gets dark whether it adjusts automatically or not...

vdwkes commented 5 years ago

Is there a possibility that auto night detection is always on , on startup of the camera? I use a xiaofang with the dafang hack as a babycam. But everytime i plug it in i have to set the autonight mode on. As long as the cam is connected to power it works fine.

TRSx80 commented 5 years ago

Yeah I ended up having to run /system/sdcard/controlscripts/auto-night-detection as a cron job every 15 min (or whatever the lowest setting was in the preconfigured folders) in order to get it to persist. So far it seems to be working (automatically changing from day to night mode)!

jmtatsch commented 5 years ago

auto-night-detection is by default started with the camera. If it is not running we should investigate why it died.

vdwkes commented 5 years ago

everytime i plug in my xiaofang S1 i have to set auto night detect manually

SirRedwind commented 4 years ago

I have the same issue, but only in 1 of my 4 cameras. The other 3 work fine. Could it be something corrupted on the original installation of the firmware which never got updated? Maybe a fresh install would do it? Any thoughts? Or... As @jmtatsch mentioned, this is default started with the camera. How do we know if it's still running and/or how did it crash?

cwiggs commented 4 years ago

I'm also having this issue. I implemented the workaround @TRSx80 mentioned using a cron job. However on my Wyze V2 running crontab did not work until I created /var/spool/cron/crontabs

So, if anyone else has this issue, this is how I created the cronjob:

mkdir -p /var/spool/cron/crontabs
cat '* * * * * /system/sdcard/controlscripts/auto-night-detection' >> /var/spool/cron/crontabs

That should run every minute. You can also use crontab -e and manually enter in the cron setting if you like.

EDIT:

I don't think the above works, after a while the /var/spool/cron/crontabs file is gone.

I did find /system/sdcard/config/cron/crontabs/root which you can add to. Or place a cronjob file into /system/sdcard/config/cron/periodic/15min/

However I noticed this morning that if I just run /system/sdcard/controlscripts/auto-night-detection it doesn't seem to act the same as going to the "SW Night Configuration" page, so running that shell script does not seem to really fix the issue for me.

If anyone has any other ideas on a workaround or need me to test something, feel free to comment.

cwiggs commented 4 years ago

Looking into this more and I found when I went to the "SW Night Configuration" page that the following error was showing up in /var/log/lighttpd-cgi-stderr.log:

cat: can't open '/system/sdcard/config/autonight.conf': No such file or directory

Looking into this more and I found this issue: https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/issues/845#issuecomment-449803369

In that comment they mention to do the following:

I followed those steps and now SW night mode seems to work correctly. I suspect the issue is simple that the /system/sdcard/config/autonight.conf file is missing. In the future if someone has this issue, try and run this command and see if it fixes the issue:

cat '-S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8' > /system/sdcard/config/autonight.conf

If the missing autonight.conf is really the issue I think the permanent fix is to include that file in the git repo so it will be there on a new install.

danmed commented 4 years ago

I've just done your suggestions.. Previously my autonight.conf only contained "-S".. it now contains the parameters.. so will see what's what.

Edit : Ok.. so now one of my cameras is completely black as it's in the dark but night mode isn't on... not quite working i'd say.

cwiggs commented 4 years ago

@danmed I should have mentioned, I did reboot after I made my changes, perhaps that will help?

davidpesce commented 4 years ago
  • Browse to "SW Night configuration" page
  • Disable "Auto Night Detection" under "Camera Controls"
  • Click "save" on the "SW Night Configuration" page, which creates the /system/sdcard/config/autonight.conf file.

This seemed to work for me as well. It created the autonight.conf file.

danmed commented 4 years ago

Yeah i think the missing step is to re-enable auto night detection :)

On Tue, Jan 7, 2020 at 4:42 PM Chris Wiggins notifications@github.com wrote:

@danmed https://github.com/danmed I should have mentioned, I did reboot after I made my changes, perhaps that will help?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/issues/1145?email_source=notifications&email_token=AA5S4WR4KC7RRKJYJB7YHADQ4SWHRA5CNFSM4ISX4DUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIJPXTY#issuecomment-571669455, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5S4WXP56UU652IBS23KQLQ4SWHRANCNFSM4ISX4DUA .

cwiggs commented 4 years ago

I created PR #1245 that adds the autonight.conf file. Once that is merged we should be able to close this issue.

Morphy99 commented 4 years ago

I'm having this issue still. My autonight.conf existed and did contain -S but not the extra parameters. I added these but still it refuses to switch to night mode until the SW Night Configuration page is opened. I also copied autonight.conf.dist to autonight.conf (which contained the parameters).

It seems the SW Night Configuration page is only saving the file sw=-S.

jmtatsch commented 4 years ago

Did you update with autoupdate?

Morphy99 commented 4 years ago

Did you update with autoupdate?

Yea I updated last night and it still wasn't switching on without going to that page.

Morphy99 commented 4 years ago

Any suggestions how I can troubleshoot this? Is there a log for the night mode component?

jmtatsch commented 4 years ago

Is it still not working? You do use a clean config file?

Morphy99 commented 4 years ago

I've tried deleting the autonight.conf file and stopping the service then pressing Save on the config page. It generates the file ok but still doesn't switch after a reboot. Service is showing as running.

On Mon, 17 Feb 2020, 22:57 jmtatsch, notifications@github.com wrote:

Is it still not working? You do use a clean config file?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks/issues/1145?email_source=notifications&email_token=ABMVGG2IRDE5TL25SMJXNILRDMI5TA5CNFSM4ISX4DUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL73N7Q#issuecomment-587183870, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABMVGGYX4M5U6GCCLLFM7QTRDMI5TANCNFSM4ISX4DUA .

strikeir13 commented 4 years ago

I'm also having this issue and I'm on the current firmware. My /var/log/lighttpd-cgi-stderr.log has this error: /system/sdcard/www/cgi-bin/action.cgi: /system/sdcard/config/autonight.conf: line 3: -j: not found

jmtatsch commented 4 years ago

Can you post your autonight.conf?

crackers8199 commented 4 years ago

This is also not working for me...config file exists, service is running, but it's not switching. At all. Ever.

jmtatsch commented 4 years ago

Can you look with what parameters the autonight executable is running? With ps?

iceatcs commented 4 years ago

Ah, there is it.

I have a problem in here too with my Neos SmartCam (same shape as Xiaomi Xiaofang 1S and Wyzecam V2) I can confirm that Xiaomi Dafang is working with no problem with HW and SW mode.

I assume Xiaofang 1S also have this problem as well. My mate said couldn't get it to work too.

My autonight.conf: autonight_mode=sw hw_parameters= sw_parameters="-S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8" # set ir_led_off to true in front of IR reflecting windows ir_led_off=true

strikeir13 commented 4 years ago

Can you post your autonight.conf?

autonight_mode=sw  
hw_parameters=  
sw_parameters=-S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8  
#set ir_led_off to true in front of IR reflecting windows  
ir_led_off=false

relevant results of ps command:

 /system/sdcard/bin/autonight autonight_mode=sw hw_parameters= sw_parameters=-S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8 # set ir_led_off to true in front

Auto night mode shows as running in the camera controls as well. This may be unrelated, but when I reboot the camera from the webpage (Services - Reboot), it reboots but does not start up again until I pull the plug. It does seem to save any changes, though.

jmtatsch commented 4 years ago

Ahh, the service is being called with the contents of the whole config file, this cannot work.

crackers8199 commented 4 years ago

i just updated to latest version and it still doesn't seem to work. it's still running with the whole config file as options for the autonight script...

edit: actually, it seems the update didn't work. does the update from GUI not work?

iceatcs commented 4 years ago

The GUI update setting page is not for updating the mod (I assume it is for camera firmware if you put the file in the SD.

I always update by: Backup your wpa_config/wpa_supplicant.conf Remove all files from the microSD card Put everything from "firmware_mod" folder into the root of the microSD card Copy the backed up wpa_supplicant.conf from step 1 back into the config folder

You will have to re-setting.

crackers8199 commented 4 years ago

The GUI update setting page is not for updating the mod (I assume it is for camera firmware if you put the file in the SD.

I always update by: Backup your wpa_config/wpa_supplicant.conf Remove all files from the microSD card Put everything from "firmware_mod" folder into the root of the microSD card Copy the backed up wpa_supplicant.conf from step 1 back into the config folder

You will have to re-setting.

can i do this via SSH while the cam is running? if i have to run around to every single camera and pull the SD card and do this every time i want to update that's going to get old real fast...

iceatcs commented 4 years ago

I dunno if it will work while it running but it is what on the installation page. I couldn't see any alternative in there like via SSH. You could try that.

If it is all work from what version, I won't bother to update in any future. Then it doesn't have to keep updating every time.

crackers8199 commented 4 years ago

seems updating via FTP/SSH does work, even if it is a somewhat roundabout way to make it happen. here's what i did:

seems to have worked, the autonight script seems to be running now with the correct options. one thing i have noticed though is that i have no firmware string.

edit: figured out the version string. it looks like that was supposed to be updated by the autoupdate script...

@jmtatsch is updating via GUI (or by running the script via SSH) broken? neither one worked for me, had to copy files manually as i described above.

jmtatsch commented 4 years ago

@crackers8199 no updating shouldnt be broken, do you use a proxy or anything special?

crackers8199 commented 4 years ago

@jmtatsch yeah, i figured out what happened...i have my cameras restricted from talking to the internet. next time i need to update i'll turn that firewall rule off and i'm sure it'll work...but if anyone was interested, the steps i outlined above will work to update manually.

throttlenerd commented 2 years ago

Hey guys! Updated firmware on Dafang and now I can't figure out how to turn off Auto Night Detection. I mean I see it in Settings but stopping this service does nothing. How can I make it always stay in Day Mode? When I navigate to Software Auto Night Settings the camera switches to Day Mode but then, if it's dark, switches to Night Mode. Is there any smart command line like "-S -j 3 -w 3 -1 1200000 -2 930000,14,10 -3 3000,17,8" I could use? Thank you!