Project - Receiving SMS notifications from your washing machine


#21

That was it, thanks for your help. Now when the dryer stops I get this message
[Agent] ERROR: not enough parameters for the given format string
[Agent] ERROR: at send_sms:23
[Agent] ERROR: from unknown:88

line 23 is
local twilio_url = format (“https://api.twilio.com/2010-04-01/Accounts/%s/SMS/Messages.json&quot”, TWILIO_ACCOUNT_SID");

line 88 is
send_sms(number, “The Mace laundry is done!”)


#22

i copied the code into paste bin.
hope this helps
http://pastebin.com/cQR2TxyA


#23

Wow, that fixed it - thanks so much. If you have a Physical therapy or bike question, hit me up!
Thanks for your time and effort


#24

I really appreciate Buzzcola’s updated coding on this project. I built it using the original Twilio functions and was having difficulty with it but now it works great using the above code. I was thinking about adding a few features and was wondering if someone here could help. I programmed 20 years ago in very old languages so I understand the basics, just very rusty and not familiar with Squirrel. I’m also having trouble getting used to doing something not in a loop and it being an event-driven language so I have no idea where to place things.

We have a very busy house with 4 kids and the laundry is often forgotten in the washing machine until it a mildew smell sets in. I’m thinking that one text is going to be dismissed without much thought if we’re out of the house at the time or getting pulled in many different directions all day. I would like to try something like sending a text every 2 hours until the washer door is opened but wanted to set limits on the time so it’s not going off at 2am either. Then maybe start texting my oldest daughter if it has been sitting more than 12 hours.

I would add a door sensor to pin 7, probably starting with just a small button switch that I have lying around and will fit between the door and the machine.

Can anyone help me muddle through this? This is what I’ve got so far:

For the switch:

button <- hardware.pin7;

function buttonPress() {
local state = button.read();
if (state == 1) {
}
}

button.configure(DIGITAL_IN_PULLUP, buttonPress);

Timing:

Would it be best to use the date() function, store the stop time in hours, or use Imp’s hardware timer hardware.millis()? I was thinking I could do something like

local now = date();
hours = now.hour;

then check to see if the button hasn’t been released (state == 1) and onCount=0

AND

hours are less than 23 and greater than 6 and send a text then every 2 hours

Not sure exactly where things should go and if I’m on the right track or not. Thanks in advance!


#25

Great Idea. I just dont have the time atm :frowning:

I would suggest trying to save the state to a variable on the agent and not device.

Also another enhancement I made was to use IFTTT to save on money (ie no need for SMS $$$$).

Need to add this function/code at the top:
// Basic wrapper to create an execute an HTTP POST function HttpPostWrapper (url, headers, string) { local request = http.post(url, headers, string); local response = request.sendsync(); return response; }

and then comment out the line/s when triggering the SMS and add/replace it with:
HttpPostWrapper("https://maker.ifttt.com/trigger/WashingMachineFinished/with/key/XXXXXXXXXXXXXXX", { "Content-Type" : "text/xml" }, "washing finished");

the XXXXXX key you need to generate when making a custom appt using the maker channel in IFTTT.
There are guides in IFTTT so you can create any action which may help you create a reminder? There are a couple of channels that allows you to to this just search reminder in the “that” wizzard to see them.

So for the phone part you need to create an account on IFTTT.com
Follow the maker guide to get it setup… possibilities are endless :slight_smile:
https://ifttt.com/maker

Hope this helps :slight_smile:


#26

@Chase8332 I can relate to your story. LOL. I think of event driven as the “hot potato” game. As a function you never know when it’s your turn to deal with the data potato. When it arrives you want to deal with it quickly and then you send it on… as a function that choice of where to send new data to or how you respond back to recipient is yours. The order of the functions in the circle (i.e. your code structure in device or agent) is not too important.

Regarding timers, my suggestion is that you use imp.wakeup function. You set this to trigger every two hours. Then once triggered that function can check time of day / day of the week etc to determine nature of response, as in if after 2am don’t do anything etc. You will just need to implement a method / function that will cancel that timer at the right time (using cancelwakeup) otherwise will continue firing.

Also as you plan to send multiple timed messages, have you considered other notification options. One, which I recently discovered, is Slack - and it is free to use. You can use their api via imp agent to generate messages (similar methods to Twilio) but you can even make is such that the recipient has to acknowledge. May be a useful way to trigger the cancelwakeup timer.