Migrate two more blog posts

This commit is contained in:
yehor 2025-05-20 12:22:58 +03:00
parent 3aee2ea61b
commit 7445bd02a2
9 changed files with 190 additions and 0 deletions

View File

@ -2,6 +2,7 @@
slug: making-a-wifi-enabled-smart-air-humidifier slug: making-a-wifi-enabled-smart-air-humidifier
title: "DIY Smart Appliance: Making a WiFi-enabled smart air humidifier from a regular one" title: "DIY Smart Appliance: Making a WiFi-enabled smart air humidifier from a regular one"
tags: [smart home, DIY, ESP8266, ESPHome, humidifier, Wemos D1 mini, WiFi] tags: [smart home, DIY, ESP8266, ESPHome, humidifier, Wemos D1 mini, WiFi]
image: /img/blog/2018/06/001.jpg
--- ---
So there was a simple air humidifier… Actually, this post is a good example of how to make your regular boring home appliance a little smarter. The main part of my humidifier will be the Wemos (or Lolin) D1 mini board based on the ESP8266 WiFi chip. So there was a simple air humidifier… Actually, this post is a good example of how to make your regular boring home appliance a little smarter. The main part of my humidifier will be the Wemos (or Lolin) D1 mini board based on the ESP8266 WiFi chip.

View File

