I have the app Tasker, I want to know if there is a way I can create a task that changes the state of the lock screen setting "lock screen when power button pressed" from on to off and vice versa?
I'm not sure if the following will be a perfect match for you, but you always can adjust it once you've got the idea. In my example, I will refer to Tasker only: not having worked with the Secure Settings myself, I can only tell things about it from the hear-say and what I've read.
Basic Tasker knowledge assumed:
Wifi Connected, parameter:
SSIDset to your WiFi's SSID
This is with plain Tasker, and should solve half of your problem: When connected to the specified WiFi, and the Display is turned off, turn off Keyguard. As soon as you turn on the display, the condition is no longer met -- and Keyguard would automatically be activated again. Problem will be: if you do not take any immediate action, that probably locks your screen again (first action of keyguard). To prevent this, you could try adding an exit task:
- Exit Task:
Wait, parameter is the time interval (start with e.g. 10s)
This would cause the Keyguard re-activation to be delayed by the given time interval. I did not try this -- it might very well be that keyguard still would lock the device, even though you already might do something in another app. But you have already noted the "footnote sign", so let's go for that:
1 Instead of handling Keyguard directly, let Secure Settings do that. I know it has the ability to e.g. have Keyguard only come up once (initially) when a condition is met. This would simplify things greatly: the Task then would be
Secure Settings, and the Secure Settings parameter should be to set Keyguard as described: "only needed once initially, then no more until the condition is no longer met". Also drop the "Display off" condition: when the display is off, you cannot unlock it either (you see where your problem most likely was). So it should work as you have intended -- after the first unlock.
Not exactly what you wanted (one-time unlock is still needed), but almost. The Exit Task would not be required in this case, as Tasker automatically reverts back once the condition is no longer met. Play a little with this, maybe Secure Setting even allows for something better.