[Release] The Weather Company SmartApp: the “poor guy” weather station with event based switches automation

Hi Philippe,

I had installed "The Weather Company Web (Smart App, Device Handler, and created a device). It worked great but been having issue with updates.

I’d like to remove the Device, Device Handler, and Smart App. When I try to remove the Device, it all seems to work but the Device never gets removed. I can’t remove the Device Handler until the Device is gone. I can remove the Smart App as it stated that it is being used by other users.

Can you help me with this?

Thanks,

John

Hi John,

you should be able to delete the device first. Then the smartapp can be deleted too. Hope that helps.

I’m trying the app out and was having the same issue. It’s actually complaining about the code on line 167 (not line 166 as reported in the actual error message). That’s where you are trying to add the child device and subscribe to it all in the same line. It’s simply that you have to add both the app and the device handler code though it is not obvious that you need to also add a device handler. I think implementing some error handling and a message to tell the user to add it would be helpful.

In other news, I was considering adapting the app to trigger actions on a delayed basis after a condition is triggered during a day. For instance, if a high temperature is reached, do something at Sunset or some time in the future. Furthermore, another addition would be the ability to specify the duration of time the switch/device is on. Thoughts?

Hi there

Line 166 is:
subscribe(addChildDevice(“philippeportesppo”, “The Weather Company Web”, state.deviceId, null, [ “label”: “Weather in {twccity}, {twcstate}”, “data”: [ “TWCsnowalert”: twcsnowalert, “TWCstormalert”: twcstormalert, “TWCrainalert”: twcrainalert, “TWClowtempalert”: twclowtempalert, “TWChightempalert”: twchightempalert, “TWClowhumidityalert”: twclowhumidityalert, “TWChighhumidityalert”: twchighhumidityalert, /completedSetup: true/] ]), “Alert”, eventHandler)

It should pick up the devicehandler from your IDE set-up Device Handler github list or your manually imported code from the giyhub (2 ways yo do it). Are you saying you had the issue because you didn’t add the device handler code?
just making sure I understand well in case someone faces that in the future.

Regarding your other questions:

I would write a smartapp that registers to the Weather events rather than modifying the Weather app itself so that only the devices you need to behave that way would need to have the delay implemented while the other ones keep being handled the normal way.
in short I would make a delaymyswitch smartapp that triggers with the switch only when it receives the event from the weather app.

I am not sure I read it right. You want to have a duration set for the switch you turn on? or you want to know how long it was on between a weather event that put it on till it was stopped by another weather event?

As far as the issue, yes, I had just installed the app from your repo. I use GitHub for everything. Basically I did not realize that there was more than the app even though you mention in the first post “app and device handler”. Since I had not pulled down the DTH, it of course was not able to install it and hence the error. As soon as I pulled down the DTH I was able to install the app. The organization of the IDE having apps and DTHs on different pages contributes to the issue. I think error checking is the way to go to avoid a runtime error but of course having instructions of step 1, install the DTH; step 2, install the app, etc. might help too.

As far as the RFEs:

I don’t quite follow…did you mean the weather DTH instead of app? I think the app only has a notification push. I didn’t think about it before but I suppose you could subscribe to events from the DTH in another app but it seemed to be an natural fit for your app. Likewise, I thought about having your weather app trigger a virtual switch and then have another app pick up that event but that also seemed to add more complexity / potential failure points.

I was referring to simply adding a timer that shuts it off after a certain time. Having it turn the device off when the conditions change is also another interesting idea. It would be possible to do this from other apps such as Smart Lighting (for instance I do this using Smart Lighting for bath fans so they don’t run all day when someone forgets to shut it off) but again, having it all in one seemed natural.

You might be wondering about the use cases. I can think of a couple offhand:

  1. Watering plants - On a hot day, you might want to do some additional watering when it comes to potted/hanging. This is actually my need. Using an irrigation controller (I use Rachio) I can turn on watering from ST but I don’t think there is any environmental trigger other than physical sensors. Watering during the hot part of the day is ineffective but waiting until it cools down is ideal…and of course you only want to water for a set time.

  2. Snow melting - If you got snow then you might want to turn on a driveway snow melter after some delay / accumulation.

  3. Pipe/Gutter/ice dam heaters - You might want to turn on these types of heaters immediately but only for a set duration.

