Category Archives: Settings

Using voice commands to control Home Assistant. Part 2

Today, we continue setting up voice control in Home Assistant. This time, we will need a small yet cheap device with a speaker and a microphone “on board.” Let’s assume all the initial settings I wrote about here have been applied.

Setting up and flashing firmware on the ATOM Echo

You will need a device which you can buy here and here, approximately, it only costs 13$.

Follow this link, and you will see the “CONNECT” button.

Connect the ATOM Echo to the computer using USB and click the “CONNECT” button.

If you haven’t downloaded the firmware for similar devices, you might not have the USB driver installed. A pop-up window will only show the standard COM-port.

Click “Cancel,” and you will see a pop-up window where you can install the USB driver.

Install the driver for CH342 devices. Only after you do so will the required port show up. Select it and click the “Connect” button.

Select “INSTALL VOICE ASSISTANT.”

The process of flashing the firmware will now start. Do not close the page while the firmware is flashing.

After the installation finishes, click “NEXT.”

You need to enter the credentials of your Wi-Fi network in the next step.

Click “ADD TO HOME ASSISTANT” to add the device. A new window should show up, advising you to add an ESPHome integration if you don’t have it yet.

After you add the device, you can choose a room or zone for the device.

The image below shows the ATOM Echo in the list of ESPhome devices.

In ESPHome, you need to “ADOPT” the ATOM Echo, after which you should update the firmware to the latest version.

You now have all the sensors and control elements in the integration. From the drop-down list, select the language model created earlier, click ATOM Echo button, and give a command to Home Assistant. Everything should work as intended.

Setting up the wake word

With the latest Home Assistant update, you can activate your “smart speaker” without physical intervention. It’s not difficult to do. Open the add-on store (or click the button below).

Install the openWakeWord add-on, and click “Start” afterward. The add-on doesn’t need setting up.

After installing the add-on, open the Integrations settings.

Go to voice assistants and click the one you want to edit.

In the pop-up window, select Wake word engine and the wake word from the list to the right. Click “Update.”

The last thing you should do is check if the wake word is on for the ATOM Echo. After you turn on “Use wake word,” your speaker will light up with a lilac color, which means it’s waiting for your voice command. Below in the drop-down list, you can select a voice assistant the device will use.

In future reviews, I will show how to make a custom wake word, so stay tuned. See you.

How to set up voice control for Home Assistant

For quite a while, we have had smart speakers in our house, allowing us to control appliances with a simple voice command. People who own those devices know that there are some limitations, such as limited support for smart device developers. For some, lack of native language support might also become a problem.

Before we begin the setup process, you must know that to interact with a device using voice commands, the device must “understand” your request – detect your voice and convert it into an understandable format – text. This process is abbreviated as “STT,” or speech-to-text.

Initial settings

Before we begin the setup process, you must know that to interact with a device using voice commands, the device must “understand” your request – detect your voice and convert it into an understandable format – text. This process is abbreviated as “STT,” or speech-to-text.

You will most likely expect a voiced response to your command. The process of voicing the “response” of the device is called TTS, or text-to-speech.

In Home Assistant, two separate add-ons are responsible for STT and TTS – Whisper and Piper. Go to the add-on store and install both add-ons.

After installing, don’t click the start button yet – there’s still something to set up. Go to Whisper’s settings tab and select the language that you wish to use.

In Piper’s settings, choose the language and voice that would respond to you.

If, for Home Assistant, you use a single-board computer like a Raspberry Pi, you should select the “extra-low” voice. At the end of the title, you will see “x_low,” which stands for “extra_low.” Here, and further in the article, I choose my native language – Ukrainian. You can select any language from the list. The language list, just like the voice list, is regularly updated.

Now, you can click the start button for both add-ons. After some time, they will finish loading. You can check the event log to make sure. You should also checkmark “Watchdog” and “Start on boot” on the first tab, which allows the add-ons to start automatically alongside Home Assistant and after an emergency stop.
Go to the integrations list in settings (or click the “MY” button below.)

Here, you only need to click the “Configure” buttons. The “Wyoming Protocol” integration will appear, which combines Piper and Whisper.

Setting up voice control

Go to “Settings” -> “Voice assistants” (Or click on the “MY” button below).

You might have noticed there’s a voice assistant in the list that already speaks English, but we need to add our own, which understands and speaks Ukrainian (or your native language). So, click the “Add Assistant” button.

From the pop-up window where you can select language from both the SST and the TTS, choose the TTS voice down.

Usually, these settings are enough for most users. Reboot Home Assistant. After reboot, in the upper-right corner of Lovelace, a speech bubble icon should have appeared, just like in the picture below.

Click on the icon. A window should pop up where you can give commands.

You can choose an assistant from the list, including the one you created earlier. If your device is missing a microphone or you can’t speak, you can still enter a request using text.

If you’re facing problems speaking to the assistant, try adding the following to your “configuration.yaml” file.

conversation:

Don’t forget to reboot Home Assistant.

Possible issues and some recommendations

You have set up a voice assistant that does not require Internet access to work. The advantage is that it works locally regardless of the network status. However, there are still significant disadvantages. Voice recognition isn’t always perfect. I can only assume that the voice recognition quality depends on CPU load. The image below shows the result of the low-quality voice recognition.

The second disadvantage concerns the voice model. As of writing this, only one voice model existed for Ukrainian – lada x-low, and it’s so horrible that you don’t even want to turn it on.

There is a solution that removes both cons – Home Assistant Cloud. Of course, it’s not run locally anymore. Home Assistant Cloud is a service with a monthly subscription that is very useful since it doesn’t include just voice assistants. Also, Ukrainians can use the service free of charge since the full-scale invasion.

After you connect “the cloud,” select Home Assistant Cloud in the voice assistance settings, and the voice recognition quality and the voice will pleasantly surprise you.

