Tasker Scene WebView JavaScript Interaction - Tasker Tips & Tricks

Is it possible to call a Javascript function that exists within a WebView from Tasker? I tried calling a URL on the WebView of "javascript:FUNCTION_NAME()", but that did not seem to work.
This is a completely random example. Lets say, from Tasker, that I want to be able to change the background color of the body of the WebView.
In the webview, I have the code
JavaScript:
function ChangeBGColor(NewColor)
{
document.body.style.backgroundColor=NewColor;
}
I want to be able to call ChangeBGColor() from Tasker with a color.

I remember having this same question a while back and was unable to find a solution that didn't involve sending HTTP requests, so I came up with a really weird hacky solution. I'm not sure its going to work for your situation, but maybe it can give you some ideas.
On the web side- have a transparent div element that occupies a single pixel. Put it in a corner or somewhere you won't accidently touch it. Now, add an event listener to it like this:
element.addEventListener('touchend', (e)=> {
let x = e.changedTouches[0].clientX;
let y = e.changedTouches[0].clientY;
renderColor(x, y);
});
On the Tasker side- If you don't already have it, download AutoInput, which is plugin that was created by Joao Diaz before he took over development of Tasker, and its incredibly cheap for what it does. You can use it to simulate a swipe gesture that starts at that exact spot on the screen, and ends at the coordinates you specify. You now have a way to send two values from tasker to you Javascript with a possible range of your screen resolution.
This might be challenging if you want the full spectrum of colors, because ideally you would want 3 parameters with 256 possibe values (0 for 00 and 256 for FF), so you'll have to figure out a way to encode and decode your color. You could either dumb down the resolution of colors and then use some math involving the modulus operator, but a better way would be to send the data via two swipe gestures, which would give you 4 parameters to work with- so to send white with full opacity (FFFFFFFF), simulate a swipe starting at 0,0 and ending at 256, 256 (FF or 256 for your alpha value, and the same for red), have your Javascript function store that in a variable. Then, send the second swipe which in this case will be the same as the first, and you now have 4 values to give you your color. Keep in mind you'll want to offset everything by 1 or you wouldn't be able to send black, since swiping from 0,0 to 0,0 won't trigger anything.

Related

Excel VB question: re: Arrays

Hey,
I am working on something for work and it has to do with a simple database (excel file) with data kept in rows. This data is accessed using a userform that looks up a query that happens to be the data kept in the first column of the spreadsheet. Basically, each row contains 46 cells, including the first cell (the query).
I am hoping to use the same userform to search, update, save, print and quit excel. So far search works:
Code:
Sub CommandButton1_Click()
dim query as range
set query = range("A:A")
call readData(query.find(TextBox1, lookat:=xlWhole).row)
End Sub
Private Sub readData(x as integer)
Dim boxes as range
set boxes = range("A:A")
TextBox1 = boxes.cells(x).offset(0,0)
TextBox2 = boxes.cells(x).offset(0,1)
....
End Sub
This works fine for search; however, as there is 45 boxes containing different kinds of data, I would rather read the cells from the spreadsheet using a loop and setting the TextBoxN as a static array:
Code:
Sub readData(x as integer)
***** VB treats array(45) as an array having 46 elements *****
dim textBoxArray(45) as [u]Variant[/u]
set textBoxArray = array(TextBox1, TextBox2... TextBox46)
For i = 1 to 46
textBoxArray(i-1) = cells(x, i)
Next i
End Sub
Note that "query.find(TextBox1, lookat:=xlWhole).row" returns the row number of the query and this is passed as an integer to the readData sub-routine and is referred to as "x".
I would like to do this for the read and then do the same, although opposite for the update (i guess I could call it the 'write' back to the excel worksheet).
The problem is, with this code I get an error that says the array is not declared or arranged (Japanese laptop: 配列は割り当てられません。)
Question 1
Any of you developers with any vb experience know how I can correctly declare my array (would be nice if I could decare the array globally so that I don't have to re-declare it for every sub-routine, and I can just use the for loop in each sub-routine)?
At present, all the code is within the userform and I cannot seem to declare outside of a subroutine:
Code:
Public boxArray(45) as Variant
Sub CommandButton_Click()
...
End Sub
Question 2 SOLVED I removed the "set" from the line where I filled the array with each textbox. Tested it again and all data is flowing correctly. Only need question 1 answered.
Thank you.
Hey all, thanks for the replies; I didn't think the thread would be this popular.
I solved the problem with global variables. Instead of setting a fixed array size in the main code section dec area, I found another way of assigning values to all 46 textboxes.
Instead of:
Code:
Dim boxArray(45) as Variant
boxArray(45) = array(TextBox1, TextBox2, ... TextBox46)
then
Code:
For i = 1 to 46
boxArray(i-1) = cells(x,i)
Next i
I used vb's Control method/function (no array necessary):
Code:
For i = 1 to 46
Control("TextBox" + CStr(i)) = cells(x,i)
Next i
So i turned 46+ lines into 6+ lines into 3 lines.
MODS, this thread may be closed. THanks.

[APP] Native screen rotate applications

i wrote two applications that provide screen rotations in different scenarios.
the first one (rotexec) rotates the screen in a particularly orientation and executes an application, then restores the orientation on exit.
the second one (devomon) polls the accelerometer and updates the screen orientation.
i know there are already applications out there that handle these tasks, but the ones i found all ran on the .net vm.
my goal here was to minimize the memory footprint, something not possible with managed languages.
for devomon.. with 4 filtered applications, it consumes about 52 KB of heap space.
the new version of devomon (with a gui):
http://www.megaupload.com/?d=LCOWUDF4
rotexec and devomon w/o a gui (don't use it):
http://www.megaupload.com/?d=DL58WVU4
project is hosted at SourceForge.. i haven't committed the newer changes though.
----
rotexec is intended for use with shortcuts, although if you use it more than once you might have a hard time distinguishing when all have the same damn icon.
the command-line format is...:
Code:
rotexec <direction>|<full_path_to_exe>[|<args]
<direction> indicates the side the top of the window touches and can be either N, S, E, or W
you can quote the individual items (i.e., "N" vs. N), but not the entire string.
* the orientation is set for the duration of the program, regardless of whether or not it owns the foreground window.
example shortcut:
Code:
88#"\Storage Card\rotexec.exe" W|\Storage Card\Program Files\Navigator\TomTom Navigator.exe
----
devomon reads the output of the accelerometer using htcsensorsdk.dll.
* the screen orientation is changed for all applications except those in the filter list.
* if the keyboard is out, no orientation changes are made.
* filters cannot be persisted at this time.
devomon now has a gui.
I'd just like to say a TON of thanks to this program. It works GREAT. I use it for Remote Desktop. I always want it rotated portrait, without the keyboard open, and now it does!
In addition, I would like to add a recommendation for modifying the shortcut icons. This app that I have attached is called Shortcut Creator, and it allows you to pull up any shortcut, and specify an icon from any .EXE on the device!

NoRefresh enabler

Hi,
I am trying to put a code together to control the refresh behavior of the e-ink screen. The final goal is to have a drop-in library for app developers to help making their app more e-ink friendly.
The code works already for the PRS-T1, but needs a different driver for the Nook Touch (N2EpdController included).
My one and only beta tester gets the famous "There is a problem parsing the package" error. Pls find enclosed the sources.
I would be grateful if someone could fix possible Eclipse setting or other errors.
Hi,
I have some interest in adapting apps to the eink screen, so I will try to help with this. Unfortunately, I cannot post in the dev forums yet.
When you get error installing apps via android UI, it is useful to do via "adb install" to be able to know the error cause. The message was "INSTALL_FAILED_OLDER_SDK", which I solved by lowering the android:minSdkVersion parameter in Manifest. Then, the app installed and ran fine, but didn't do the desired effect yet. I will check the code now...
---------- Post added at 02:41 AM ---------- Previous post was at 01:53 AM ----------
I see that you're trying to use enterA2Mode() for the nook (btw, there is a typo at NoRefreshEnablerActivity.java:29, it should read EINK_NOOK). I've been playing around with this some time ago when I started developing a fast e-ink drawing app for the NST, you can see it here: https://github.com/marspeople/E-Paper (WIP).
With few testing I've done, I guess the 1-bit mode (A2) setting is not applied globally: it should take effect only in the View from which it is called. I haven't investigated further to try to use it globally.
Hi marspeople,
Thanks for pointing out the type, it should read
} else if (DeviceInfo.EINK_NOOK)
Regarding the global value of mode setting. From what I understand, A2 is a permanent mode, so whatever function or app is setting the updatemode, it is kept. With the PRS-T1, it is reset by calling any stock (Sony) app. For the Nook I don't know..
Good luck in compiling, hopefully we come to a version which works on both devices. Then I can proceed to dynamically change the updatemode within an app.
Yes, the A2 mode is kept until any process resets the EPD. Using logcat, I noticed several epd_reset_region messages appearing automatically when I close your app to go back to the launcher. It seems the system overrides the EPD setting, making impossible to use A2 system-wide (at least by this method).
However, if you want A2 just for an app, calling enterA2mode() will probably work, as I used in my own app above.
Can you send me your apk?
salsichad2 said:
Can you send me your apk?
Click to expand...
Click to collapse
You mean the apk for "NoRefresh" or my drawing app?
Hi marspeople,
I would be most interested to know why the initial source code does compile ok, works on the PRS-T1 and does not install on the Nook Touch + the fixes.
With this knowledge I can write either an app to set refresh modes or within apps.
Did you succeed to compile and install on Nook?
Hi again,
in your N2EpdController.java
Code:
83: mtSetRegion.invoke(null, "aarddict", enumsRegion[region], regionParams, enumsMode[mode]);
I would like to replace the hardcoded "aarddict" by something dynamic.
What would be the correct function to infer the wanted name?
Code:
activity.class.getName()
this.getClass().toString()
.. ?
bardo8430 said:
Hi marspeople,
I would be most interested to know why the initial source code does compile ok, works on the PRS-T1 and does not install on the Nook Touch + the fixes.
With this knowledge I can write either an app to set refresh modes or within apps.
Did you succeed to compile and install on Nook?
Click to expand...
Click to collapse
Yes, sorry about the confusion, but I managed to do it, despite the A2 mode didn't work. What I did was just edit the AndroidManifest.xml, changing the android:minSdkVersion parameter to 7 (since the NST runs Android 2.1).
Good luck finding out how to set A2 mode permanently. I guess you don't have a Nook, so feel free to ask me for testing purposes.
Since the Nook A2 mode seems to be overridden when switching foreground activity, I've tried another approach with a background service which toggles A2 mode when requested by user. This way, the foreground activity isn't switched and "fast refreshing" mode works (until you change activity).
This fast refresh mode (called A2) is only possible because it uses only 1-bit depth, i.e, just black on white, meaning you can't see grayscale pictures but it's good enough for black text on white background and scrolling. I have not "created it", it is built-in from the device (you can test using the stock reader, it is activated when holding a page button). What I implemented is a way to activate and deactivate it at user will from inside any app.
Thanks to dairyknight for his N2EpdController class, which made this possible.
Thanks to bardo8430 for bringing the idea.
Thanks to AndroSS source code for screenshots used in automatic contrast.
Changelog:
01/Mar: Now when you launch the app and it is already running, it will activate NoRefresh mode. So you can also use an activation shortcut to the app using NookTouchTools (i.e. B&N's book icon at top left corner).
02/Mar: Improve activation shortcut to perform toggle between modes. Tap gestures aren't needed anymore (use "-noGestures" apk version if you don't want them).
04/Mar: Got rid of initial ghosting by redrawing the screen after activating A2.
04/Mar (2): Minor improvement of removing ghosting at screen edges.
12/Mar (Beta): Now you can adjust contrast in A2 mode. Images shouldn't be dark or black anymore if you raise the contrast a bit.
22/May: Completely redesigned version 2.0:
- Several options can be customized via settings screen.
- NoRefresh can be toggled by manual app shortcut, tap gestures or automatically according to screen animation (new).
- New App Whitelist to avoid unwanted activation in specific apps (except for manual mode).
- Background service can be launched at boot.
- Small improvements and tweaks.
- Custom app icon (finally )
06/Jun: Fix crash on empty whitelist
08/Jul: (Version 2.1)
- Automatic contrast when activating NoRefresh, according to total "brightness" of the screen (simple algorithm). This should ask you for root permission.
- Also supports manual setting in specific situations (customizable).
- Fix possible crash at startup.
26/Jul: (Version 2.2)
- Fix contrast setting behaviour
06/Dec:
- Alternative version with fixed compatibility for FW 1.2.0 available at https://github.com/marspeople/NoRefreshToggle/downloads
First Video: http://youtu.be/6pBPsyno5PY
Other Video: http://youtu.be/kBbl6egyPsQ
Another demo: http://youtu.be/5b7JjllImjM
Repository: https://github.com/marspeople/NoRefreshToggle
Great to see that it works on the Nook! Good job.
When I try to compile on Eclipse, I have to remove the below Override:
//@Override
public boolean onTouch(View v, MotionEvent event) {
otherwise I get an error: The method onTouch(View, MotionEvent) of type A2Service must override a superclass method
When I compile with this mod and run the app, nothing happens after using your gestures. Except that I tap on other icons which then try to launch other apps.
Should NoRefreshToggle keep the focus?
I have a suspicion: The PRS-T1 needs to call a function of the Sony library with extended parameters to pass the updatemode. ANY function carrying the mUpdateMode parameter would do - but it must be called. Which might be the problem here. In the used EinkListView.java, a lot of "injection" functions like below are defined.
Code:
@Override
public void scrollTo(int x, int y) {
try {
Method invalidateMethod = super.getClass().getMethod("scrollTo",
int.class, int.class, int.class);
invalidateMethod.invoke(this, x, y , mUpdateMode);
} catch(Exception e) {
e.printStackTrace();
}
But your code has neither a Listview, nor would any injection function trigger. I am afraid you would have to make the app use a ListView (or WebView).
Can you?
bardo8430 said:
Great to see that it works on the Nook! Good job.
When I try to compile on Eclipse, I have to remove the below Override:
//@Override
public boolean onTouch(View v, MotionEvent event) {
otherwise I get an error: The method onTouch(View, MotionEvent) of type A2Service must override a superclass method
When I compile with this mod and run the app, nothing happens after using your gestures. Except that I tap on other icons which then try to launch other apps.
Should NoRefreshToggle keep the focus?
Click to expand...
Click to collapse
Well, I noticed that problem of accidentally tapping unwanted widgets, I would recommend tapping on a free area of the screen. I could use an overlay button, but it would occasionally get in the way too. What do you mean by "keep the focus"?
---------- Post added at 09:13 PM ---------- Previous post was at 09:05 PM ----------
bardo8430 said:
I have a suspicion: The PRS-T1 needs to call a function of the Sony library with extended parameters to pass the updatemode. ANY function carrying the mUpdateMode parameter would do - but it must be called. Which might be the problem here. In the used EinkListView.java, a lot of "injection" functions like below are defined.
Code:
@Override
public void scrollTo(int x, int y) {
try {
Method invalidateMethod = super.getClass().getMethod("scrollTo",
int.class, int.class, int.class);
invalidateMethod.invoke(this, x, y , mUpdateMode);
} catch(Exception e) {
e.printStackTrace();
}
But your code has neither a Listview, nor would any injection function trigger. I am afraid you would have to make the app use a ListView (or WebView).
Can you?
Click to expand...
Click to collapse
Well, to capture touch events I've used a dummy View which is added to an overlay (see A2Service.java:43). Despite being an android Service instead of Activity, maybe you can instantiate your ListView there and hopefully it will work.
Thanks for the hint on the dummy view, will try.
"keep the focus"?: window manager speak, I mean that a tap stays within your app and does not act on the icons below.
bardo8430 said:
Thanks for the hint on the dummy view, will try.
"keep the focus"?: window manager speak, I mean that a tap stays within your app and does not act on the icons below.
Click to expand...
Click to collapse
Since I'm using a transparent overlay, I have to let touch events pass through, otherwise only my app would see them.
PS: I've added a demo video at a previous post.
I've been trying to improve the functionality of the app by changing from this manual toggle approach to something like: fast mode is triggered (a bit after) when user starts dragging his finger on the screen and restored when released.
However, I've been searching how to do this with no success so far. The invisible overlay that detects touch events currently is only able to capture MotionEvent.ACTION_OUTSIDE event type, which is useful to detect a tap, but can't deal with a drag. I also need that the drag is passed normally to the app below (to perform scrolling or whatever).
I've found this page (http://stackoverflow.com/questions/8073803/android-multi-touch-and-type-system-overlay) in which is proposed a solution that can detect a drag but can't pass it to the app below.
The code is now here: https://github.com/marspeople/NoRefreshToggle . I would appreciate any help from developers.
Maybe it can be run every 1 second when screen is on. I mean nook is not locked. I don't think that changing one parameter would eat battery. Is it worth a try?
Hi marspeople,
thanks again for taking this. My initial intention was to help app developers with no e-ink experience to easily adapt their code. Doing these things inside an app is much easier but needs access to the source.
See the related question on stackoverflow:
http://stackoverflow.com/questions/9391710/adapt-scrolling-swiping-to-e-ink-screens
The external app was used as a mere demonstrator to have it work on the NST and PRS-T1. Good to have a repository for it now.
marspeople said:
Ok, I think I've got it.
Since the Nook A2 mode seems to be overridden when switching foreground activity, I've tried another approach with a background service which toggles A2 mode when requested by user via a touch gesture. This way, the foreground activity isn't switched and "fast refreshing" mode works (until you change activity).
The activation gestures I'm currently using (unfortunately, it seems you can't use hardware keys using this approach) are:
- 4 "downward-right" taps (each tap must be done to the right and below the previous one) to activate (A2 mode)
- 4 "upward-left" taps to deactivate (Normal mode)
Video: http://youtu.be/6pBPsyno5PY
Here is the source code and a apk. bardo8430, I believe it would be easy to port this to the PRS-T1.
Click to expand...
Click to collapse
Noob question.
So I just install the apk and run it and I have Norefresh.
dark_hawk said:
Noob question.
So I just install the apk and run it and I have Norefresh.
Click to expand...
Click to collapse
yes, just open the norefresh app, and like the youtube video tap the screen from top left to bottom right 4 point
but i think the trade off is the screen go black&white with no grayscale (at lease for me)

[Q] Disable horizontal lines of touch screen

Hi,
The touch screen/digitizer of my Nexus 4 registers random touch inputs at the bottom horizontal line. I had some hardware issues with the USB port, which probably caused these ghost touches... It is definitely a hardware problem and renders my phone unusable. However, if I could somehow disable the system from registering touch input events from the bottom line of the screen, that would fix my problem. I am happy to give up this horizontal line so that I can use my phone again.
I am writing to the Xposed community because I think this can be realized by writing an Xposed mod. I have written some Xposed mods, so I can write it myself. But I could need some help as to where in the system to hook the touch input events to drop those from the bottom line of my screen. So far, I could only find a place to hook in Android 2.x, see the following helpful posts: http://stackoverflow.com/questions/11947653/android-key-handling-framework and http://seasonofcode.com/posts/inter...e-linux-kernel-and-the-android-userspace.html
But this propagation of input events has changed dramatically in Android 4 and the above information is not applicable anymore. I browsed the AOSP 4.x sources and tried to follow the input events but eventually gave up and thought maybe someone here just knows where to look/hook to drop input events from specific positions in the screen. The earlier the hook in the flow of input events happens, the better
Cheers!
A random idea that *might* work: hook View.class or something similar and get the stacktrace in the hooked method to find its callers. Then print that and see if you find what you want. I can't test it myself right now, but something like this might work:
Java:
StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
for (StackTraceElement stackTraceElement : stackTraceElements) {
// Why not used XposedBridge.log(…)? Because this is going to print a lot and we don't want to murder I/O.
Log.d("Xposed", "Caller: " + stackTraceElement.toString());
}
Log.d("Xposed", "—————");

Five Awesome Things You Can Do With Tasker Right Now

Just getting started with Tasker? If you're looking for some great tasks to get going on your phone, you should try these ones out first. I picked out five simple and useful profiles that you can take a gander at.
1. Keep screen on when using reading apps
Nothing is more frustrating than when you're in the middle of reading the hottest scene in Fifty Shades Of Grey and you screen times out. I'm reading here! To prevent this from happening, you can program Tasker to tell all reading apps to stay awake as long as they're open. Here is how:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Steps:
Create new task (name it “Keep screen on” or something like that).
Tap on the “+” button, select “Display” and then “Display Timeout“.
Increase the limit to your desired level and save the task.
Go to “Profile” then tap the plus icon and select “Applications“.
Choose the applications for which you want to keep the screen on.
2. Put your phone in silent mode by turning your phone upside down
Do you ever get jealous of those rich people that are able to afford phones that come with this silent feature? They just set their phone face down as they briefly make eye contact with you to make sure that you know you're inferior. Well screw those guys. You make make your own phone do this with this simple Tasker profile!
Steps:
Go to Profile , then select “State“, “Sensor” and “Orientation” in that order. Choose “Face down” from the drop down menu.
Create new task. Tap on the “+” icon , select audio then silent mode. Choose “On” or “Vibrate“.
3. Turn android lockscreen off in trusted locations
If you're like me, the Android lockscreen drives you up the wall! When I need access to my phone, I need it now. I don't want to have to put a pin in each time but if I don't then my kids will break in and find out I'm putting them up for adoption. When I'm at work this isn't an issue though because my kids are at home locked up in the basement. That's why this Tasker profile will come in handy by disabling my lockscreen in trusted locations. So now when I head in to work my phone will disable the lockscreen. Pretty dang useful.
Steps:
Entry Task
create an entry task (name it “Lockscreen OFF“) and tap the “+” button.
Select “Plugin“, “Secure Settings” and “Root actions” that order. Set “Pattern lock OFF“.
Exit Task
create an entry task (name it “Lockscreen ON“) and tap the “+” button.
Select “Plugin“, “Secure Settings” and “Root actions” that order. Set “Pattern lock ON“.
Profile
Create new. Select “State“, “Net” and “Wi-Fi connected” in that order.
Enter the SSID of your home Wi-Fi network.
Link to the “Lockscreen OFF” Task.
Long press the profile and add an exit task. Select “Lockscreen ON“.
4. Night mode or Quiet time
This one easy as crap. Your phone doesn't need to be making all this noise and using all that data at night time does it? Shut that nonsense off! This profile will save battery and give you a better sleep, which could end up giving you 4 extra years of life.
Steps:
Create a new profile and select time. Choose the desired time range (for example, from 00:00 – 06:30).
Create a new task and tap the “+” icon.
Go to “Audio” then set Silent mode ON or vibrate.
Go to “Net” and turn auto sync OFF and Wi-Fi OFF.
5. Lock phone by shaking
The sensor tasks are my personal favorites. You can trigger all kinds of actions by use the data from your sensors. For this profile you can set your screen to lock when you shake your phone. Everyone likes stuff like this and it takes literally 30 seconds to do.
Steps:
Create a new profile. Go to “Events” and then “Sensor“. Select “Shake” and enter your preferences for axis, sensitivity and duration.
Create a new task and tap the “+” icon. Click “Display” then “System lock“.
So there you have five easy profiles to get you started with Tasker. <3
Great post champ!
I have a N6P and I have a profile that is requiring a code in order to access apps like my gallery and Facebook.
Now my question is if there is a way I kan change the annoying number pad lock with the much easier fingerprint sensor?
Or a way to tell the profile to disable the code request if the phone was unlocked by the print sensor?
Thanks a head!
NesBitton said:
I have a N6P and I have a profile that is requiring a code in order to access apps like my gallery and Facebook.
Now my question is if there is a way I kan change the annoying number pad lock with the much easier fingerprint sensor?
Or a way to tell the profile to disable the code request if the phone was unlocked by the print sensor?
Thanks a head!
Click to expand...
Click to collapse
That's a good question and I think you might be the first person to run into that. I cannot find any information on how that would be possible.
Hope someone can help/direct on if this is possible. Would like to create a profile based on location and weather. If I arrive home, and it's raining and/or dark (sunset) execute a task to turn on an outside light.
pmgreen said:
Hope someone can help/direct on if this is possible. Would like to create a profile based on location and weather. If I arrive home, and it's raining and/or dark (sunset) execute a task to turn on an outside light.
Click to expand...
Click to collapse
With respect to the location part, you could try Cell Near. For the weather, a couple of months ago I was looking for something similar and found this, which may help. (reading it gave me a massive headache, so I gave up.)
pmgreen said:
Hope someone can help/direct on if this is possible. Would like to create a profile based on location and weather. If I arrive home, and it's raining and/or dark (sunset) execute a task to turn on an outside light.
Click to expand...
Click to collapse
What system are you using to control your light? I know how to do it using Z-wave and Vera + HomeBuddy + Tasker, its pretty easy to use tasker to trigger Automated Scene in Vera
You can use the method posted above to set your local weather in a variable then use this variable and either the "State --> Phone ---> Cell Near" or "Location(GPS)" condition to trigger a task that will send and intent to Homebuddy to start a Vera scene (homebuddy is an app to control your Vera scenes). So if your are connected to your local tower (or your GPS position is home) + your local weather is bad = send an intent to homebuddy that will turn on the lights.
Edit:
Here is how you do it using a Vera z-wave hub (Vera lite/2/3):
-Log in your Vera account, go to the Automation menu and create a new scene that will simply turn on the desired lights. Take note of your scene number.
-Make an account (free) at weatherunderground.com to get a user key: www.wunderground.com/weather/api/ once registered take note of your key
-Download HomeBuddy on your phone (yes I know the app is old and did not get any updated for a while but its working good to make Tasker talk to your Vera hub)
-Launch homebuddy and setup your Vera serial number, Username and Password
-Then go in Tasker and create a new task (I have named mine "Get Weather") and add the following actions in your task:
Action #1
HTTP Get
Serverort: api.wunderground.com
Path: /api/your_key/conditions/q/your_location.xml
*replace "your_key" by your weatherunderground.com key and "your_location" by your gps location. You can use Google Maps to find your GPS location. e.g: New York is 40.690917,-74.047185. By default there is a space between your latitude and longitude values when you copy it from google maps, you need to remove it. Lets say you are at New York and your key is abcdef123456789 then the Path will be: /api/abcdef123456789/conditions/q/40.690917,-74.047185.xml
This will set your %HTTPD variable to this value:
Code:
<response>
<version>0.1</version>
<termsofService>
http://www.wunderground.com/weather/api/d/terms.html
</termsofService>
<features>
<feature>conditions</feature>
</features>
[B][COLOR="Red"]<current_observation>[/COLOR][/B]
<image>
<url>http://icons.wxug.com/graphics/wu2/logo_130x80.png</url>
<title>Weather Underground</title>
<link>http://www.wunderground.com</link>
</image>
<display_location>
<full>Jersey City, NJ</full>
<city>Jersey City</city>
<state>NJ</state>
<state_name>New Jersey</state_name>
<country>US</country>
<country_iso3166>US</country_iso3166>
<zip>07303</zip>
<magic>1</magic>
<wmo>99999</wmo>
<latitude>40.690917</latitude>
<longitude>-74.047185</longitude>
<elevation>3.00000000</elevation>
</display_location>
<observation_location>
<full>NJWxNet, Jersey City, New Jersey</full>
<city>NJWxNet, Jersey City</city>
<state>New Jersey</state>
<country>US</country>
<country_iso3166>US</country_iso3166>
<latitude>40.708744</latitude>
<longitude>-74.053070</longitude>
<elevation>6 ft</elevation>
</observation_location>
<estimated></estimated>
<station_id>MNJ12</station_id>
<observation_time>Last Updated on January 16, 2:25 AM EST</observation_time>
<observation_time_rfc822>Sat, 16 Jan 2016 02:25:00 -0500</observation_time_rfc822>
<observation_epoch>1452929100</observation_epoch>
<local_time_rfc822>Sat, 16 Jan 2016 03:01:09 -0500</local_time_rfc822>
<local_epoch>1452931269</local_epoch>
<local_tz_short>EST</local_tz_short>
<local_tz_long>America/New_York</local_tz_long>
<local_tz_offset>-0500</local_tz_offset>
[B][COLOR="DarkOrange"]<weather>[/COLOR][/B][B][COLOR="SeaGreen"]Overcast[/COLOR][/B][B][COLOR="darkorange"]</weather>[/COLOR][/B]
<temperature_string>44 F (6.7 C)</temperature_string>
<temp_f>44</temp_f>
<temp_c>6.7</temp_c>
<relative_humidity>96%</relative_humidity>
<wind_string>From the NNE at 5 MPH Gusting to 11.0 MPH</wind_string>
<wind_dir>NNE</wind_dir>
<wind_degrees>32</wind_degrees>
<wind_mph>5</wind_mph>
<wind_gust_mph>11.0</wind_gust_mph>
<wind_kph>8.0</wind_kph>
<wind_gust_kph>17.7</wind_gust_kph>
<pressure_mb>996</pressure_mb>
<pressure_in>29.41</pressure_in>
<pressure_trend>+</pressure_trend>
<dewpoint_string>43 F (6 C)</dewpoint_string>
<dewpoint_f>43</dewpoint_f>
<dewpoint_c>6</dewpoint_c>
<heat_index_string>NA</heat_index_string>
<heat_index_f>NA</heat_index_f>
<heat_index_c>NA</heat_index_c>
<windchill_string>41 F (5 C)</windchill_string>
<windchill_f>41</windchill_f>
<windchill_c>5</windchill_c>
<feelslike_string>41 F (5 C)</feelslike_string>
<feelslike_f>41</feelslike_f>
<feelslike_c>5</feelslike_c>
<visibility_mi>10.0</visibility_mi>
<visibility_km>16.1</visibility_km>
<solarradiation/>
<UV>0</UV>
<precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string>
<precip_1hr_in>0.00</precip_1hr_in>
<precip_1hr_metric>0</precip_1hr_metric>
<precip_today_string>in ( mm)</precip_today_string>
<precip_today_in/>
<precip_today_metric/>
<icon>cloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_cloudy.gif</icon_url>
<forecast_url>http://www.wunderground.com/US/NJ/Jersey_City.html</forecast_url>
<history_url>
http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MNJ12
</history_url>
<ob_url>
http://www.wunderground.com/cgi-bin/findweather/getForecast?query=40.708744,-74.053070
</ob_url>
[B][COLOR="red"]</current_observation>[/COLOR][/B]
</response>
The information we need (the actual weather condition) is inside the <weather> and </weather> tags which are inside the <current_observation> and </current_observation> tags. We'll need to split everything so we end up having a variable that is simply the current weather But first we need to create another variable to replace %HTTPD because it can be overwritten by any other task using this variable.
Action #2
Variable Set
Name: %weather
To: %HTTPD
So now we can work with our own %weather variable instead of %HTTPD
Action #3
Variable Split
Name: %weather
Splitter: <current_observation>
This will create a new Variable named %weather2 which will be equal to the information present after the <current_observation>
Code:
<image>
<url>http://icons.wxug.com/graphics/wu2/logo_130x80.png</url>
<title>Weather Underground</title>
<link>http://www.wunderground.com</link>
</image>
<display_location>
<full>Jersey City, NJ</full>
<city>Jersey City</city>
<state>NJ</state>
<state_name>New Jersey</state_name>
<country>US</country>
<country_iso3166>US</country_iso3166>
<zip>07303</zip>
<magic>1</magic>
<wmo>99999</wmo>
<latitude>40.690917</latitude>
<longitude>-74.047185</longitude>
<elevation>3.00000000</elevation>
</display_location>
<observation_location>
<full>NJWxNet, Jersey City, New Jersey</full>
<city>NJWxNet, Jersey City</city>
<state>New Jersey</state>
<country>US</country>
<country_iso3166>US</country_iso3166>
<latitude>40.708744</latitude>
<longitude>-74.053070</longitude>
<elevation>6 ft</elevation>
</observation_location>
<estimated></estimated>
<station_id>MNJ12</station_id>
<observation_time>Last Updated on January 16, 2:25 AM EST</observation_time>
<observation_time_rfc822>Sat, 16 Jan 2016 02:25:00 -0500</observation_time_rfc822>
<observation_epoch>1452929100</observation_epoch>
<local_time_rfc822>Sat, 16 Jan 2016 03:01:09 -0500</local_time_rfc822>
<local_epoch>1452931269</local_epoch>
<local_tz_short>EST</local_tz_short>
<local_tz_long>America/New_York</local_tz_long>
<local_tz_offset>-0500</local_tz_offset>
[B][COLOR="DarkOrange"]<weather>[/COLOR][/B][B][COLOR="SeaGreen"]Overcast[/COLOR][/B][B][COLOR="darkorange"]</weather>[/COLOR][/B]
<temperature_string>44 F (6.7 C)</temperature_string>
<temp_f>44</temp_f>
<temp_c>6.7</temp_c>
<relative_humidity>96%</relative_humidity>
<wind_string>From the NNE at 5 MPH Gusting to 11.0 MPH</wind_string>
<wind_dir>NNE</wind_dir>
<wind_degrees>32</wind_degrees>
<wind_mph>5</wind_mph>
<wind_gust_mph>11.0</wind_gust_mph>
<wind_kph>8.0</wind_kph>
<wind_gust_kph>17.7</wind_gust_kph>
<pressure_mb>996</pressure_mb>
<pressure_in>29.41</pressure_in>
<pressure_trend>+</pressure_trend>
<dewpoint_string>43 F (6 C)</dewpoint_string>
<dewpoint_f>43</dewpoint_f>
<dewpoint_c>6</dewpoint_c>
<heat_index_string>NA</heat_index_string>
<heat_index_f>NA</heat_index_f>
<heat_index_c>NA</heat_index_c>
<windchill_string>41 F (5 C)</windchill_string>
<windchill_f>41</windchill_f>
<windchill_c>5</windchill_c>
<feelslike_string>41 F (5 C)</feelslike_string>
<feelslike_f>41</feelslike_f>
<feelslike_c>5</feelslike_c>
<visibility_mi>10.0</visibility_mi>
<visibility_km>16.1</visibility_km>
<solarradiation/>
<UV>0</UV>
<precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string>
<precip_1hr_in>0.00</precip_1hr_in>
<precip_1hr_metric>0</precip_1hr_metric>
<precip_today_string>in ( mm)</precip_today_string>
<precip_today_in/>
<precip_today_metric/>
<icon>cloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_cloudy.gif</icon_url>
<forecast_url>http://www.wunderground.com/US/NJ/Jersey_City.html</forecast_url>
<history_url>
http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MNJ12
</history_url>
<ob_url>
http://www.wunderground.com/cgi-bin/findweather/getForecast?query=40.708744,-74.053070
</ob_url>
[B][COLOR="red"]</current_observation>[/COLOR][/B]
Now we need to split it again
Action #4
Variable Split
Name: %weather2
Splitter: <weather>
Now you'll have the %weather22 variable which will be equal to the information present after the <weather> tag:
Code:
[B][COLOR="SeaGreen"]Overcast[/COLOR][/B][B][COLOR="darkorange"]</weather>[/COLOR][/B]
<temperature_string>44 F (6.7 C)</temperature_string>
<temp_f>44</temp_f>
<temp_c>6.7</temp_c>
<relative_humidity>96%</relative_humidity>
<wind_string>From the NNE at 5 MPH Gusting to 11.0 MPH</wind_string>
<wind_dir>NNE</wind_dir>
<wind_degrees>32</wind_degrees>
<wind_mph>5</wind_mph>
<wind_gust_mph>11.0</wind_gust_mph>
<wind_kph>8.0</wind_kph>
<wind_gust_kph>17.7</wind_gust_kph>
<pressure_mb>996</pressure_mb>
<pressure_in>29.41</pressure_in>
<pressure_trend>+</pressure_trend>
<dewpoint_string>43 F (6 C)</dewpoint_string>
<dewpoint_f>43</dewpoint_f>
<dewpoint_c>6</dewpoint_c>
<heat_index_string>NA</heat_index_string>
<heat_index_f>NA</heat_index_f>
<heat_index_c>NA</heat_index_c>
<windchill_string>41 F (5 C)</windchill_string>
<windchill_f>41</windchill_f>
<windchill_c>5</windchill_c>
<feelslike_string>41 F (5 C)</feelslike_string>
<feelslike_f>41</feelslike_f>
<feelslike_c>5</feelslike_c>
<visibility_mi>10.0</visibility_mi>
<visibility_km>16.1</visibility_km>
<solarradiation/>
<UV>0</UV>
<precip_1hr_string>0.00 in ( 0 mm)</precip_1hr_string>
<precip_1hr_in>0.00</precip_1hr_in>
<precip_1hr_metric>0</precip_1hr_metric>
<precip_today_string>in ( mm)</precip_today_string>
<precip_today_in/>
<precip_today_metric/>
<icon>cloudy</icon>
<icon_url>http://icons.wxug.com/i/c/k/nt_cloudy.gif</icon_url>
<forecast_url>http://www.wunderground.com/US/NJ/Jersey_City.html</forecast_url>
<history_url>
http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=MNJ12
</history_url>
<ob_url>
http://www.wunderground.com/cgi-bin/findweather/getForecast?query=40.708744,-74.053070
</ob_url>
[B][COLOR="red"]</current_observation>[/COLOR][/B]
Now we need to split one last time to wipe evertyhing after the </weather> tag to keep only the "Overcast" value:
Action #5
Variable Split
Name: %weather22
Splitter: </weather>
Now you'll have the %weather221 variable which will be equal to the information present before the </weather> tag:
Code:
[COLOR="SeaGreen"][B]Overcast[/B][/COLOR]
Now we can save this value in another variable so its safe:
Action #6
Variable Set
Name: %CURRENTWEATHER
To: %weather221
so in this example %CURRENTWEATHER = Overcast
Action #7
If
Condition: %CURRENTWEATHER doesn't match Clear
(If weather isn't clear ---> bad weather)
Action #8
Send Intent
Action: android.intent.action.VIEW
Data: homebuddy://activate?vera=<your_vera_serial_number>&<your_scene_number>
Target: Activity
replace your_vera_serial_number and your_scene_number by the correct value (don't forget to remove the <> symbols)
Action #9
End If
Now you're done. If the weather isn't clear, tasker will send an intent to homebuddy which will then send the command to your Vera to trigger the scene you have made to turn on your lights.
Now you only need to create a Profile that triggers this task based on your location either with the Cell Near function or Location function. You could also trigger the Task when our phone is connected to your home wifi (specific SSID) so the Task only runs when you are near your door (if you get wifi at the door).
Finally you might think I forgot about that "turn on the lights" at sunset thing... No need to use Tasker for that (even if that could be done). There is a simple Vera app to detect sunset and sunrise which you can use to trigger the same scene. Its called "Day or Night"
That's it, hope it will help some of you. :good:
For reference, the weather conditions that can be present between the <weather> and </weather> tags are
Code:
[Light/Heavy] Drizzle
[Light/Heavy] Rain
[Light/Heavy] Snow
[Light/Heavy] Snow Grains
[Light/Heavy] Ice Crystals
[Light/Heavy] Ice Pellets
[Light/Heavy] Hail
[Light/Heavy] Mist
[Light/Heavy] Fog
[Light/Heavy] Fog Patches
[Light/Heavy] Smoke
[Light/Heavy] Volcanic Ash
[Light/Heavy] Widespread Dust
[Light/Heavy] Sand
[Light/Heavy] Haze
[Light/Heavy] Spray
[Light/Heavy] Dust Whirls
[Light/Heavy] Sandstorm
[Light/Heavy] Low Drifting Snow
[Light/Heavy] Low Drifting Widespread Dust
[Light/Heavy] Low Drifting Sand
[Light/Heavy] Blowing Snow
[Light/Heavy] Blowing Widespread Dust
[Light/Heavy] Blowing Sand
[Light/Heavy] Rain Mist
[Light/Heavy] Rain Showers
[Light/Heavy] Snow Showers
[Light/Heavy] Snow Blowing Snow Mist
[Light/Heavy] Ice Pellet Showers
[Light/Heavy] Hail Showers
[Light/Heavy] Small Hail Showers
[Light/Heavy] Thunderstorm
[Light/Heavy] Thunderstorms and Rain
[Light/Heavy] Thunderstorms and Snow
[Light/Heavy] Thunderstorms and Ice Pellets
[Light/Heavy] Thunderstorms with Hail
[Light/Heavy] Thunderstorms with Small Hail
[Light/Heavy] Freezing Drizzle
[Light/Heavy] Freezing Rain
[Light/Heavy] Freezing Fog
Patches of Fog
Shallow Fog
Partial Fog
Overcast
Clear
Partly Cloudy
Mostly Cloudy
Scattered Clouds
Small Hail
Squalls
Funnel Cloud
Unknown Precipitation
Unknown
So you might want to add some more values than only "Clear" at action #7 cause there are other weather values where its still sunny enough outside and you don't need to turn on the lights...
You could also use AutoVera instead of homebuddy to make the bridge between your Vera and Tasker (its a tasker plugin). The advantage of using hommebuddy is that its free, not AutoVera
Thank you, you can also turn on flashlight when on dark place.
Thank you for sharing profiles.
Thank you for sharing profiles. "The knowledge is good when sharing it".
GroovyAPKs said:
If you're like me, the Android lockscreen drives you up the wall! When I need access to my phone, I need it now. I don't want to have to put a pin in each time but if I don't then my kids will break in and find out I'm putting them up for adoption. When I'm at work this isn't an issue though because my kids are at home locked up in the basement. That's why this Tasker profile will come in handy by disabling my lockscreen in trusted locations. So now when I head in to work my phone will disable the lockscreen. Pretty dang useful.
Entry Task
create an entry task (name it “Lockscreen OFF“) and tap the “+” button.
Select “Plugin“, “Secure Settings” and “Root actions” that order. Set “Pattern lock OFF“.
Exit Task
create an entry task (name it “Lockscreen ON“) and tap the “+” button.
Select “Plugin“, “Secure Settings” and “Root actions” that order. Set “Pattern lock ON“.
Profile
Create new. Select “State“, “Net” and “Wi-Fi connected” in that order.
Enter the SSID of your home Wi-Fi network.
Link to the “Lockscreen OFF” Task.
Long press the profile and add an exit task. Select “Lockscreen ON“.
Click to expand...
Click to collapse
I created a profile using your instruction but I was getting error "an error occurred while executing Pattern Lock". Root access is granted to Secure Settings
Thank you for helping us newbies with this program.... It is a little daunting at first, but help like this helps, me at least, grasp the concepts easier.
How could I go about doing your #4. Night mode or Quiet time (tho i would probably just toggle Airplane Mode)... but only for specific days? I usually stay up later on Friday and Saturday... so I wouldnt want to miss a call or text at say 11pm... but during the week (Sun-Thurs) I am in bed by 10 due to getting up pretty early. Would I really need to create the task for each day?
As an example, I would want quiet from 10pm to 5am Sun-Thurs... and 1am to 9am on Fri-Sat. I could go without Fri and Sat if necessary. I just dont see how to do a day and time profile. THANKS!
Another good - and free source of weather data is:
www.worldweatheronline.com - you can get a feed in either xml or in json... I prefer the xml one.
You need to sign up for the key, but the thing I like is you can give it a lat/long and it will tell you the nearest weather station and country - saves me looking up the google api to convert lat/long to address.
I use a loop to read splitter text from a txt file and extracting the data I want from the XML file in to a "clean" txt file. If anyone is interested I'd be happy to post the code here - it's not brilliant, very Heath Robinson.
its there anyway to toggle the nav bar from the quick settings?
NesBitton said:
I have a N6P and I have a profile that is requiring a code in order to access apps like my gallery and Facebook.
Now my question is if there is a way I kan change the annoying number pad lock with the much easier fingerprint sensor?
Or a way to tell the profile to disable the code request if the phone was unlocked by the print sensor?
Thanks a head!
Click to expand...
Click to collapse
http://forum.xda-developers.com/showthread.php?t=2679305
Regarding the keep screen on when using apps, my display time out stays at whatever time I set it at in Tasker. Is there a way to have it revert back to my original settings after the app is closed?
Edit: Oh nvm, new to Tasker and didn't know I had to add the Exit part!
jlang11 said:
Thank you for helping us newbies with this program.... It is a little daunting at first, but help like this helps, me at least, grasp the concepts easier.
How could I go about doing your #4. Night mode or Quiet time (tho i would probably just toggle Airplane Mode)... but only for specific days? I usually stay up later on Friday and Saturday... so I wouldnt want to miss a call or text at say 11pm... but during the week (Sun-Thurs) I am in bed by 10 due to getting up pretty early. Would I really need to create the task for each day?
As an example, I would want quiet from 10pm to 5am Sun-Thurs... and 1am to 9am on Fri-Sat. I could go without Fri and Sat if necessary. I just dont see how to do a day and time profile. THANKS!
Click to expand...
Click to collapse
You can add a trigger condition (for example day of the week) by long-pressing the initial trigger condition in the profile screen (see screenshots).
In the given example, long-press the Display Off trigger(see screenshot #1) and you will be prompted with the popup menu as seen in screenshot #2.
You can now add "Day" as trigger condition and "Time" for specific time intervals.
This way you can set up two Quiet Hours profiles, one for the weekend and one for working days, for example Quiet Hours Working and Quiet Hours Weekend.
orville87 said:
You can add a trigger condition (for example day of the week) by long-pressing the initial trigger condition in the profile screen (see screenshots).
In the given example, long-press the Display Off trigger(see screenshot #1) and you will be prompted with the popup menu as seen in screenshot #2.
You can now add "Day" as trigger condition and "Time" for specific time intervals.
This way you can set up two Quiet Hours profiles, one for the weekend and one for working days, for example Quiet Hours Working and Quiet Hours Weekend.
View attachment 3678947 View attachment 3678948
Click to expand...
Click to collapse
Awesome!! Ill give it a try tonight after work. Thank you!
I did number 3 and it worked brilliantly for about a day, then it just turned my lockscreen off even when I'm not connected to my wifi. I realised that at some point I had lost root so I restored that and hoped that would fix it, but I still cant get it to go again. I've looked over the settings over and over again and can't see anything wrong. Any ideas? Its like it doesn't run the end task of turning the lockscreen back on. Even my settings say lockscreen is set on swipe.
I followed the tutorial on youtube, turning on wifi when triggered by location. But when I tap the gps icon at the top of the tasker screen the map doesnt move. It is stuck not doing anything. Location icon on the settings is ON. I NOTICE that the cursor is on the box that says latitude then longtitude on the opposite side. Looks like it does the contrary. Instead of locating me it looks like tasker want me to specify the latitude and longtitude of my location.
Using moto e 2nd gen marshmallow. I dont see that it requires root access.
MrMosoani said:
I followed the tutorial on youtube, turning on wifi when triggered by location. But when I tap the gps icon at the top of the tasker screen the map doesnt move. It is stuck not doing anything. Location icon on the settings is ON. I NOTICE that the cursor is on the box that says latitude then longtitude on the opposite side. Looks like it does the contrary. Instead of locating me it looks like tasker want me to specify the latitude and longtitude of my location.
Using moto e 2nd gen marshmallow. I dont see that it requires root access.
Click to expand...
Click to collapse
Using location to trigger events can be power intensive. Android, by default, scans for wifi even when it is off. I have profiles similar to what you're trying to do. But i have mine set up to trigger when the wifi specified is detected. It's "wifi near"
Thanks. But how come he was able to make it work in the tutorial? It was his first basic profile to turn On wifi on the phone when he reached home.

Categories

Resources