NFC stands for Near field communication, they are passive devices they draw power from the devices that they are in contact in (your smartphone) when in close proximity.
These tags, that don’t require a power source can be positioned anywhere in your home to trigger smart devices. Your smart device needs to be NFC enabled.
My home automation platform of choice is home assistant, an open source platform that can run on light weight micro computers like a raspberry PI.
To add NFC tags into Home Assistant follow this video:
Table of Contents
Automations
All automations have been created with version 2020.12 of Home Assistant, I have my automations in separate yaml files under a custom folder automations/
Story Time
This automations allows my Google Mini to read (play a recording of) a book for my son’s bedtime routine.
This allows people that can’t be at home, like Grandparents due to social distancing to record their voice while reading the book and allow Google to play the recording at the right time.
A little NFC tag can be placed on the book and a parent can scan the tag and activate the automation. Before you do this you will need to integrate the google speaker into home assistant. This can also work with other speakers like Alexa / Sonos but the code will need to change slightly.
You will need to replace your TAG ID in the automations and the entity ids of your devices and the name of the file
You will need to upload the file in HA under www folder
alias: Read Bear and Hare
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service : media_player.volume_set
data:
entity_id: media_player.kitchen_speaker
volume_level: 0.2
- service: media_player.play_media
data:
entity_id: media_player.kitchen_speaker
media_content_id: 'http://IP_ADDRS:8123/local/bear_and_hare.mp3'
media_content_type: 'audio/mp3'
Garage Opener
This is useful when you have forgotten your key fob, you can open your garage door from the inside of your car!
alias: Tag Garage Door is scanned
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: switch.turn_on
data:
entity_id: switch.shelly1_garage_door
Turn on Light Strip
Scanning this tag will turn on the LED light strip behind the Monitor, I’m setting this to red, but feel free to find the right colour combination.
alias: Tag Office Light is scanned
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: light.toggle
entity_id: light.office_light_strip
data:
transition: 60
rgb_color:
- 255
- 100
- 100
brightness_pct: 47
mode: single
Medicine Cabinet
We need to setup three components, the first component is the input boolean, this will let me know if the I have taken the medication. It needs to reset once a day as this is daily. An Input boolean has two values, ON or OFF (default is OFF) when you set this up.
Input Boolean (configuration.yaml)
#Input Boolean
# Example configuration.yaml entry
input_boolean:
medicine_taken:
name: Have I taken my Medicine Today
icon: mdi:pill
Toggle Medicine Taken to ON
This automation is going to scan the tag and confirm you have taken the medication.
alias: Taken Medicine
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: input_boolean.turn_on
data:
entity_id: input_boolean.medicine_taken
Turn boolean off each day at midnight past one minute
alias: Reset Daily Medications
trigger:
- platform: time
at: "00:00:01"
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.medicine_taken
Disarm the Alarm
alias: Disarm Alarm
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: alarm_control_panel.alarm_disarm
data:
entity_id: alarm_control_panel.home_alarm
code: !secret alarm_code
Watering the Plant
You might not remember the last time you gave water to the plant, by scanning this NFC tag you can store the date and time in home assistant
alias: Plant has been watered
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: input_datetime.set_datetime
data:
entity_id: input_boolean.plant_last_watered
timestamp: "{{ now().timestamp() }}"
Garden Light
It is common that the light for your garden is on the inside of the property and that to turn on the garden lights you would need to go back in the home. If you hide one of these NFC tags under your garden table, you can toggle it on or off without moving from your chair.
alias: Tag Garden Light is scanned
trigger:
- platform: tag
tag_id: TAG_ID
action:
- service: switch.toggle
entity_id: switch.sonoff_dining1
mode: single