If you use the voice assistant with multiple languages at once, you should create aliases for devices and rooms. It could be names in different languages or different cases. Below is an example of different aliases.

The image below shows the result of adding aliases.

How to set up the voice assistant on an Android phone

You may have already used Google Assistant by holding the “Home” button. You can change the default assistant app from the settings. Before that, update your Home Assistant to the latest version.

On your Android phone, go to Settings and select “Apps.”

Select “Choose default apps.”

Select “Digital assistant app.”

Select the top button.

From the app list, choose Home Assistant and confirm your choice.

Close the settings. Now, your default voice assistant app is Home Assistant.

You can now control your smart devices using voice (or text) commands from your phone and your computer.

Also, in the HA settings, you might need to activate voice control for the specific device, but only if you have turned it off earlier.

In one of my reviews, I will show you how to make a cheap smart speaker with the Home Assistant’s voice assistant. The article will be a logical part 2 of today’s review.

Tracking Sun and Moon in Home Assistant

You can track the Sun in the standard Home Assistant integration. The integration creates an object with two possible states: above_horizon, bellow_horizon, and several other attributes such as elevation, azimuth, next_dawn, next_dusk. You can use these states as a trigger or condition for automations in your smart home. An example of an automation idea is “turn on the light at the front door 30 minutes after sunset”.

You can also track the Moon in Home Assistant. This integration creates an entity that provides you with the current moon phase, such as new_moon, full_moon, waxing_crescent, waning_crescent, etc. But whether this information is useful for the average user is a good question. Probably not, but some people may find it as such. For someone who is into home automation, the best thing they can do is to create a dashboard and maybe set up a few automations

Setting up the Sun Integration.

  • Go to Home Assistant.
  • Click Settings on the side panel.
  • Choose “Devices and Settings” in the configuration.
  • In the lower right corner, click “Add Integration”.
  • Find “Sun” in the list.
  • Follow the instructions on the screen to finish.

Or, to finish the setup, click the button below.

Setting up the Moon integration.

  • Go to Home Assistant.
  • Click Settings on the side panel.
  • Choose “Devices and Settings” in the configuration.
  • In the lower right corner, click “Add Integration”.
  • Find “Moon” in the list.
  • Follow the instructions on the screen to finish.

Or, to finish setup, click the button below.

Usage of the Sun integration.

Sun integration can be very useful. You can use it in many automations as a trigger. For example, we can use it as a condition to turn on the light on the terrace, but only after sunset. We would not want the light to turn on when we go outside during the day. The trigger can be a motion detector signal.

alias: Terrace Lights ON
description: 'Turn ON Terrace Lights After Sunset'
trigger:
  - platform: state
    entity_id: binary_sensor.terrace
    from: 'off'
    to: 'on'
condition:
  - condition: sun
    after: sunset
    after_offset: '20'
action:
  - service: light.turn_on
    target:
      entity_id: light.terrace_lights

We can also use it directly as a trigger to turn on the backlights and turn them off at sunrise:

alias: Walkway Lights
description: 'Turn on Porch Lights After Sunset'
trigger:
  - platform: sun
    event: sunset
action:
  - service: light.turn_on
    target:
      entity_id: light.porch_lights
alias: Walkway Lights
description: 'Turn Off Porch Lights At Sunrise'
trigger:
  - platform: sun
    event: sunrise
action:
  - service: light.turn_off
    target:
      entity_id: light.porch_lights

Sun display on the information panel.

There is a wonderful Sun Card. We can use it to depict the Sun’s position in the sky. The card can also show some additional information. You can find this card in HACS, and it is most convenient to install it from there.

The card’s code looks like this:

type: custom:sun-card
darkMode: true
showAzimuth: true
showElevation: true

Using the Moon integration.

Similarly, the moon phases are also usable as trigger automations. Although the average user may not find the integration useful, some people will come up with a good use case for it. As an example, we will create an automation that will notify astronomers when there is a full moon so that they can go outside and enjoy this spectacle:

alias: Full Moon
description: 'Notify Me When It`s a Full Moon'
trigger:
  - platform: state
    entity_id:
      - sensor.moon
    to: full_moon
action:
  - service: notify.mobile_app
    data:
      title: Full Moon!
      message: It's a Full Moon Outside!

This automation will notify you with a notification on your phone

Moon display on the information panel.

Do you use Mushroom Cards? If so, the Sun and Moon information can look good on its Mushrooms-Chips Card. For example:

To create a more visually appealing card we will use custom:stack-in-card. We will also download .png images that HA user “bthoven” provided in the topic..

First, download the .png images here and upload them to your Home Assistant server. I have placed them in the folder www/images/MoonPhases, which corresponds to /local/images/MoonPhases in your browser. You can use Samba Share and Studio Code Server to upload them to the folder. Then we create a custom entity image card that will show the corresponding moon image during each phase.

But first, let’s create a sensor that, as a parameter, will transmit the image of the moon phase depending on the state of the main sensor (sensor.moon_phase).

- platform: template
  sensors:
    moon_phase_image:
      #entity_id: sensor.moon
      friendly_name: "Moon Phase image"
      value_template: "{{ states.sensor.moon_phase.state }}"
      icon_template: >
        moon:{{ states.sensor.moon.state }}
      entity_picture_template: >-
        {% if is_state('sensor.moon_phase', 'new_moon') -%}
        /local/images/MoonPhases/new_moon.png
        {% elif is_state('sensor.moon_phase', 'waxing_crescent') -%}
        /local/images/MoonPhases/waxing_crescent.png
        {% elif is_state('sensor.moon_phase', 'first_quarter') -%}
        /local/images/MoonPhases/first_quarter.png
        {% elif is_state('sensor.moon_phase', 'waxing_gibbous') -%}
        /local/images/MoonPhases/waxing_gibbous.png
        {% elif is_state('sensor.moon_phase', 'full_moon') -%}
        /local/images/MoonPhases/full_moon.png
        {% elif is_state('sensor.moon_phase', 'waning_gibbous') -%}
        /local/images/MoonPhases/waning_gibbous.png
        {% elif is_state('sensor.moon_phase', 'last_quarter') -%}
        /local/images/MoonPhases/last_quarter.png
        {% elif is_state('sensor.moon_phase', 'waning_crescent') -%}
        /local/images/MoonPhases/waning_crescent.png
        {%- endif %}

For more appeal, upload the image moon_bg.jpg to the same folder. This will be the background of the card with moon phases. I have an image of a tree against the evening sky, but you can choose an image of your choice.

Now create a card in your dashboard. You can see the sample code in my GitHub here.

As you can see, the card shows the parameter {{ state_attr(entity, ‘entity_picture’) }}, which passes the sensor as the image address. Below, there are two Mushrooms – Chips elements on the card – the time to the nearest moonrise and moonset. I take these parameters from the AstroWeather integration, which can also be found in HACS.

Home Assistant panel on Sonoff NSPanel Pro

This article is my adaptation of the story of enthusiast in smart homes who calls himself blakadder. His experience is below, and I used his materials in the article. Link to the original article by blakadder

Warning: I used a device from the pre-production batch, which was provided to me free of charge by Sonoff. Some of its elements may change with the official release.

For now, you can buy NSPanel Pro with a discount before the opening of sales in the Itead store.

After the shock and disappointment of the firmware release and the September update, I decided to go further. The easiest way to do this is with Android Debug Bridge.

Dissasemble

Remove the panel from the base. Remove the two screws on the back panel and then carefully detach the back plate starting from this point.

Now unscrew the small screws, the ones circled in red. Remove the harness from the touch panel and disconnect the connector to lift the PCB.

Connect the USB cable to the computer.

Install ADB drivers

Download the ADB drivers and install them.
When NSPanel Pro connects to the computer via USB, a new device should appear in the Device Manager.

Download Android platform tools and extract the contents into a folder. Open a command prompt and navigate to this folder. In my case, it’s at D:\adb.

Providing access to ADB

Run adb devices -l . It will list all connected devices with additional information.

D:\adb>adb devices -l
List of devices attached
F061512302021100016 device product:px30_evb model:px30_evb device:px30_evb transport_id:3

Run adb tcpip 5555, command to configure NSPanel Pro to listen for TCP/IP connections on port 5555.

D:\adb>adb tcpip 5555
restarting in TCP mode port: 5555

Now you can connect to NSPanel Pro wirelessly. If you do not know the IP address, type adb shell ip -o a to find it out.

Try this while you are still connected via USB to ensure everything works.

D:\adb>
adb connect 10.1.1.144
connected to 10.1.1.144:5555

Reassemble the panel and connect it to the power supply. After booting, run adb connect [ip_address].

Using ADB

With ADB, you have a powerful tool to control your NSPanel Pro. You can install and uninstall applications, get a list of running processes, free memory, and even gain root access.
Here is a list of ADB commands you can use on your NSPanel Pro.

It is handy to simulate pressing the “Home” button using adb shell input keyevent 3.

You can also get root access with adb root.

Send a file to NSPanel Pro, like a new wallpaper:

D:\adb>adb push wallpaper.jpg /sdcard/Download/wallpaper.jpg
wallpaper.jpg: 1 file pushed, 0 skipped. 18.5 MB/s (52101 bytes in 0.003s)

Installing a launcher

To make working with NSPanel easier, you need to change the default launcher, the eWeLink control panel, to a more familiar one. I chose Lawnchchair because of its small size. Download the APK to the adb folder and install it on NSPanel Pro using ADB.

D:\adb>adb install ch.deletescape.lawnchair.plah_2001.apk
Performing Streamed Install
Success

D:\adb>adb shell monkey -p ch.deletescape.lawnchair.plah 1
bash arg: -p
bash arg: ch.deletescape.lawnchair.plah
bash arg: 1
args: [-p, ch.deletescape.lawnchair.plah, 1]
arg: “-p”
arg: “ch.deletescape.lawnchair.plah”
arg: “1”
data=”ch.deletescape.lawnchair.plah”
Events injected: 1
## Network stats: elapsed time=32ms (0ms mobile, 0ms wifi, 32ms not connected)

Set the default launcher in Settings – Apps & notifications – Advanced – Default apps and set Lawnchair as “Home app.”

To enable the navigation bar, go to Settings – Display and turn on “show status bar.”

Now you can freely navigate the user interface.

Home Assistant

You can install the Home Assistant Companion app, but I have connection problems, probably because of the old WebView component used in the system. The same goes for the Fully Kiosk browser, which complains that WebView is too old.

But you can still access the Home Assistant dashboard through the browser. Download Chromium for Android and install it using the ADB command adb install chromium-106.0.5228.0.apk (version number may be different).

D:\adb>adb install chromium-106.0.5228.0.apk
Performing Streamed Install
Success

It will take some time because the apk file is big! You can run it using the launcher or using adb shell monkey – p org.chromium.chrome 1

It will complain about the lack of Google Play services. Ignore the message. Enter the Home Assistant URL and open it.

After going to the Home Assistant dashboard, tap the three dots and add the page to the home screen.

Pressing the icon opens the full-screen mode of the Home Assistant dashboard.

Capabilities

This solution is not perfect, but it’s what I’ve managed so far. The best option would be to reach out to Itead en masse and demand HA Companion or Fully Kiosk Browser support out-of-the-box. They get more sales, we get more features, it’s a win-win scenario, and now we know it’s possible. At the very least, demand that they update WebView to a compatible version. Tweet them at https://twitter.com/ITeadstudio, email them at support@itead.cc, or use the contact form!

Poking around in the adb environment revealed things like mosquitto, bash scripts to interact with the Zigbee module, RS485 traces, relay 1, relay 2, and possibly more. I hope that more developers who understand Android will fully unlock this device.

Setting up Lovelace UI on NSPanel

In one of my previous articles, I introduced you to a way to flash NSPanel for better compatibility with Home Assistant. We used ESPhome as a basis, which controlled the ESP32 controller. But we left the firmware of the device screen unchanged, which allowed us not to change the appearance. In turn, the screen with the microcontroller “communicated” with each other using the NSPanel Protocol.

I suppose that someone may not like the standard NSPanel interface. Perhaps you will not even be satisfied with the limited number of screens. Let me remind you that you can switch interface screens using swipes. There are only three of them.

That is why today, I offer you a way to change the NSPanel interface to an alternative one called NSPanel Lovelace UI.

Preparing and flashing NSPanel

I chose Tasmota as the main firmware in NSPanel Lovelace UI. Although it is possible to add an ESPHome component, I didn’t succeed with ESPHome and decided to configure Tasmota. That’s why I’ll tell you about this particular firmware.

So, let’s start with flashing Tasmota firmware to the ESP32 controller in NSPanel. If you, like me, have already installed ESPHome on this device, the easiest way is to “update” over the air (OTA). Go to the NSPanel web interface, select the previously downloaded firmware file from your computer at the bottom of the page and click “Update.” After about a minute, the device will reboot with the new Tasmota firmware.

upload firmware Esphome

If you still have the original “factory new” firmware, you will have to disassemble the NSPanel and download the Tasmota firmware using a USB device, sometimes called a TTL converter. I already told you how to do it in this article.

After flashing and rebooting the device, the microcontroller will not connect to your Wi-Fi because it does not know anything about it yet. It will create its own open Wi-Fi access point with the word Tasmota in the name. Then, connect your smartphone to the network and enter the address 192.168.4.1 in your browser, the temporary address of our NSPanel. Here you can choose your Wi-Fi network and save your password. Save the settings. After rebooting, the NSPanel will connect to your Wi-Fi. I highly recommend specifying a static address for our device in the router settings.

Configuring NSPanel with Tasmota firmware

The first thing to do is to specify a device template for Tasmota. To do this, go to the device’s IP address in the browser. In “Configuration,” click Configure Other and paste the following template code:

{"NAME":"NSPanel","GPIO":[0,0,0,0,3872,0,0,0,0,0,32,0,0,0,0,225,0,480,224,1,0,0,0,33,0,0,0,0,0,0,0,0,0,0,4736,0],"FLAG":0,"BASE":1,"CMND":"ADCParam 2,11200,10000,3950 | Sleep 0 | BuzzerPWM 1"}

Don’t forget to leave the “Activate” checkbox.

Download Berry Driver in Tasmota

  1. Download the autoexec.be file from the Berry Driver repository.
  2. In Tasmota, go to Consoles > Manage File System and download the previously specified file.
  3. Reboot your NSPanel.

Updating the Nextion screen firmware on NSPanel

Now let’s update the screen firmware. To do this, in Tasmota, go to Consoles > Console and, depending on the version, use one of the following commands:

EU Version: FlashNextion http://nspanel.pky.eu/lui-release.tft
US Version Portrait: FlashNextion http://nspanel.pky.eu/lui-us-p-release.tft
US Version Landscape: FlashNextion http://nspanel.pky.eu/lui-us-l-release.tft

Press “Enter.” The firmware download and screen flashing will start. Depending on the network speed, the process may take five minutes. Wait until the download is finished and reboot the device.

Setting up Home Assistant

Installing the AppDaemon plugin

The easiest way to install AppDaemon is through the Home Assistant Supervisor Add-on Store. It will connect automatically to your Home Assistant instance.

Adding the babel package to AppDaemon (optional)

To localize the interface (date in your language), add the babel package to your AppDaemon. In the AppDaemon settings tab, in the python packages field, enter the text “babel” and save the settings.

Installing Studio Code Server and Home Assistant Community Store

To configure the NSPanel Lovelace UI, you will need to edit the apps.yaml file. Editing yaml files will be more convenient in the Studio Code Server interface.

HACS is the Home Assistant community store that will allow you to easily update integrations and community automation through the Home Assistant web user interface. You will get notified about updates. You can install them by simply clicking a button. I already wrote about how to install HACS in my previous articles.

Install Lovelace AppDaemon Backend Application

  1. Click on the Home Assistant web interface on the left menu bar on HACS.
  2. Click “Automations” on the right panel.
  3. In the lower right corner, click “Explore & download repositories.”
  4. Type NSPanel and click NSPanel Lovelace UI Backend in the list that appears.
  5. In the bottom right corner of the panel, click “Download this repository with HACS.”
  6. Now a confirmation panel will appear. Click “Download” and wait for the download.
  7. You now installed The Backend Application, and HACS will notify you when updates are available.

Configure MQTT on Tasmota and in AppDaemon configuration

First, set up a connection to your MQTT server in Tasmota.

Please fill in the “Topic” field as it will be in the configuration. Change “Topic” to something unique for your device, you’ll need it later in the appdaemon/apps.yaml settings.

Now configure the MQTT connection in the AppDaemon configuration file. Please add your MQTT server configuration, user, and password to appdaemon.yaml. Then restart the AppDaemon container after adding the MQTT configuration. You will find this file here: config/appdaemon/appdeamon.yaml
secrets: /config/secrets.yaml

appdaemon:
  latitude: 52.0
  longitude: 4.0
  elevation: 2
  time_zone: Europe/Berlin
  plugins:
    HASS:
      type: hass
    MQTT:
      type: mqtt
      namespace: mqtt
      client_id: "appdaemon"
      client_host: 192.168.75.30
      client_port: 1883
      client_user: "mqttuser"
      client_password: "mqttpassword"
      client_topics: NONE
http:
  url: http://127.0.0.1:5050
admin:
api:
hadashboard:

Configure NSPanel in AppDaemon

Add the following minimum configuration to the apps.yaml file located in config/appdaemon/apps/apps.yaml

nspanel-1:
  module: nspanel-lovelace-ui
  class: NsPanelLovelaceUIManager
  config:
    panelRecvTopic: "tele/tasmota_your_mqtt_topic/RESULT"
    panelSendTopic: "cmnd/tasmota_your_mqtt_topic/CustomSend"

Specify tasmota_your_mqtt_topic according to the topic used in the Tasmota MQTT configuration.

If your settings and configuration are correct, you should see the following screens on NSPanel:

Getting acquainted with an example of a complete NSPanel Lovelace UI configuration

Below, under the spoiler, you will find the full text from my NSPanel configuration file. Also, look at the images of several interface screens of my particular configuration. You can see the screensaver screen with the weather in the header of this article.


That’s it for today. See you!

P.S.

After pressing the switch button, the relay response time of the device with Tasmota firmware became a little longer than it was with ESPhome. Perhaps the reason is that NSPanel is waiting for a command to turn on the relay from Home Assistant. At the same time, in ESPHome, all the “magic” happens only in the device without waiting for a response from Home Assistant.

I changed Tasmota on the NSPanel and installed ESPhome with the Lovelace UI component. You can find the ESPhome configuration file in my GitHub repository at this link. I changed Tasmota on the NSPanel and installed ESPhome with the Lovelace UI component. You can find the ESPhome configuration file in my GitHub repository at this link. Now the switches are working quite lively and, frankly speaking, it is more familiar to me to configure ESPhome.

Stream from Nest cameras on TV using Chromecast

Quickly see who is at the front door using your TV.

Imagine you are comfortably settled on the sofa and watching the latest episode of your favorite series on Netflix with your children, but someone rings the doorbell, or you hear a noise from the children’s room. If you have a Google Chromecast at home connected to your TV, you don’t have to take out your phone or crane your neck to look at the Nest Hub display— ask Google to show you the feed from your doorbell or security camera right on that TV.

Any compatible security camera from Nest, Arlo, Wyze, Eufy, Netatmo, TP-Link Kasa, and more can be streamed live to the big screen using Chromecast. And starting last month, you can stream video from the new Nest cameras if you have a Chromecast with Google TV.

Below is a list of new Nest cameras you can now use to stream video.

  • Nest Doorbell battery *
  • Nest Cam (indoor, wired) *
  • Nest Cam (outdoor or indoor, battery) *
  • Nest Cam with floodlights *
  • Nest Cam IQ (indoor and outdoor — now discontinued)
  • Nest Doorbell wired (formerly the Nest Hello)
  • Nest Cam (indoor, first-gen)

(*Only works via Chromecast with Google TV)

With your cameras and Chromecast enabled, you can easily set up streaming to your TV. First, ensure you connect your camera and Chromecast to the same Wi-Fi network. Then follow these steps.

Add your Chromecast TV to the Google Home app

First, you need to make sure you connect your Chromecast to the same account as your smartphone or tablet.

  • Open the Google Home app.
  • Find the icon from your Chromecast – it will be in the room you placed it in during setup.
  • Tap and hold the icon.
  • Click on settings in the upper-right corner.
  • Tap on “Recognition & Sharing.”
  • If you didn’t connect the device, you would see a banner in the upper part of the screen titled “Enable voice control and more.”
  • Tap the banner and follow the instructions to link the Chromecast with Google Home.

However, suppose your device is already connected. In that case, the banner won’t be there, and your email address should be displayed under “Linked account(s),” indicating that your TV is already connected.

Watch video from your video call or security camera on your TV

Using voice commands, you can view a live feed from any compatible security camera or video call directly on your TV.

  • Say “OK, Google” or “Hey, Google” to your smart speaker or Google Assistant on your smartphone, and then “followed by [camera name] on [TV or Chromecast device name].”
  • On the Chromecast with Google TV, hold down the Assistant button on the remote and say the wake-up phrase “OK, Google” or “Hey, Google,” and then “show [camera name].”
  • To stop streaming, say “stop [Chromecast or TV name]” or tap on the “Home” button on the Chromecast on the Google TV remote.

Installing Ukraine Alarm in HA and setting up notifications

Update 2022.5.3 to Home Assistant introduces a new integration called Ukraine Alarm. With its help, you can get information about air alarms or other alarms in Ukraine in real-time.

Ukraine Alarm creates four binary sensors, each responsible for a specific type of alarm, and when the sensor is in the “on” state, a corresponding alarm goes off.

In version 2022.5.4 HA, the integration got an update. Now you do not need to wait for the API key from the developers (who may not give you the key), and you can configure “Ukraine Alarm” by specifying the area you plan to monitor immediately.

Adding Ukraine Alarm integration to Home Assistant

Click the My button or add “Ukraine Alarm” manually by clicking the “+ Add Integration” button and start entering the name. Then click on the name of our integration.

Next, you need to choose the area where you plan to monitor the alarm, which could be an area, district, local community, or city.

In the last step, you can assign a room (zone) to which new integration sensors would add.

After clicking on the “Finish” button, the “Ukraine Alarm” integration will be added.

As you can see in the image, each instance of this integration creates four binary_sensor entities responsible for having a type of alarm. These alarms are Air, Artillery, Urban Fights, and Unknown. There is a limit on the number of territories, not to exceed the number of API requests from one IP. You can monitor up to 5.

Adding sensors to the home screen in the Dashboard

If you do not want to receive notifications but want clear information about alarms in a particular region, add sensors to the Lovelace card. Of course, you can design the look to your liking.

The first image shows a card with four-alarm sensors when there are no alarms. The second image shows the state of the sensors when the air alarm goes off.

Adding sensors to the home screen in the Dashboard

I already made a tutorial on setting up a Telegram bot that receives notifications from your smart home. Next, I’ll just add the automation code, which will allow you to send notifications to your telegram bot.

