Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cls
- #Settings
- $senzor = "" # For example http://192.168.1.1/api/power?apikey=53B8B55BEE6A4775" #Need to know POW's IP and API key
- #Email Settings
- $SMTPUsername = "" #for example somebody@seznam.cz
- $SMTPServer = "" #for example smtp.seznam.cz
- $SecureStringPassword = Read-Host "password for email account please" -AsSecureString
- $EmailCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $SMTPUsername,$SecureStringPassword
- $email1 = "" #emaill address or special email address with your phonenumber which you received from your operator I can set it in My T-Mobile App in Czech Republic
- $counter = 5 #Higer value when script is started because of fake notification it will be changed to 0 after dryer will be started.
- while (1){
- #Vypis poweru
- $power = Invoke-WebRequest -uri $senzor
- $actualtime = Get-Date -Format "yyyy-MM-dd HH:mm"
- write-host $actualtime $power.Content "W - counter: " $counter
- if([INT]$power.Content -lt 5){ #When power is less then 5W (standby value) it add 1 to counter
- $counter = $counter + 1
- }
- else{
- $counter = 0
- }
- if($counter -eq 3){ # If it is for three times less then 5W it goes to send e-mail notification
- write-host("I: E-mail has been sent") -ForegroundColor Yellow
- Send-MailMessage -From $SMTPUsername -To $email1 -Subject "Drying finished" -SmtpServer $SMTPServer -Credential $EmailCredential
- }
- Start-Sleep -Seconds 30 #Wait 30s
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement