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

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 08-07-2019
Viewed: 194 times