- Home assistant уведомления android
- Setup Home Assistant Push Notifications (The Easiest Method)
- Prerequisite
- Configure Home Assistant
- Notification automation
- Add a trigger
- Add a notification action
- Title and message
- Subtitle
- Grouping notifications
- Troubleshooting
- Conclusion
- Notifications for Android TV / Fire TV
- Configuration
- Services
- Service notify.[name_of_your_tv]
- Configuration Variables
- Service data for sending images
- Notifications
- Service
- Test if it works
- Introduction
- Sending notifications to multiple devices
- General Options
- Attachments
- Opening a URL
- Grouping
- Replacing
- Clearing
- Subtitle / Subject
- Android Specific
- Notification Color
- Sticky Notification
- Notification Channels
- Creating a channel
- Removing a channel
- Specific channel properties
- Notification Channel Importance
- Notification Vibration Pattern
- Notification LED Color
- Persistent Notification
- Notification Timeout
- Notification Message HTML Formatting
- Notification Icon
- Text To Speech Notifications
- Chronometer Notifications
- Alert Once
- Notification Status Bar Icon
- iOS/macOS Specific
- Sounds
- Badge
- Interruption Level
- Presentation Options
- Performing a Shortcut
Home assistant уведомления android
- Главная
- Блог
- Уведомления из HomeAssistant в Push
Home Assistant — это open-source платформа для организации автоматизации системы умный дом. Home Assistant представляет собой модульное приложение с открытым исходным кодом, работающее на языке программирования Python 3. С помощью платформы можно отслеживать и контролировать все установленные устройства в доме. Платформа устанавливается на любой девайс, в том числе и на одноплатный компьютер Raspberry PI. Используя Home Assistant вся умная техника в доме, выстраивается в одну логическую цепь, взаимодействуя с пользователем через интуитивно понятный интерфейс приложения. В программе предустановлено множество устройств бытовой техники, датчиков, сенсоров, роботизированной техники, как именитых брендов, так и менее известных. Продвинутые пользователи при необходимости могут самостоятельно дописать недостающее устройство в приложение, создав отдельный модуль. Устанавливая Home Assistant пользователь настраивает график работы, или по другому автоматизацию, для любого электронного-процессорного устройства в доме, а в совокупности слаженную работу всех девайсов. На современном рынке с элементами умного управления уже есть холодильники, стиральные машины, печи, мелкая бытовая техника, освещение и розетки, а также роботизированная техника, такая как робот-пылесос или мойщик окон. Использование платформы объединяющей всю умную технику в одном интерфейсе значительно снижают вовлеченность человека в повседневную рутину. Каждое устройство сработает согласно заранее заданному алгоритму.
Примеры автоматизаций в Home Assistant:
- Отопление полов включится на заданный промежуток времени за час до будильника и за час до возврата жильцов;
- Кондиционирование воздуха запускается только в присутствии человека с учетом данных с наружных датчиков;
- Наружное освещение автоматически включается с заходом солнца при приближении человека;
- Запись веб-камеры включается при движении в зоне ее видимости;
- Робот-пылесос начинает уборку строго по расписанию;
- Метеостанция выводит данные на стену после срабатывания будильника;
- Освещение в помещениях автоматически включается при срабатывании датчика движения;
Четкая и слаженная работа каждого девайса это результат тщательно прописанного алгоритма автоматизации. Основные характеристики и преимущества платформы:
- Поддержка подключения OpenZWave. Z-wave помогает решать точечные потребности. В Home Assistant можно использовать специальные Z-wave стики или плату Razberry;
- Широкий набор плагинов и устройств. Среди подобных платформ, Home Assistant обладает наибольшим количеством;
- Возможность полностью кастомизировать веб-интерфейс приложения;
- Полная автоматизация всех подключенных устройств. Даже не владея навыками программирования пользователь сможет настроить свою автоматизацию опираясь на примеры в сети;
- Постоянные обновления, включающие в себя новые устройства, функционал и возможности;
- Можно устанавливать дополнительные кастомные компоненты найденные, к примеру на GitHub;
- Широкое распространение в сети. Благодаря популярности Home Assistant в сети много пабликов, блогов, каналов и других источников информации, где пользователи делятся своим опытом взаимодействия с Home Assistant;
- Простая установка. Дистрибутив Hass.io устанавливается на карту памяти, с плагинами и бэкапами одним нажатием кнопки.
Приложение Home Assistant поддерживает в той или иной мере совместную работу с другими приложениями “умный дом”. К примеру, совместная работа с Apple HomeKit может быть частично некорректной, тогда как при работе с Xiaomi Smart Home нареканий практически нет. На данный момент приложение Home Assistant можно установить на любой девайс, поддерживается работа со всеми известными операционными системами. Поддерживаемые ОС:
- Windows 10;
- Mac OS X;
- Ubuntu 14.04;
- Raspbian (Raspberry PI);
- iOS App – beta;
Поддерживаемые компоненты: 545 шт., включая почти все TV/AV receivers, Broadlink, ZigBee, iCloud, Yandex TTS и многое другое. Начало и окончание каждой автоматизации дублируется системой уведомления. Получать данные от Home Assistant можно на любой канал связи. Среди возможных способов получения есть достаточно простой ‒ получение PUSH уведомлений на Android. Создать такую связку можно используя интеграцию Notify Events.
Источник
Setup Home Assistant Push Notifications (The Easiest Method)
Home Assistant has a very powerful notification system whereby it is possible to produce many different types of custom notification.
Since the release of version 2 of the Home Assistant mobile app, support for custom push notifications has been added. Awesome!
Like with other notifications, this type of notification is accessible by using the Home Assistant notify service.
Prerequisite
You should have Home Assistant installed and running. A basic understanding of YAML would also be highly beneficial.
If you are not yet familiar with automation or YAML then I would recommend reading the tutorials about automation and scripts first.
You will also need the Home Assistant app installed on at least one device. The Home Assistant Companion App can be downloaded from the iOS App Store or Play Store.
You will also either need the file editor add-on or be familiar with editing the files using your favorite text editor. If you are not familiar with either you may want to check out my tutorial on automation or scripts first.
Configure Home Assistant
You need to be running Home Assistant version 0.95 or newer, I would recommend just updating to the latest version.
First we need to make sure that the default_config integration is added to our configuration.yaml file. If not then you can go ahead and add it.
If there is some reason that you have removed it, you can instead enter the following.
So long as you have either of these options within your configuration.yaml file, the companion app will automatically configure itself.
It is important that you enable notifications during the installation . If you have already installed the companion app and did not enable notifications during the installation, you may need to follow the steps in the troubleshooting section.
Notification automation
You can utilise push notifications anywhere that you would normally use the notify service in Home Assistant. For this example we will setup a basic automation to test and demonstrate the functionality.
As we are creating a new automation, we will be adding the code to our automation integration within the configuration.yaml file.
Alternatively if you are using automation.yaml generated by the automation GUI or you already have automation in your configuration.yaml file, simply add the code beneath the existing code.
Add a trigger
Next we need to add a trigger for our automation. For this example we will create a simple notification that informs us when a lamp is switched on.
We will use the state platform in order to trigger the automation when the state of a light entity changes to ‘on,’ in this case my tree lamp. You should of course choose your own light entity.
Add a notification action
Now that we have an automation setup with our desired trigger, we can create an action that sends the push notification to our mobile device.
We will use the service notify.mobile_app_ where will be the name of your mobile device integration in Home Assistant. In my case this is simply notify.mobile_app_iphone.
Title and message
Now we can add our notification title and message as desired.
When the notification fires, it will look something like this.
Subtitle
If you are using an iOS device it is also possible to add a subtitle, which appears below the main title and above the message.
Grouping notifications
It is also possible to group notifications if you are using iOS 12 or newer. All notifications that share the same thread-id will be grouped in the notifications center.
Troubleshooting
When I first setup notifications I have some trouble getting them to work. If you had already installed the Home Assistant app prior to reading this tutorial and notifications are not working, you may need to carry out the following steps.
- Delete the Home Assistant app
- Remove the mobile device integration in Home Assistant from configuration > integrations
- Ensure that default_config: is present in the configuration.yaml file
- Restart Home Assistant from configuration >server controls
- Re-install the Home Assistant app
Conclusion
That’s it! You should now be able to set up some awesome push notifications!
In this tutorial we looked at a basic example of how a push notification can be sent to a mobile device using an automation. The integration works very well and makes for yet another superb Home Assistant feature.
You should now have the basic knowledge required to add notifications to more useful applications, such as my easy Home Assistant DIY thermostat.
Also check out my tutorial on push notifications and actionable buttons to add a button to your notification!
Thanks for taking the time to read the tutorial and for visiting my site! Be sure to check out some of my other awesome Home Assistant tutorials!
Источник
Notifications for Android TV / Fire TV
Notification integration for Notifications for Android TV and Notifications for Fire TV. You can use this integration to send notifications to your Android TV device. An overlay with the message content will appear for a configurable amount of seconds and then disappear again. Sending images (e.g., security cam) is supported too.
The notifications are in the global scope of your Android TV device. They will be displayed regardless of which application is running.
When setting this up be aware, that there are two apps: one for your smartphone to send notifications (not required for this platform) and one for your Android TV device to receive the notifications. The app available in the store of your Android TV device is the one that is needed to display notifications sent from Home Assistant. The In-App purchases only apply to the client for Android smartphones, so there isn’t any limit when pushing notifications from Home Assistant.
Configuration
Adding Notifications for Android TV / Fire TV to your Home Assistant instance can be done via the user interface, by using this My button:
If the above My button doesn’t work, you can also perform the following steps manually:
- Browse to your Home Assistant instance.
- In the sidebar click on Configuration.
- From the configuration menu select: Integrations.
- In the bottom right, click on the Add Integration button.
- From the list, search and select “Notifications for Android TV / Fire TV”.
- Follow the instruction on screen to complete the set up.
Services
The following options can be specified inside the data field for the notify service call:
Service notify.[name_of_your_tv]
Configuration Variables
The duration in seconds for which the notification will be displayed.
Has to be one of: small , medium , large or max .
Has to be one of: bottom-right , bottom-left , top-right , top-left or center .
Has to be one of: grey , black , indigo , green , red , cyan , teal , amber or pink .
Has to be one of: 0% , 25% , 50% , 75% or 100% .
The timeout in seconds for trying to send the notification to the device.
If set to true, 1, on etc., the notification is interactive and can be dismissed or selected to display more details. Depending on the running app (e.g., Netflix), this may stop playback.
This is a fully customized YAML you can use inside data to test how the final notification will look like:
Service data for sending images
The following attributes can be placed inside data to send images.
Источник
Notifications
The notify integration makes it possible to send notifications to a wide variety of platforms. To use it you have to setup at least one notification target (notifier), check the integrations list for one that fits your use case.
If you want to send notifications to the Home Assistant web interface, you may use the Persistent Notification integration.
Service
Once loaded, the notify platform will expose a service that can be called to send notifications.
Service data attribute | Optional | Description |
---|---|---|
message | no | Body of the notification. |
title | yes | Title of the notification. |
target | yes | Some platforms allow specifying a recipient that will receive the notification. See your platform page if it is supported. |
data | yes | On platforms who have extended functionality. See your platform page if it is supported. |
The notify integration supports specifying templates. This will allow you to use the current state of Home Assistant in your notifications.
In an action of your automation setup it could look like this with a customized subject.
Test if it works
After you setup a notifier a simple way to test if you have set up your notify platform correctly, is to open Developer Tools from the sidebar and then select the Services tab. Choose your service from the Service dropdown menu, enter the sample below into the Service Data field, and press the CALL SERVICE button.
Источник
Introduction
The mobile_app notify platform accepts the standard title , message and target parameters used by the notify platform. The mobile _ app notify platform supports targets as services. As long as you granted notifications permissions during setup, you will find all your devices listed as targets for the notify service with names prefixed notify.mobile_app_ followed by the Device ID of you device. This can be checked in the App Configuration menu of the sidebar and defaults to the name specified in the General>About within the iOS/macOS settings app or under About>Phone in Android settings (with spaces and non alphanumeric characters replaced by underscores). A requirement of the notify platform is that you must specify at least message: in your payload. A minimum working example of a notification is:
The mobile_app platform provides many enhancements to the simple notification generated above. The image below, for example, shows an iOS actionable notification allowing you to trigger different automations from each button.
Sending notifications to multiple devices
To send notifications to multiple devices, create a notification group:
Now, you can send notifications to everyone in the group using:
General Options
Attachments
You can attach media and other content to notifications. See Attachments.
Opening a URL
When tapping on a notification, you can choose to open a URL, which can fall into one of the following buckets:
- A relative URL to your Home Assistant instance, like /lovelace/test .
- If you have multiple servers connected to an iOS or mac app, relative URLs will be treated with respect to the server that sent the notification.
- An full URL like https://example.com
- For a particular action in Actionable Notifications, see its documentation.
- An application using app://
is replaced with the actual package you wish to open.
- The More Info panel of an entity using entityId: where is replaced with the entity ID you wish to view. Ex: entityId:sun.sun .
For relative URLs, you can open a lovelace view in the format /lovelace/test where test is replaced by your defined path in the defined view or a lovelace dashboard in the format /lovelace-dashboard/view where /lovelace-dashboard/ is replaced by your defined dashboard URL and view is replaced by the defined path within that dashboard.
Grouping
Combine notifications together visually.
Replacing
Replace an existing notification by using a tag for the notification. All subsequent notifications will take the place of a notification with the same tag.
does not support replacing critical notifications.
Clearing
Clearing a notification on iOS requires app version 2021.5 or later.
You can clear an existing notification which has a tag by sending clear_notification .
will only clear the most recent critical notification from a given tag.
Subtitle / Subject
Subtitles and subjects are secondary headings you can use in your notifications beyond the title property.
A subtitle displays in addition to title and message.
A subject may take the place of longer content (more than 6 lines), depending on your device.
Android Specific
Notification Color
In Android you can set the color of the notification, you can use either the color name or the hex code.
Sticky Notification
You can set whether to dismiss the notification upon selecting it or not. Setting sticky to ‘true’ will keep the notification from being dismissed when the user selects it. Setting it to ‘false’ (default) will dismiss the notification upon selecting it.
Notification Channels
Notification channels allows users to separate their notifications easily (i.e. alarm vs laundry) so they can customize aspects like what type of sound is made and a lot of other device specific features. Devices running Android 8.0+ are able to create and manage notification channels on the fly using automations. Once a channel is created you can navigate to your notification settings and you will find the newly created channel, from there you can customize the behavior based on what your device allows.
Creating a channel
In order to create a notification you will need to specify the channel you wish to use. By default all notifications use General if channel is not defined.
In the example below a new channel will be created with the name Motion :
Default values for a channel if not provided will be as follows:
- Importance: Default which means Default notification importance: shows everywhere, makes noise, but does not visually intrude.
- Vibration Pattern: Vibration disabled
- LED Color: LED disabled
Removing a channel
If you wish to remove a channel you will need to send message: remove_channel with the channel you wish to remove. Removing a channel doesn’t reset the settings to the default values, it just removes it from the notification channels list. If you send a notification to a removed channel, it will restore it. The only way to really remove a channel is by clearing the app data which will remove everything.
Depending on when you installed the app you may want to send remove_channel to channel: default to clean up the old default channel:
Specific channel properties
If your device is on Android 8.0+ the following properties will become the default for the channel the first time they are set:
These options will be ignored once they are set for a particular channel, only lowering of the importance will work (if the user has not already modified this).
Devices running Android 5.0-7.1.2 do not have channels and do not need to worry about this note.
Notification Channel Importance
When you are setting the channel for your notification you also have the option to set the importance for the channel per notification. Possible values for this property are high , low , max , min and default . To learn more about what each value does see the FCM docs. For devices before Android 8.0 this property can be used like priority with the same options described up above.
See Specific channel properties for important behavior of this property.
Notification Vibration Pattern
You can set the vibration pattern for the channel by setting the vibrationPattern property. Possible values are a list of numbers. eg. «100, 1000, 100, 1000, 100» etc.. The pattern specification is «off time, on time, off time, on time, off time» etc.
See Specific channel properties for important behavior of this property.
Notification LED Color
Some Android devices have a multi-color notification LED. By setting the ledColor property you can control what color the LED will flash. Possible values are the same as for property color eg ‘#2DF56D’ # or ‘red’.
See Specific channel properties for important behavior of this property.
Persistent Notification
Persistent notifications are notifications that cannot be dimissed by swiping away. These are useful if you have something important like an alarm being triggered. In order to use this property you must set the tag property as well. The persistent property only takes boolean ( true/false ) values, with false being the default. The persistent notification will still be dismissed once selected, to avoid this use sticky: true so the notification stays.
In the example below we will create a notification and then later on we will remove it.
To remove the persistent notification we send clear_notification to the tag that we defined.
Notification Timeout
You can set how long a notification will be shown on a users device before being removed/dismissed automatically. You may use the timeout property along with the value in seconds to achieve this.
Notification Message HTML Formatting
You can add some custom HTML tags to the message of your notification.
Notification Icon
You can set the icon for a notification by providing the icon_url . The URL provided must be either publicly accessible or can be a relative path (i.e. /local/icon/icon.png ), more details can be found in attachments. It is important to note that if you set the image then Android will not show the icon for the notification, the image will be shown in its place. So the message will be shown with the image and with the image as the icon.
Text To Speech Notifications
Instead of posting a notification on the device you can instead get your device to speak the notification. This notification works different than the others. You will set message: TTS and the actual text to speak would be in the title . Current support is limited to the current Text To Speech locale set on the device. If there is an error processing the message you will see a toast message appear on the device. Check to make sure that the Google Text To Speech engine is up to date and set as the default, in case you run into any issues.
By default Text To Speech notifications use the music stream so they will bypass the ringer mode on the device as long as the device’s volume is not set to 0. You have the option of using channel: alarm_stream to have your notification spoken regardless of music volume.
If you find that your alarm stream volume is too low you can use channel: alarm_stream_max which will temporarily set the alarm stream volume to the max level, play the notification and then revert back to the original volume level.
You may not want the TTS notification to be spoken in certain situations (e.g. if the Ringer mode is not normal or DND is enabled). This can be done by adding a condition in your automation that checks the state of other sensors. Few examples are presented below:
Chronometer Notifications
You can create notifications with a count up/down timer (chronometer) by passing the chronometer and when options. This feature requires at least Android 7.0.
Do note that the notification will not disappear when the timer reaches 0. Instead, it will continue decrementing into negative values. You may want to utilize notification timeouts or replace the notification when the timer hits zero.
- chronometer — true to enable chronometer mode
- when — the timestamp to count up or down to (seconds since 01/01/1970)
Alert Once
On Android you have the option for making a notification only alert once on the device. This means it will only make a sound, vibrate and/or flash the LED once. Although it is not an Android requirement this feature will not appear to function if you do not have a tag set. This setting is set to false by default as each and every notification will alert the user. This feature makes use of the Alert Once API
Notification Status Bar Icon
On Android you also have the option of changing the notification status bar icon to any icon on Material Design. By default the Home Assistant icon will appear. The expected format is the same in Home Assistant mdi:cellphone . If you provide an invalid icon name then no icon will be shown. Requires Android 6+.
iOS/macOS Specific
Sounds
By default the default notification sound (Tri-tone on iOS) will be played upon receiving a notification. See the Sounds documentation for details of the available sounds and how to add custom sounds. The default notification sounds (Tri-tone) can be disabled by setting sound to none in the data payload:
Badge
You can set the app icon badge in the payload. The below example will make the app icon badge say 5:
By setting the message to delete_alert you can silently update the app badge icon in the background without sending a notification to your phone.
2021.7 will automatically reset the badge to 0 when launching the app. You can control this behavior in App Configuration > Notifications.
Interruption Level
On iOS 15, you can set the interruption level of a notification, which has the following types:
Value | Description | Overrides Focus |
---|---|---|
passive | Quiet notifications without waking screen | No |
active | Default behavior | No |
time-sensitive | Important notifications | Yes |
critical | Critical notifications | Yes, even mute |
time-sensitive requires iOS-2021.10 or later.
You can read more about these levels in the Apple documentation.
By default, time-sensitive notifications will be read as an announcement. You can control what notifications are announced in the system Settings app > Notifications > Announce Notifications > Home Assistant.
This level is set in the payload. The below example delivers a passive notification:
Presentation Options
By default, if the app is open (in the foreground) when a notification arrives, it will display the same as when the app is not active (in the background), with a visual alert showing notification contents, a badge update (if one was sent in the notification) and the sound of your choice. You can control how a notification is displayed when the app is in the foreground by setting the presentation_options string array. Allowed values are alert , badge and sound .
Performing a Shortcut
You can perform a Shortcut when launching for a notification and have an event fire from the results. See Siri Shortcuts documentation.
Источник