Hacker News new | past | comments | ask | show | jobs | submit login

Is your app in the Play Store?



No apps here. It is just a Wifi-plug and Termux. It reads the battery voltage with termux-battery-status and turns the plug onoff. It does various other things too and there are issues, which I dont remember, so here is the entire program.

  import os,json,time
  loki="../batcon.log"
  f=open(loki,'w')
  f.write('ALKU\n')
  f.close()
  lokinolla=time.time()
  alku=True
  while True:
    b=json.loads(os.popen("termux-wifi-connectioninfo").read())
    if b['ip'] == "192.168.1.205":
        os.system("termux-api-start")
        os.system("termux-wake-lock")
        a=json.loads(os.popen("termux-battery-status").read())
        if alku:
            alku=False
            os.system('termux-notification -c "BATCON TOIMII"')
        p=a['percentage']
        s=a['status']
        cur=a['current']
        if p<70 and s=="DISCHARGING":
            yes=int((time.time()-lokinolla)/60)
            if yes>0:
                fi=open(loki,'a')
                fi.write(str(yes)+" "+str(cur/1000)+"\n")
                fi.close()
            os.system('curl 192.168.1.156/ON')
            lokinolla=time.time()
        if s=="CHARGING":
            if p>70: os.system('curl 192.168.1.156/OFF')
            if p==81:
                os.system("termux-tts-speak -l fi LASTAUS EI LOPU &")
                if 0!=os.system("ping -c 1 192.168.1.156"):
                    os.system("termux-tts-speak -l fi LATURI EI VERKOSSA &")
                time.sleep(30)
        if 0==os.system("ping -c 1 192.168.1.118"):
            os.system("termux-volume music 15 &")
            os.system("termux-tts-speak -l en YOUR FRONT DOOR IS OPEN! &")
            time.sleep(30)
        if 0==os.system("ping -c 1 192.168.1.219"):
            os.system("termux-volume music 15 &")
            os.system("termux-tts-speak -l fi HUOMIO... JÄÄKAAPIN OVI ON AUKI ! &")
            os.system("termux-toast -b yellow -c black  JÄÄKAAPPI")
            time.sleep(30)
    else:
        alku=True
        print('No KOTIKONE')
    time.sleep(30)


Does your fridge only get an IP when the door is open?


Yes. It is battery-operated esp-01, which gets power when door is open, establishes wifi-connection and after few minutes goes to machine.deepsleep().




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: