Tag Archives: Home Assistant

Qinping Motion and Light Sensor T and what’s interesting

Today, we are reviewing a quite interesting and questionable to an extent device – Qinping Motion and Light Sensor T. The letter “T” in its name means it has Thread support. Also, the device has Apple Home support, as claimed by the manufacturer, which only piqued my interest further.

Aqara compatibility

Although the device works on the Thread protocol, when it first boots, it can be discovered as a Bluetooth device and work that way later.

In reality, there shouldn’t be any problems with adding the device to the Aqara system. Just scan a QR code or enter the pairing code in the factory app. Don’t forget to turn on pairing mode on the device. For that, hold down the blue button for 10 seconds. When the LED inside stops blinking and lights up, stop holding the button.

This device is for the Aqara ecosystem, but I can’t check how the device works with Aqara hubs since I don’t have one at home. I assume that support for Bluetooth or Thread is required for the device to work.

I will once again remind you that both protocols – Thread and Bluetooth – work at the same frequency.

Home Assistant compatibility

Since Home Assistant allows for devices that work with Apple Home, this device should also be A-OK. There is a requirement, though – you must set up the Bluetooth integration. Besides, if you plan on installing the sensor far from the Home Assistant controller, Bluetooth Proxy also becomes a requirement. What that is and why use it is a topic for a different article, so for now, follow the link to learn more.

So now, we put the Qingping Motion & Light Sensor T into pairing mode by holding down the blue button under the casing for 10 seconds. After a while, Home Assistant will discover a new device and request to add it.

The next step is to enter the code which is on the photo.

Now that you’ve added the sensor, you can optionally assign it a room or a zone.

Below is the device page where you can see its status: the motion and light sensor, battery status, etc.

#image_title

I will again remind you that, at the moment, the Qingping Motion & Light Sensor T works in Bluetooth mode. Of course, this is enough for full functionality, but if you’re building a Thread network and don’t want to inconvenience yourself with Bluetooth Proxy, you can put the device into Thread mode.

Connecting the Qingping Motion & Light Sensor T to Thread

For Thread to work, you must have a border Thread router in your home network. In Home Assistant, the “OpenThread Border Router” addon does the job, which doesn’t work without a Thread adapter.

For the device to connect to the network using Thread, go to the device page and click the “Provision Preferred Thread Credentials” button.

After about a minute, your sensor will connect to the Thread adapter. You may see the device become unavailable for a few seconds, which is when it’s changing modes.

In the “Diagnostic” column, the sensor’s status has changed to an end Thread device (Child).

Something that might be strange is that the “OpenThread” integration is empty. The sensor is still in the “HomeKit Device” category. Perhaps it’s because the device is for HomeKit.

By the way, many people think that if the device works using Thread, it also means that it will work with Matter as well, which isn’t the case. Thread is simply a method of transferring information between devices, like a wired connection in a local or Wi-Fi network. Matter takes care of compatibility between ecosystems on a logical level.

Conclusion

The device I’m reviewing works well. It quickly reacts to motion, and the additional light sensor allows use in many scenarios. The dual CR2450 batteries guarantee good battery life without replacing the power source, but we still need to test that theory. If you own an Aqara hub and have devices you can use as Bluetooth gateways, then the device is definitely for you.

Otherwise, you’ll have to set up a Thread network, and it’s hard to do for now due to the lack of many devices that support the new protocol.

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.

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.