What I needed:
Android phone with NFC (for NFC tag sleep) and NFC Task Launcher (NFCTL) or Tasker to create a location task and NFC tag task. I think any other smartphone with similar software should work as well.
Wi-Fi turned on on smartphone.
Dummy switch ’home’ and ’sleep’.
What I did:
I created a location task in NFCTL (you do not need NFC tags for NFCTL to work).
When connected to my home Wi-Fi run a certain URL in the background.
You can run an URL to switch a switch on or off with Domoticz. This way you can have certain software switch some appliances on or off with certain triggers (location, nfc etc.).
First I added a dummy switch which I called ‘Thuis’ (Home). The IDX number of the switch can be found on the devices page. In my example I use IDX 40.
I must note that the URL trigger only worked when I used the basic authentication method.
The URL I used is:
Code: Select all
http://(username:password)@(ip-address)/json.htm?type=command¶m=switchlight&idx=(switch ID number)&switchcmd=On&level=0
http://test:welcome@192.168.1.1/json.htm?type=command¶m=switchlight&idx40&switchcmd=On&level=0
If you are using a DNS service you must route the correct port and add the port number in the url. For example domoticz.mydns.com:8080 instead of the internal IP when you want to trigger a switch over the internet.
At this point you can test your URL. When you try this in your browser you should receive the message { "status" : "OK", "title" : "SwitchLight" }. If you want to turn the switch off, simply change On to Off in the URL (case sensitive). This way you can turn all your switches on and off.
Next I created the Wi-Fi location task called ‘Thuis’ (home) in NFCTL. Simply add a task when connected to your home Wi-Fi, open URL in background and then use the example URL with your own credentials.
If you did it right NFCTL should give you the status last task: Thuis. If you check the dummy switch in Domoticz it should be on.
Now simply create a task when you are away from home. Mine is called ‘Niet thuis’ (not at home). Here you use the same URL but with Off instead of On.
Again if you did this right the dummy switch should turn off when you disconnect your Wi-Fi. Keep in mind when you do this you are not connected to your network so internal IP-addresses will not work. You must route the correct port and external IP or DNS.
Test the task simply by turning your Wi-Fi on your smartphone on and off to see if the switch turns on and off correctly.
Once you have this running you can create events upon switching on your dummy switch.
I also have an NFC tag on my bedside which I use to set my phone’s alarm and sounds settings to silent when I go to sleep. You can then create a second dummy switch in Domoticz which I called ‘Slaap’ (Sleep). In the NFC tag I added the task to open a URL in the background like the one we used before but this time for the dummy switch with the corresponding IDX.
Some NFC tags can store multiple tasks so you can also create a ’Wakker’ (Awake) task. The tags I use can do this so I add the second task to restore the sound settings to normal and open the URL witch turns the dummy switch off. This way when I go to bed I swipe my phone over the tag to execute the ‘Slaap’ task and when I am awake I swipe it again to execute the ‘Wakker’ task.
Now you can have an event when the dummy switch is turned on.
I am still playing around with the possibilities but what I have so far is the following blocky example.
There are 3 blocky events in the same example.
The first one is used to turn the living room light on if I’m home and not asleep and it is past sunset.
The second one turns all the lights off (I created a group with all the lights) if I’m home and when I go to sleep. This way the light will only turn on when it is dark and turn off when I swipe my phone over the NFC tag.
The third one simply switches off the living room light when I leave the house.
In the winter when I wake up before sunrise this way the living room light turns on when I am awake but turns off when I leave the house.
Even if you do not want any lights turned on or off you can still use the Wi-Fi / Dummy switch method to let your Domoticz know when you are home.