Note: I want to do home automation with Home Assistant + Raspberry Pi + sensor # 1

What is Home Assistant?

https://home-assistant.io/

An open source home automation platform made in Python. There seems to be something called OpenHAB in this area.

By freely combining functions called "components", each component can control and automate the corresponding device. You can also display the status on a web page and control it from there.

Corresponding components includes IoT devices such as electric shutters that are unlikely to be available in Japan.

It is said that it supports such things. Also, it seems to support data acquisition from command line standard output (Command line sensor etc.), control from command line (Command line switch etc.), or creation of custom components using Python, so this kind of thing Those who are accustomed to the command will not be in trouble.

Installation

https://home-assistant.io/getting-started/

Raspberry Pi must be Raspbian Jessie. Installation from PyPI completes. https://home-assistant.io/getting-started/installation-raspberry-pi/

At the first startup, it automatically gets the Python module required by the component, or gets the current location from the IP address (used by the Sun (sunrise / sunset) component, etc.).

If you want to start automatically, refer to Launch Home Assistant on Boot. For Raspbian Jessie, set by Systemd method.

If you want to boot in demo mode

$ hass --demo-mode

Start with. After booting, you can access the control web page by accessing http: // (IP address): 8123. Also, if you add the --open-gui option at startup, the browser will open automatically after startup. It feels like Android material design, and you can actually operate it from the browser screen of your smartphone.

homeassistant_demo_mode.png

I feel like the demo screen is a little overloaded.

Setting

https://home-assistant.io/getting-started/configuration/

A .homeassistant directory is created in the home directory of the invoking user, and a configuration.yaml file is created in it. Settings are described in YAML. The time zone etc. has already been set from the current location information obtained from the IP address at the first startup, but you can change it. For details, see the Configuration page above and the details page for each component.

After changing the settings, go to http: // (IP address): 8123 and click "Configuration" on the side panel. Click the [Configuration.yaml]-[CHECK CONFIG] button to check the setting description. If there are no problems, click [RELOAD CORE] to reflect the settings.

Initial setting items

homeassistant:
  # Name of the location where Home Assistant is running
  name: Home
  # C for Celcius, F for Fahrenheit
  temperature_unit: C
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  time_zone: Asia/Tokyo
  #latitude
  latitude: [abridgement]
  #longitude
  longitude: [abridgement]

#Login password
http:
  api_password: [abridgement]

# Track the sun
sun:

Device registration

Register your BME280 (temperature / humidity / barometric pressure sensor) and CPU temperature as Command line sensor. Also, get the CPU clock with CPU speed sensor. For acquisition from BME280, slightly modify Python script published by Switch Science, operate in Force mode, and operate at the temperature specified by the command line option. , Humidity, and barometric pressure were modified to be displayed.

sensor:
  - platform: command_line
    name: "BME280 temperature"
    command: "/home/pi/sbin/bme280_sample.py -T"
    unit_of_measurement: "°C"
  - platform: command_line
    name: "BME280 pressure"
    command: "/home/pi/sbin/bme280_sample.py -P"
    unit_of_measurement: "hPa"
  - platform: command_line
    name: "BME280 humidity"
    command: "/home/pi/sbin/bme280_sample.py -H"
    unit_of_measurement: "% RH"
  - platform: cpuspeed
    name: 'CPU speed'
  - platform: command_line
    name: "CPU Temperature"
    command: "cat /sys/class/thermal/thermal_zone0/temp"
    unit_of_measurement: "°C"
    value_template: "{{ value | multiply(0.001) }}"

Group settings

When the component is registered independently, it is displayed in the form of a round icon-shaped "badge" at the top of the control Web page. By grouping related components together, it can be displayed in a "card" format on the control Web page, and switches etc. can be controlled collectively. There is also a setting to group tabs. (view: yes) For the components to be grouped, describe the service name (entity_id) of each component in a list.

group:
  Weather:
    - sun.sun

  In the room:
    - sensor.bme280_temperature
    - sensor.bme280_pressure
    - sensor.bme280_humidity

  Raspberry Pi 2:
    - sensor.cpu_speed
    - sensor.cpu_temperature

And the display looks like this.

homeassistant.png

Click the set component to display details such as graphs.

homeassistant_humidity.png

Future goals

--Trial of other components --Automation settings using the acquired data --Linkage with various Web services via IFTTT --Creating custom components --Data acquisition from remote sensor

Recommended Posts

Note: I want to do home automation with Home Assistant + Raspberry Pi + sensor # 1
I want to do ○○ with Pandas
Make a note of what you want to do in the future with Raspberry Pi
[ML Ops] I want to do multi-project with Python
I talked to Raspberry Pi
When I tried to do socket communication with Raspberry Pi, the protocol was different
Easy introduction to home hack with Raspberry Pi and discord.py
I want to disable interrupts on Raspberry Pi (≒ DI / EI)
I tried using the DS18B20 temperature sensor with Raspberry Pi
I want to debug with Python
I tried to automate the watering of the planter with Raspberry Pi
I made a web server with Raspberry Pi to watch anime
I want to run the Python GUI when starting Raspberry Pi
I want to do a full text search with elasticsearch + python
I want to pip install with PythonAnywhere
I want to analyze logs with Python
I want to play with aws with python
Improved motion sensor made with Raspberry Pi
I want to make an automation program!
Use PIR motion sensor with raspberry Pi
A memo to simply use the illuminance sensor TSL2561 with Raspberry Pi 2
I tried to make a traffic light-like with Raspberry Pi 4 (Python edition)
I connected the thermo sensor to the Raspberry Pi and measured the temperature (Python)
I want to do Dunnett's test in Python
I want to use MATLAB feval with python
I want to analyze songs with Spotify API 2
I tweeted the illuminance of the room with Raspberry Pi, Arduino and optical sensor
I want to mock datetime.datetime.now () even with pytest!
I want to display multiple images with matplotlib.
I want to knock 100 data sciences with Colaboratory
I tried L-Chika with Raspberry Pi 4 (Python edition)
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
I want to be an OREMO with setParam!
I want to analyze songs with Spotify API 1
I want to use Temporary Directory with Python2
I don't want to use -inf with np.log
#Unresolved I want to compile gobject-introspection with Python3
[For beginners] I made a motion sensor with Raspberry Pi and notified LINE!
I want to use ip vrf with SONiC
I want to solve APG4b with Python (Chapter 2)
I want to do pyenv + pipenv on Windows
I want to start over with Django's Migrate
I tried to create a button for Slack with Raspberry Pi + Tact Switch
I want to write to a file with Python
Connect to MySQL with Python on Raspberry Pi
I want to save a file with "Do not compress images in file" set in OpenPyXL
I want to be notified of the connection environment when the Raspberry Pi connects to the network
I want to convert an image to WebP with lollipop
I want DQN Puniki to hit a home run
I want to detect unauthorized login to facebook with Jubatus (1)
Using the digital illuminance sensor TSL2561 with Raspberry Pi
I want to transition with a button in flask
Easy IoT to start with Raspberry Pi and MESH
I want to handle optimization with python and cplex
I want to climb a mountain with reinforcement learning
Try to visualize the room with Raspberry Pi, part 1
Links to do what you want with Sublime Text
I want to inherit to the back with python dataclass
I want to work with a robot in python.
I want to split a character string with hiragana
I want to AWS Lambda with Python on Mac!