@Philippe_Portes I’ve been playing around with the app and I’m having issues getting any alerts from the child device to the main app.

Everything is installed (and I reinstalled just to be sure) and I see the child device polling and getting the right weather data and I see in the event log that it is indeed sending out the alterts but the app does not seem to get any “Alert” event regardless.

Also, although it isn’t part of the above issue per se, while debugging the App code and found that there were some errors in the code when it came to the high and low temperature settings that I initially thought were the cause but it seems not

In the code you have:

		input "twctwcwtempalert", "number", title: "Low temperature Alert (C or F)", required: false
		input "twctwcghtempalert", "number", title: "High temperature Alert (C or F)", required: false

but the value/name is incorrect so it never was getting picked up by the DTH. I corrected it and the DTH began to send these events once the threshold was triggered:

		input "twclowtempalert", "number", title: "Low temperature Alert (C or F)", required: false
		input "twchightempalert", "number", title: "High temperature Alert (C or F)", required: false

But, still no events at all seem to come back to the app in the logs.

Thoughts?

Thanks for the finding. I reviewed the code further and fixed another typo and pushed a fix on github master branch now. Please synch up your IDE smartapp.

Regarding the events to the app, I added some logs so you can try to verify by setting a lower temp than current one and refresh the device (swipe down on the device view), then you should see a log like this:

Please let me know if you face other issues

Sorry for the late reply…

Yes, “in short I would make a delaymyswitch smartapp that triggers with the switch only when it receives the event from the weather DTH.”

If you want to setup individual timers based on a formula taking into account temp and humidity, I think some folks on this forum would advice you to use WebCore rules, otherwise, you for sure can adapt the smartapp I provided. My general usage is more about triggering things like shades, outdoor devices, etc.

Thanks, I think there is an issue when you only enable one threshold such as what I was testing which was only a high temp alert. I’m debugging it now but if i turn on both high and low it works - just not one or the other.

I think you need “isStateChange:true” in the DTH sendEvent() calls. It seems to make it work for me but I am experimenting now.

Also, not sure if it matters since “true” is already the default but I think “display” should be “displayed”…

            sendEvent(name:"Alert", value: "TWC High Temperature Alert!", displayed:true, isStateChange:true)

Unrelated: Also, I’m curious why you chose to comment out your state machine logic, such as:

       //if ( state.hightempalert == false) {

I would think you would not want to get continuous alerts every 10 minutes after you’ve crossed the threshold once (maybe this should be in the app though). Also, a related suggestion would be to put in a settings slider allowing you to turn on or off the push message in the app.

the high temp had a wrong test , was checking the twchighton swtich to trigger it off. If you updated to the lastest master version you will see the code fix.

I guess that is what you are experiencing

Thanks again for that one even though, using the new app, I don’t see the event showing up in history even with displayed:true. I pushed that in a new commit on the on the master of the DTH.

Regarding the state machine, I wanted to implement it but then I left it like that, as for switches, it doesn’t matter you switch them on every 10min if they are already on and same for turning off something that is already off.

To implement the state logic, then it would have to include a counter like turn the flag off every 6 times (=1h) but then this is still the same as I explained above, it would turn on something that was on for 1h already so no benefit. But I understand that if you want to implement your timeout, you will have to implement that so you don’t rearm every 10min for another timeout period.

Actually, I wasn’t able to get it to work with the newest code unless I add the “isStateChange:true” option as I noted previously when having only one alert enabled. Basically SmartThings is trying to do you a favor by not sending a bunch of repetitive events if it thinks that nothing is really changed but in this case actually something is changing every time so I think you have to force it by adding this.

Let me know if the above doesn’t make sense. It’s only seemingly an issue when you only have one enabled alertlike just high temp…two or more it seems to know that the state is changing.

Is there a mean to point thse weather pp to MY specific weatherstation instead of zipcode?

yes, line 160 of the SmartApp put the lication as a string to the getTwcLocation function.

you’ll find the syntax in above in post #20

SO if my weather station is publishing to Weahter Underground, this will pull it?
Also, I can’t just subit my Station ID (KIDKUNA40), I have to use lat/long?

I think you’ll find some information in this thread Weather API Changes

Around post 46.

I don’t have WPS so I didn’t dig this up.