Warning: Declaration of Db::query($query) should be compatible with mysqli::query($query, $resultmode = NULL) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 29

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Paginator has a deprecated constructor in /var/www/u1300519/data/www/acoptex.com/_lib/class.Paginator.php on line 13

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Deprecated: Function get_magic_quotes_runtime() is deprecated in /var/www/u1300519/data/www/acoptex.com/_lib/CacheLite/Lite.php on line 757

Warning: Cannot modify header information - headers already sent by (output started at /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php:0) in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 168

Warning: session_start(): Cannot start session when headers already sent in /var/www/u1300519/data/www/acoptex.com/_config/config.php on line 169

Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 92

Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64

Warning: mysqli_fetch_array() expects parameter 2 to be int, string given in /var/www/u1300519/data/www/acoptex.com/_lib/class.Db.php on line 64
jobs.html_title
0

members

Easy Raspberry basics: Project 29c Raspberry PI 3 model B board - Creating automations in Home Assistant

of Acoptex.com in Raspberry Pi 3

Raspberry basics: Project 29c

Project name: Raspberry PI 3 model B board - Creating automations in Home Assistant

Tags: Raspberry, Raspberry PI 3 model B board, vers 1.1, v 1.1, Home assistant, creating automations in Home Assistant

Attachments: copy_configuration.yaml , automations.yaml

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Raspberry PI 3 model B 1 pc

2. Micro SD card and SD card adapter 1 pc

3. Micro USB power supply (2.1 A, max 2.5 A) 1 pc

4. USB keyboard 1 pc

5. USB mouse 1 pc

6. TV or PC monitor 1 pc

7. HDMI cable 1 pc

8. Jumper cables M-M, F-M

9. Resistor 2 pc (220 Ohm)

10. LED 2 pcs (green and red)

11. Breadboard 1 pc

General

We will learn how to create automations in Home Assistant with Rasprberry Pi. We are going automatically turn on and off the Green and Red LEDs.

Understanding the Home Assistant

You can read more about it here.

Automations in the Home Assistant

You can make automations directly in the configuration.yaml file or in the automations.yaml file or in the Home Assistant User interface.

If you want to make automations in the Home Assistant User Interface, go to Configuration -> Automation and click the plus sign in the right bottom corner. 

In the Automation tab you have several sections: New Automation, Triggers, Conditions and Action.

In Home Assistant, the automation have 3 parts:

 

  • trigger: this is what happens for the automation to start
  • condition: these are the conditions that have to be met for the automation to continue
  • action: this is what happens when the automation takes place

 

 

Understanding the Raspberry PI 3 model B

The Raspberry Pi 3 is the third-generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B in February 2016.

Specification:

  • Quad Core 1.2GHz Broadcom BCM2837 64bit CPU
  • 1GB RAM
  • BCM43438 wireless LAN and Bluetooth Low Energy (BLE) on board
  • 40-pin extended GPIO
  • 4 USB 2 ports
  • 4 Pole stereo output and composite video port
  • Full size HDMI
  • CSI camera port for connecting a Raspberry Pi camera
  • DSI display port for connecting a Raspberry Pi touchscreen display
  • Micro SD port for loading your operating system and storing data
  • Upgraded switched Micro USB power source up to 2.5A

Signals and connections of the Raspberry PI 3 model B


Wiring

Step by Step instruction

We recommend using a high-performance SD card for increased stability as well as plugging your device into an external display to see the default application booting up.

We assume that you have Windows 10 installed on your PC and empty micro SD card 32 GB with SD card adapter.

Please see the  copy_configuration.yaml , automations.yaml files for your reference.

1. Do wiring

2. Installing Hass.io

It was explained in Raspberry basics: Project 29a Raspberry PI 3 model B board - Home assistant for beginners

3. Adding integration Raspberry Pi GPIO switch

  1. To add integration to the configuration.yaml file go here and search for the Raspberry Pi GPIO switch.
  2. Just type Rapsberry Pi GPIO.
  3. Click on Raspberry Pi GPIO switch.
  4. Copy the entry given to your configuration.yaml file.
    # Example configuration.yaml entry
    switch:
      - platform: rpi_gpio
        ports:
          11: Lamp Bedroom
          12: Lamp Kitchen
    Copy this entry to your configuration.yaml file. In this entry we are adding two buttons that will control the Raspberry Pi GPIOs 11 and 12. We are calling them Green LED and Red LED. You can call them in different way and select other GPIOs too.
  5. If you have Configurator installed in Home Assistant skip installation notes. Go to Hass.io -> ADD-ON STORE  and select Configurator.
  6. Click on Install.
  7. Click on Start.
  8. Click on Open Web GUI.
  9. The configurator GUI opens. Go to Browse FileSystem.
  10. Go to config folder and find the configuration.yaml file.
  11. Save your configuration.yaml file.
  12. In the Home Assistant User Interface, go to Configuration->General and click the CHECK CONFIG button. This will check the syntax of the configuration.yaml file. When, it’s done, you get a Valid! message if everything is good with the syntax.
  13. Go to Server Management field (Configuration->General) and click on RESTART.
  14. Wait for the system to restart. 
  15. Go to Overview.
  16. Click on dots in top right corner. Select Configure UI.
  17. Click on plus in orange circle to ADD CARD.
  18. Click on ENTITIES.
  19. Type the title, make sure that Show header toggle? deselected, select Entity from dropdown menu - Green LED and Red LED. Click on SAVE.
  20. If you want to EDIT the card click on EDIT. If you want to go back to normal mode click on X.
  21. You should see two new buttons on the interface called Green LED and Red LED. Click on those buttons to turn the LEDs on and off.
  22. Before proceeding with the automation let's check the Developer tools in the Home Assistant.
  23. Select the States under the Developer Tools. You can test setting the state of a device, see the ID of all your entities here. For example, your Green LED and Red LED buttons have the following IDs, state and attributes:
  24. Select the Services under the Developer Tools. You can call a service from a component and test it, to see what happens here. We are going to test a service that turns the Red LED on. Select switch.turn_on in the Service field. Select switch.red_led in the Entity field. When you select  parameters in the fields the parameters for that event (switch.turn_on) appear in Service data field:{  "entity_id": "switch.red_led"}. If you click on Call service button the Red LED will be on. This is just a method to check the service you want to call.
  25. Go to Configuration->Automation->New Automation. Give a name to your automation. For example, New Automation.
  26. We will trigger the automation (Red LED will be on) at specific time (16:40). Select Time in the Trigger Type field. In the At field type 16:40. Click on ADD TRIGGER button.
  27. Select Call service in the Action type field. Select switch.turn_on in the Service field. Paste the following to Service data field: {  "entity_id": "switch.red_led" }. Click on ADD ACTION button. As you noticed it is the same information which we had in the Services under the Developer Tools.

  28. Save the automation by clicking on yellow circle at the bottom right corner.
  29. To turn the Red LED off at 16:40, for example, you need to add another automation, change the time and call the service switch.turn_off.

Summary

We have learnt how to create automations in Home Assistant with Rasprberry Pi. 

Libraries in use

  • None

Resources

  • See on the begining of this project


Other projects of Acoptex.com
Medium Basics: Project 083w Sipeed Maixduino board - Using PlatformIO IDE of Acoptex.com in Sipeed Maixduino 08-08-2019
Medium Basics: Project 083e Sipeed Maixduino board - Uploading MaixPy of Acoptex.com in Sipeed Maixduino 04-08-2019
Medium Basics: Project 083f Sipeed Maixduino board - Using MycroPython of Acoptex.com in Sipeed Maixduino 04-08-2019

jobs.published_at
jobs.viewed