Send Home Assistant notification via M365
Ever since I started with Home Assistant I wanted to be able to send some notifications via email. As I have an M365 Business Basic account I can use Roger Selwyn’s M365-Mail Integration. You can use a Personal account as the prerequisites states.
Note - Personal accounts
Since the middle of 2024, Microsoft has mandated that any new app registrations must be created within an Entra ID directory. You will need to sign up for Azure on a pay as you go basis, where Microsoft Entra ID is indicated as always being free.
The documentation is really good and easy to follow, but I did have a few issues getting the YAML to work.
The documentation gives this as an example
service: notify.ms365_mail_xxxxxxxx
I was confused as to what the XXXXX meant. It is the name you gave the Integration. Below is my Integration
Microsoft 365 - Mail Integration Configuration Screen
As you see my notify line is
notify.ms365_mail_baz_m365
This is my full YAML. This notification sends the SoC level of my solar batteries at 12pm. It sends a Home Assistant notification and then an email to the target address
alias: Notification - Solar - LuxPowerTek 12pm Battery Level
description: Notification - Solar - LuxPowerTek 12pm Battery Level
triggers:
- at: "12:00:00"
trigger: time
conditions: []
actions:
- data:
message: LuxPowerTek Battery % is {{ states("sensor.lux_battery") }}
title: LuxPowerTek 12pm Battery Level
action: notify.notify
- data:
message: LuxPowerTek Battery % is {{ states("sensor.lux_battery") }}
title: "[HA] LuxPowerTek 12pm Battery Level"
target: email@domain.com
action: notify.ms365_mail_baz_m365
mode: single
This Integration can also do the following
Getting emails from your inbox
Setting Auto Reply/Out of Office response
Thanks to Roger for this great Integration