I have talked about Smart NavBar actions for WhatsApp before and the time and location contexts, it’s time to try something new. Tasker 5.7 comes with native NFC actions, so there is no need for plugins any more. This got me the idea to link the Smart NavBar series and present you NFC enabled smart lights controller available in the NavBar. You will be able to scan NFC to display controllable devices in each room and control it directly from the NavBar.
NFC lights controller
I streamlined the original version of my profile to make it easy to add new rooms and devices. Now you can simply scan a new NFC tag to log in to another room or scan the same one to log out. This Smart NavBar action will allow you to keep store the state of the lights (and other devices) and display it via icons.
Getting NFC tags ready
To log in to a room you have to prepare your NFC tag first. Scanned tags return %evtprm() array that stores the tag’s ID and the payload. I created a simple task that you can use to write your room names. Make sure you note the values as you will need to be consistent.
Just hoover the phone over the NFC tag and run the task with the modified name.
NFC control profile
The profile consists of 2 parts. One section logs you in (when you are not logged in or when you are logged in to another room), while the other one logs you out from the room. Based on the %evtprm2 value and the state of the %NBroomTag variable one of the following will be performed:
Log in to a room
Apart from nice Flash actions telling you about the progress, there are 3 actions crucial to this operation. First, I’m going to set the room name in %NBactiveTag (office, kitchen, none)- this is used to keep track of the rooms that you are in. It’s worth noting that I have added the %NBactiveTag !~R none|%evtprm2 to run this task if you simply scan another NFC tag without logging out.
Then I’m going to perform the action which starts with NB NFC %evtprm2 (room name). Which has the correct NavBar task associated with it.
Lastly, I will change the value of the %NBroomTag to off – as next time I scan the same NFC tag, I want the other condition to run instead.
Log out of the room
To reset your Smart NavBar, you have to sign off first by setting the %NBactiveTag to none. then use the NavBar action to set a default NavBar and change the value of the %NBroomTag to on so the next time the other condition would run.
NFC controller in the NavBar
For each device in the room, I’m running the HTTP Get request. Since my devices are flashed with custom software and have REST API available. You can use sonoff based Tasmota or AFE Firmware on all compatible ESP8266 devices.
- Obtain the status with HTTP Get for each device (vary how, based on your device)
- Save the output to file
- Read the file as JSON with AutoTools
- Update the %NBofficestate(x) variable for each device in the room
Then set the NavBar with composed data. My NavBar config looks like this: task(NB Bench Toggle %NBofficestate1)[1.0],task(NB Lamp Toggle %NBofficestate2)[1.0]
NB Toggle on/off
For each device, I have to create two ON and OFF task which will contain the correct HTTP request, the correct name and the correct icon associated with the task. Since the NavBar looks for the task with the %NB (device name) %NBofficestate(x) then I have to make sure the name is consistent.
Adding more room and devices
If you want to add another room, all you have to do is to replicate the NB NFC office and modify the HTTP Get requests. You have to remember to create the ON and OFF tasks for each new device in the room. I could possibly do this with arrays, but this would increase the complexity significantly.
Smart NavBar integration
This is a stand-alone version of the Smart NavBar actions. Once I created the standalone versions for each NavBar Task I will show you how to integrate it together. You can read the tutorial about this now!
Conclusion
The Smart NavBar NFC controller shows you how dynamic the NavBar can be. If you are bothered, you can even run the NB NFC (room name) task every minute to get accurate icon changes. You can connect any IoT device using HTTP request, MQTT or NodeRED. While this all is done in a local mode, you could also create access from the WAN. Take a look at other NavBar actions I have created. Let me know how would you use it in this Reddit thread.
Project Download
Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.