I will also provide the code to allow you to manage notifications in your Home Assistant mobile app. This example will use a voice notification, and you will hear it even when your phone is silent. Well, let’s get acquainted with the code.

In the code above, I left comments on the relevant parts.

That’s all for today. Have a peaceful sky without air alerts!

Meeting the NSPanel switch and flashing ESPHome

Last year, the Chinese company Sonoff started crowdfunding, where they presented an interesting smart device. By the end of 2021, Sonoff introduced NSPanel. This device is a rectangular device with a colored touch display sized 3,5 inches and two physical buttons.

The touch display was also created by Sonoff, this is a Nextion model.

There are two versions of the NSPanel, and they differ only in size. One is for the US market, and the other one is for the EU countries. The power and logical parts of the devices are the same. As a “brain“, the company chose the Espressif ESP32-DOWD V3, which allowed working in Wi-Fi 4 802.11n/g/n networks. Bluetooth 4.2/5.x is only used when setting up the device.

Connecting NSPanel to the power grid

To set up and control the device you need to download the eWeLink app, it must be familiar with Sonoff devices owners. If you do not have an account yet, create it, or log onto your account. eWeLink lets you control connected devices from all around the world where the Internet connection is established.

So, to connect the NSPanel on the phone you need to turn on Bluetooth. After that, connect the device to the power grid.

Use safety precautions when working with high voltages!

In the eWeLink app press “add new device“. Then, you will see the device on the screen, tap on it to add it. Then, you may need to enter your Wi-Fi credentials. After connecting, the NSPanel most likely will ask you to update its firmware. Do it, because this update may contain bug fixes or performance improvements. The update may take a while.

The power part of the switch includes two relays that can withstand up to 16A of current. This means that you can connect two additional electric devices. It could be not only lighting devices but also, for example, a warm floor controller. Below is a switch connecting scheme.

Setting up the NSPanel in eWeLink

In the eWeLink application, you can switch one of the switch relays to thermostat mode, then the built-in thermal sensor can control the temperature in the room. For the thermostat, choose the heating or cooling mode depending on the device you want to connect (heater or cooler). Set the target temperature in the room and the device will turn off when it reaches the target temperature.

To reach the thermostat screen on the switch, swipe right on its screen. One more swipe will lead you to widgets. These are pictograms with which you can control other smart devices. This way you can control plugs or bulbs, and also their groups. In addition, you can create widgets to load a scene.

You need to create widgets in the eWeLink app. The max widget number is 8.

To control the device using voice assistants create the appropriate integration in the eWeLink app. In addition, Sonoff allows controlling the switch in a local network, which enables integrations into alternative smart home control systems. Enable the corresponding item in the device settings.

Getting ready to launch ESPHome

I think that this smart device is “smart” only when it can work independently of cloud services. NSPanel can work locally but sadly, its widgets don’t work without a network connection. Essentially, you can only control two relay devices through a local network.

Just as I stated above, the logical part of the switch is a Nextion display that is connected to the esp32 controller. Such a tandem gives us hope for the ability to easily load alternative firmware. And really, “tasmota” firmware already exists for our device, work on creating an NSPanel component for ESPhome is also in full swing.

Let’s look at the PCB of the logic unit. To take it out, lightly press the screwdriver on the groove in the center. Remember to turn off the power beforehand!

Now you need to unscrew two screws that hold the protective plate. After you carefully remove the plate, you will see the PCB with the esp32 controller microcircuit.

You will see 5 contacts in the lower corner. They are marked as 3V3, ESP_TX, ESP_RX, GND, and IO0. The last contact is a “zero” pin controller. To switch the controller to firmware mode, connect it to the neutral wire.

To flash the controller’s firmware, you will need a usb2uart (USB to TTL converter) adapter. Before you connect it to the computer, set the voltage to 3.3V, this is important!

Using Dupont wires, connect the adapter to the PCB: VCC – 3V3, GND – GND, RX – ESP_TX, TX – ESP_RX. Connect the IO0 pin on the PCB to the neutral wire on the contact pad (green wire on the picture)

Pay attention: If the Dupont wire contacts protrude beyond the contact holes on the board, they will touch the metal plate of the display. This can lead to a short circuit and both the USB adapter and NSPanel chips failure! To avoid this, disconnect the display cable and remove the PCB from the chassis.

Downloading ESPHome onto the NSPanel

Now you can confidently download the ESPHome firmware. Connect the USB adapter to the computer, and in the device manager, look what COM port it received. Now, in the ESPHome interface, you can create a new node. To be honest, downloading empty code onto esp32 and then working with the created node using Wi-Fi would be enough. To do this, select the firmware option of the ESP controller connected to the computer. Then, select the COM port in the popup. Downloading the firmware takes a few minutes. The contacts need to stay connected!

After the firmware is loaded, disconnect the wires and assemble the switch. After connecting the NSPanel to the network, you can use the switch just like a regular esp32 controller. Now let’s download an already prepared code.

After reboot, the switch will have a familiar interface. I want to warn you: There’s no official thermostat support, so I didn’t add it in the code. The thermostat, just like some widgets, could be added by JSON requests. The format which JSON should have can be read here. And here you can find another variant of the code, already bundled with some widgets and a thermostat. One thing, you will need to replace the device IDs with yours.

For an example of scene widgets, I added code that will turn off melodies on the built-in NSPanel booster (piezodynamic). You can add and load any scene with Home Assistant.

After the official release of NSPanel components for ESPHome, I plan to update the article, so check for updates. In addition, there is a way to fully change the interface and switch from the NSPanel Protocol, since onboard of the switch we have Nextion display and esp32, but that is a topic for another article.

Setting up the integration for Nest devices in Home Assistant

A little over a month ago, I made a review on the Nest Learning Thermostat. It is a handy device that will support the comfortable temperature inside your room and will save your money on heating at the same time.

As you know, Google owns Nest, and how it often happens in big companies, not all areas of production keep up with user requests. And the fact that Google has partially closed the Nest API has been sad news for independent developers. If you use the Nest app, which manages only its own devices, you may have paid attention to the fact that the app did not update for quite a while. It also does not have that many devices.

I think it will be much more convenient for anyone to control their devices from within one app. I chose Home Assistant as the system since you can integrate many devices from different brands, manage them, and add any automatization algorithm.

I must warn you: to get access to the Nest Smart Device Management API you will need to pay 5 dollars. It is a one-time payment for API access.

After finishing setup through Home Assistant, you will gain access to these essences: Climate, Sensor, Camera.

Registering device access

For this step, enable Nest API and create an account for Home Assistant to exchange info with the Nest API.

Creating and configuring Cloud Project in the Cloud Console:

  • Go to Google Cloud Console.
  • If this is your first time, you need to create a new project in Google Cloud. Click on “Create Project”, and then “New Project”.

  • Name your project and click on “Create”.
  • Go to “APIs & Services > Library”. Here you can enable the API.
  • Search for “Smart Device management” and click on “Enable”.

  • Now enter “Cloud Pub / Sub API” in the API library search box and click “Enable.”

Now you have a project ready to set up authentication with OAuth.

Setting up OAuth in Cloud Console Consent Screen

In this section, you configure the OAuth consent screen. It is needed to give Home Assistant access to your project.

  • Go to Google API Console.
  • Click on “OAuth consent screen” and start setting it up.
  • Choose “External” (this is the only option if you are not a G-Suite user), and then click on “Create”.

  • On the “App Information” screen, enter the App name and the User Support E-Mail, and then type in your E-Mail address in the “Developer contact email” section. They are displayed only during the OAuth to give Home Assistant access to your account. Click on “Save” and “Continue”. Do not add unnecessary info (for example, the logo) to avoid additional Google checks.
  • On the “Scopes” step, click on “Save and Continue”.
  • On the “Test Users” step, add your Google account (example@gmail.com) to the list. Click on “Save” in your test account and then “Save and Continue” to finish the process.

  • Go back to the OAuth consent screen and click “Publish App” to set the “In Production” status.

  • The warning states that your application will be available to any user with Google Accounts that you have entered on the application information screen. It does not compromise your Google Account or your Nest data.
  • Make sure to disable the “Testing” status since you will be logging out of your Google account every week.

Configuring OAuth client_id and client_secret in the Cloud Console

At the end of this section, you will get the client_id and client_secret you need for the next steps.

  • Go to the “Credentials” page and click on “Create Credentials”.

  • Select “OAuth client ID” in the drop-down list.

  • Choose “Desktop App” in the “Application type” type field.
  • Give an understandable name to your credentials.
  • You will now see a message created by the OAuth client. Pay attention to “Client ID” and “Client Secret”. They are crucial to the next steps.

Creating device access for project_id in the Device Access Console

Now that you have set up the authentication, create the Nest Device Access Project, which requires $5. When done, you will have device access to project_id, which is crucial for further steps.

  • Go to the “Device Access Registration” page. Click on the “Go to the Device Access Console” button.
  • Check the “Accept the Terms of Service” and click on “Continue to Payment” where you will need to pay 5 dollars.

  • The “Device Access Console” should now be displayed. Click on “Create project”.
  • Give a name to your project and click on “Next”.

  • You then are prompted to enter the OAuth client ID you created earlier in the previous section. Click on “Next”.

  • Turn on “events” by clicking on “Enable and Create project”.

  • Note the Project ID. You currently have project_id, client_id, and client_secret required for Home Assistant.

Setting up Home Assistant

Now you have everything required to set up Nest in Home Assistant. Open “configuration.yaml” and write according to the sample you see below.

# Example configuration.yaml entry
nest:
  client_id: CLIENT_ID
  client_secret: CLIENT_SECRET
  # "Project ID" in the Device Access Console (not Cloud Project ID!)
  project_id: PROJECT_ID

Be sure to restart Home Assistant in the “Server Controls” section.

Setting up devices

After you added a Nest configuration entry to “configuration.yaml” and rebooted Home Assistant, you need to add Nest integration through the user interface. To do this, you can use the “My” button:

You can do the same manually:

  1. Go to your Home Assistant interface.
  2. On the sidebar, click on “Configuration”.
  3. In the configuration menu, select “Integrations”. (in version 2021.12 Devices & Services)
  4. In the lower right corner, click the “Add Integration” button.
  5. Use the search box, select “Nest” and follow the instructions.

Setting up the Nest integration will guide you through the steps of authorizing your Home Assistant to access your account on Nest devices.

Setting up OAuth for Device Authorization

This section will allow Home Assistant to access your account by generating an OAuth token.

  • Select “OAuth or Apps”, because we created credentials for the computer programs above in the Google Cloud Console.

  • Click the “authorize your account” link.

  • A new tab will open where you can select your Google Account. It should be the same developer account you set up before.
  • The Google Nest permissions screen will allow you to choose which devices to configure and select from several of your homes. Maybe you want to turn on everything. However, you can skip any feature you do not need to use.

  • You will get redirected to another account selection page.
  • You may see a warning screen stating that Google has not tested this program because you have just set up an unverified developer workflow. Click on “Continue” to continue.

  • You will then get prompted to grant additional permissions. Click on “Allow”.
  • Confirm that you want to grant permanent access to Home Assistant.

  • Copy the token.

  • Insert the token into the Google Home Assistant Link Account dialog box.

  • The next step is to enter the Cloud Project ID to receive updates from your devices. Open the Cloud Console and copy the Project ID.

If everything is as planned, you will see a working Nest integration.

Using automation and triggers

Nest integration makes device triggers available and the ability to enable automation in Home Assistant. For complete information, see the Home Assistant Automation Guide.

You can use nest / set_away_mode to set Home or Away mode:

# Example script to set away, no structure specified so will execute for all
script:
  nest_set_away:
    sequence:
      - service: nest.set_away_mode
        data:
          away_mode: away

Controlling the thermostat

The Nest climate platform allows you to control the thermostat from Nest. However, please note that due to the limitations of the European Nest E thermostat, integration with the Home Assistant is not possible for this thermostat.

After setting up the integration and adding the thermostat card to the Lovelace interface, you will be able to control your Nest devices via Home Assistant.

Also, it is now possible to add new climate entities in triggers and automation, calling the appropriate service using previously created configuration files. You can view the templates in the Home Assistant developer tools.

How to clean up the Home Assistant configuration file

Once upon a time, there was complete chaos in my Home Assistant configuration files, and it took a while before I put them in order. The configuration.yaml file was oversaturated with code and disorganized. My automations were in one file, and I have over 100 automations. All of my scripts were in a similar situation. Over time, I’ve created dozens of templates for sensors and binary_sensor, all in their “configuration.yaml” files. After getting confused about the configuration and settings, I decided on “general cleaning.”

Preamble

I should note that this article isn’t a discussion of the best ways to organize Home Assistant configuration files. Here are some points to keep in mind. I will focus on the configuration process for Home Assistant and what and how I decided on specific settings. I hope my experience can help you.

The initial state of Home Assistant configuration files

I have been using Home Assistant for almost three years. During this time, I’ve developed and expanded the capabilities of Home Assistant, making it a powerful tool for managing my smart home. Though, I didn’t plan or shorten my configuration files.

All my automations were in one big file (automations.yaml). Also, all my scripts were in one file (scripts.yaml). My configuration.yaml included a lot of sensors, lamps, switches, and more. It became difficult to find and manage files.

I wanted to make each of the configuration items more manageable. I didn’t want to have to scroll and search through long files to make minor edits. I want to make it easier to track errors in my configurations. I need to understand where to add new code.

Settings of the Home Assistant configuration file

Home Assistant has several code-splitting options. Their documentation explains these options in detail.

You can use “include” to move all of the integration to a new separate file(s).
You can use more advanced “include” versions to move full integrations to folders with files.
Examples will help in explaining those options.

The basics of the include setting

Let’s begin with the most simple example:

automation: !include automations.yaml

This line placed in your configuration.yaml file tells Home Assistant that your code is in the file called automations.yaml in the same configuration folder. Similarly, you can split more parts of your configuration.yaml file:

automation: !include automations.yaml
switch: !include switches.yaml
light: !include lights.yaml

The example above moves the code for automation, switches, and lighting devices to separate files.

Advanced include options

For advanced options, I will copy the explanation from the Home Assistant documentation:

  • !include_dir_list will return the contents of a directory as a list. The contents of each file will be an entry in the list. The list entries are ordered based on the alphanumeric order of the file names.
  • !include_dir_named will return the contents of a directory as a dictionary that displays filename => file contents.
  • !include_dir_merge_list will return the contents of a directory as a list by merging all the files into one list.
  • !include_dir_merge_named returns the contents of a directory as a dictionary, loading each file and merging them into one dictionary.
    Let’s look at an example of each of them:
automation: !include_dir_list automations/

In this case, each automation would be in its YAML file inside the automations/ directory. So you can have turn_on_lights.yaml and turn_off_lights.yaml files in the automations directory, each with its automation.

Compare this with:

automation: !include_dir_merge_list automations/

In this case, each YAML file in the automations/ directory can have multiple automations inside. You can write rules for turning lights on and off in a file called lights.yaml. The thing to remember when using the merge_list directive is that all automations in all files must be in list format (hyphenated), for example:

- alias: "Turn on Light"
  trigger:
    - platform: state
      entity_id: device.iphone
      to: "home"
  action:
    - service: light.turn_on
      target:
        entity_id: light.living_room

but not:

alias: "Turn on Light"
trigger:
  - platform: state
    entity_id: device.iphone
    to: "home"
action:
  - service: light.turn_on
    target:
      entity_id: light.living_room

!include_dir_named and !include_dir_merged_named work similarly, but instead of merging files into a list, they combine into a dictionary. For example, scripts load into a dictionary. Use an entry instead of a list like this:

script: !include_dir_named scripts/

to combine files in the scripts directory, each containing one script, or

script: !include_dir_merge_named scripts/

to combine files in the scripts directory, which could contain more than one script.

What I decided to change

I used a combination of include directives to split up my configuration file and organized my automations as a merged list. This way, you can store automation groups in one file. For example, I have irrigation.yaml file for irrigation automation and an hvac.yaml file for heating and cooling automation. I also created a unified dictionary for my scripts.

For sensors, lamps, switches, groups, shell commands, and input_numbers, I used a simple include directive to keep them in their files. I don’t tweak and add and change them as often as automations, and there aren’t that many, so I think a separate file for each is fine. Here is the relevant section of my configuration.yaml:

group: !include groups.yaml
automation: !include automations.yaml
automation mine: !include_dir_merge_list automations/
script: !include_dir_merge_named scripts/
sensor: !include sensors.yaml
binary_sensor: !include binary_sensors.yaml
switch: !include switches.yaml
light: !include lights.yaml
rest_command: !include rest.yaml
remote: !include remote.yaml
shell_command: !include shell.yaml
input_number: !include input_number.yaml

Note lines 2 and 3 above. I have a regular include directive and a merge list directive for automations, which allows me to organize the automations I write into files while the automations generated by the UI will still be in automations.yaml.

But what about packages?

Another way to organize your files is to use packages. Packages allow you to bundle integrations (like light, switch, input_boolean, etc.) together. You can combine packages with include directives to group functions in your configuration more logically. For example, you can have a home theater package that will include all the lighting, audio-video equipment, and automation for the room in one package.

Last thoughts

I hope that after this article, you will have new ways to organize your Home Assistant’s configuration files. I’d love to hear how you do it. Let me know in the comments.