Akshit Agrawal
Published © GPL3+

Home Automation with Raspberry Pi 3

Home automation using Raspberry Pi 3B and OpenHAB. [Optional] We will be using Google Home (or Google Assistant) to control the relays.

IntermediateFull instructions provided4 hours16,684
Home Automation with Raspberry Pi 3

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Google Home Mini
Optional - We can also use Google Assistant on a Smartphone
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Relay Module (Generic)
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian
IFTTT
Assistant SDK
Google Assistant SDK

Story

Read more

Schematics

Raspberry Pi 3 GPIO

Code

home.rules

Java
import org.openhab.model.script.actions.*
import org.openhab.core.library.types.*
import java.util.*

rule "voice"

when
Item VoiceCommand received command
then
var String command = VoiceCommand.state.toString.toLowerCase
logInfo("Voice.Rec","VoiceCommand received "+command)

if (command.contains("turn on fan") || (command.contains("turn on the fan"))) {
fan.sendCommand(ON)
}
else if (command.contains("turn off fan") || (command.contains("turn off the fan"))) {
fan.sendCommand(OFF)
}
else if (command.contains("turn off light") || (command.contains("turn off the light"))) {
light.sendCommand(OFF)
}
else if (command.contains("turn on light") || (command.contains("turn on the light"))) {
light.sendCommand(ON)
}
else if (command.contains("turn on night lamp") || (command.contains("turn on the night lamp"))) {
night_light.sendCommand(ON)
}
else if (command.contains("turn off night lamp") || (command.contains("turn off the light lamp"))) {
night_light.sendCommand(OFF)
}
else if (command.contains("turn on exhaust fan") || (command.contains("turn on the exhaust fan"))) {
exhaust.sendCommand(ON)
}
else if (command.contains("turn off exhaust fan") || (command.contains("turn off the exhaust fan"))) {
exhaust.sendCommand(OFF)
}
end

home.sitemap

Java
sitemap home label="Smart Home"
{
       Frame label="My Room"
       {
               Switch item=fan
               Switch item=light
               Switch item=exhaust
               Switch item=night_light
       }
}

Credits

Akshit Agrawal

Akshit Agrawal

1 project • 5 followers

Comments