@ -0,0 +1,52 @@
---
slug: smart-doorbell-with-xiaomi-aqara-button-and-google-home
title: "Smart doorbell with Xiaomi Aqara button and Google Home"
tags: [smart home, Aqara, Xaomi, Home Assistant]
image: /img/blog/2019/02/doorbell.jpeg
---
So I have several Xiaomi Aqara buttons. Today I want to explain how to use this button as a smart doorbell that will play sound to your Google Home device through Home Assistant.
<!-- truncate -->
All my Aqara ZigBee devices are connected to Home Assistant via [ConBee II](https://phoscon.de/en/conbee2) and [deCONZ](https://www.home-assistant.io/integrations/deconz).
First of all, lets create a script that will be executed when the button is pressed. In your `scripts.yaml`:
```yaml
doorbell:
alias: Doorbell
sequence:
- data:
entity_id: media_player.googlehome4615 #Your Google Home device
service: media_player.turn_on
- delay: 00:00:03 #To make sure we are connected to Google Home
- data:
entity_id: media_player.googlehome4615 #Your Google Home device
media_content_id: https://your.homeassistant.domain:8123/local/doorbell.mp3
media_content_type: music
service: media_player.play_media
- delay: 00:00:05 #The same as doorbell.mp3 file ledgth
- data:
entity_id: media_player.googlehome4615
service: media_player.turn_off
```
To make `doorbell.mp3` available by that URL you need to place it to `/config/www` in your Home Assistant.
Now we need to create a handler of the Aqara button in `automations.yaml`:
```yaml
- id: doorbell_notify
alias: Doorbell notify
trigger:
- entity_id: script.doorbell
from: 'off'
platform: state
to: 'on'
condition: []
action:
- data:
message: "Someone near your front door"
service: notify.push
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,137 @@
---
slug: home-assistant-presence-detection-with-google-wifi
title: "Home Assistant presence detection with Google WiFi"
tags: [smart home, Google WiFi, Home Assistant, home automation]
image: /img/blog/2019/02/presence.jpeg
---
Previously my presence detection in Home Assistant works through Asus router and `asuswrt` component. And it was bad. Very bad. Recently I switched to Google WiFi and realized that the only way to implement presence detection with this router is IFTTT (Update: No). I thought it would be the slowest presence detection in the world but I was wrong.
<!-- truncate -->
:::info
While you still can do this through IFTTT you need to know that there is much easier way not depending on your router model and any 3rd party services [Nmap Tracker](https://www.home-assistant.io/integrations/nmap_tracker). You just enable this component and configure your devices IP addresses.
I configured static IP addresses for devices I wanted to track using [DHCP IP Reservation](https://support.google.com/wifi/answer/6274660?hl=en) on Google WiFi router.
:::
If you still want to use IFTTT, you are welcome to continue reading.
## Home Assistant IFTTT webhook
First of all, we need to create a webhook for IFTTT in our Home Assistant instance through Integrations. Go to “Configuration” -> “Integrations” in the Home Assistant web UI. Find “IFTTT” in the “Set up a new integration” section and click “CONFIGURE”. You will be provided with a webhook URL to use in IFTTT applets. It should look similar to this:
```
https://ha.mydomain.com:8123/api/webhook/e7cd74856399e8934b8f5beffeeeaee4c351cdc8373647585ec040c7b69c2b999
```
Save this URL somewhere because you will not be able to see it again in your Home Assistant UI.
## Home Assistant Entities
For presence detection, Im using `binary_sensors` with `device_class: presence`. Also, the state of those sensors depends on the corresponding `input_boolean`. It is made to be able to switch someones presence on and off manually by adding `input_boolean` to UI and switching its state. Dont set the initial state for input_boolean. It will make it possible to save and restore its state on HA reboots. Also, I set these sensors to have different pictures depending on their presence.
```yaml
input_boolean:
is_yegor_home:
name: “Yegors presence”
binary_sensor:
- platform: template
sensors:
presence_yegor:
friendly_name: "Yegor"
value_template: "{{ is_state('input_boolean.is_yegor_home', 'on') }}"
device_class: presence
entity_picture_template: "/local/yegor_picture_bw.jpg"
```
## IFTTT applets
Next. There is an official Google WiFi service in IFTTT and it can create IFs like “If some device connected/disconnected”. Thats exactly what we need.
![Google WiFi in IFTTT](./ifttt_google_wifi.png)
Open [IFTTT website](https://ifttt.com/) and log in with your account. Go to “My Applets” and click “New Applet” in the upper right corner.
![image](./screenshot-ifttt.com-2019.02.21-11-10-25.png)
Then hit “+this”, search for “Google WiFi” and click it. You will be asked to authorize IFTTT in your google account. After that you will be able to select one of the triggers Google WiFi can send to IFTTT:
![image](screenshot-ifttt.com-2019.02.21-11-20-06.png)
Lets start with “Device connects”. Click it and select the device name you want to track in the next step.
Next, you will be asked to create an action by clicking “+that”. For action, you need to find the “Webhooks” service and choose the only action it provides “Make a web request”.
Now we need to fill all the fields for web request:
URL: `[The url of our Home Assistant webhook we created recently]`
Method: `POST`
Content Type: `application/json`
Body: `{ "action": "call_service", "service": "input_boolean.turn_on", "entity_id": "input_boolean.is_yegor_home"}`
## Handling IFTTT requests
The last thing we need is to create a handler in Home Assistant for web requests from IFTTT. It will be new automation:
```yaml
- id: 'ifttt_webhook'
alias: IFTTT Webhook
trigger:
platform: event
event_type: ifttt_webhook_received
event_data:
action: call_service
action:
service_template: '{{ trigger.event.data.service }}'
data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
```
This automation will handle any requests from IFTTT that will have `action: call_service` in their body with `service` and `entity_id` in it.
For disconnecting from Google WiFi we need to create another applet in IFTTT. It will be the same except for two things:
1. We should select “Device disconnects” from Google WiFi services when creating “+this” for applet.
1. We need to replace input_boolean.turn_on with input_boolean.turn_off in web requests “Body” field when creating “+that” to make it looks like this:
```
{ "action": "call_service", "service": "input_boolean.turn_off", "entity_id": "input_boolean.is_yegor_home"}
```
## Automation based on presence
Assuming weve set up presence detection for everyone living in our home, we now need one variable to know if there is nobody home now. It would be helpful when creating automation that should be triggered when there is nobody home or when someone is back home. So we will add all our presence sensors in a group in `groups.yaml`:
```yaml
presence:
entities:
- binary_sensor.presence_someone
- binary_sensor.presence_yegor
- binary_sensor.presence_someone_else
```
Now we can rely on that groups state to check if there is nobody home. Ive added a delay of 10 minutes to make sure this automation will not be triggered when I simply reboot my device or there was a short connection lost to a router.
```yaml
- id: 'nobody_home'
alias: 'Nobody home'
trigger:
- entity_id: group.presence
for:
minutes: 10
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
message: “Looks like there is nobody home now”
service: notify.push
```
That is all for now. Thanks for reading.

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB