Welcome to Cup of Dev, the best blog by far!

All post publised as Morné Wolfaardt

Home Assistant Tip Split Automation Yaml Into Multiple Files

Home Assistant automation file I recently started adding more and more automation into my Home Assistant *automation.yaml config file. One thing I’ve realized is that the file grows quickly and it get difficult to track your automation. A quick and easy solution is to have multiple files, each containing a different automation YAML. I have a YAML file for my door automation, and another for my reminders.

Backup Your Home Assistant Config to Git

I run my Home Assistant of a raspberry pi using Docker. I found this to be a great way to run multiple different containers as well as Home Assistant. If you are like me, and like to tinker with the YAML files, you can very quickly end up overwriting working config with something that’s not working at all. I’ve learned my lesson by not having a backup of the files.

Starting Docker Containers After a Host Restart

I’ve recently started learning Docker, and how to run Docker on a Raspberry PI 3. I soon realized that whenever the host shuts down, or restarts the Docker containers will not restart automatically. I know you can set the container to auto start but if you are a Noob like me, you can use the following to get the containers back up and running. docker ps -a The command docker ps -a will list all the containers event the once that are not running.

Compress files and folders using sevenzipsharp and 7-Zip in C-Sharp

Compressing files using 7-Zip and seven zip sharp ( is really easy. To get started you would need the 7-Zip DLL namespace Cupofdev { using System; using System.IO; using SevenZip; class Cupofdev { static void Main(string[] args) { // Set source and target folders string targetFolder = @"E:\CodeDumps"; string sourceCodeFolder = @"C:\Dev\Clients\cupofdev"; if (System.IO.Directory.Exists(targetFolder)) { // Specify where 7z.dll DLL is located SevenZipCompressor.SetLibraryPath(@"C:\Program Files\7 - Zip\7z.dll"); SevenZipCompressor sevenZipCompressor = new SevenZipCompressor(); sevenZipCompressor.

Sending Email Using Office 365 Exchange Webservices Api

Sending email using C# is really easy, you can use the build in SMTP client // Setup mail message section MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress("[email protected]"); mailMessage.To.Add(new MailAddress("[email protected]"); mailMessage.Subject = "Test Message Subject"; mailMessage.Body = "HTML Body; mailMessage.IsBodyHtml = true; // Setup SMTP Client SmtpClient client = new SmtpClient(); client.Credentials = new NetworkCredential("", ""); client.Port = 587; client.Host = ""; client.EnableSsl = true; client.send(mailmessage); but using this method will send email using the SMTP setting for Exchange Online / Office 365.

Log Data to a File

You can easily write a collection of data to a log file by using System.IO.File.WriteAllLines method.System.IO.File.WriteAllLines The File.WriteAllLines method take two parameters, the output file and a collection of string entries. The method writes each entry on a new line. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Cupofdev { class Cupofdev { static void Main(string[] args) { // Create a list and populate it. List<string> lstEntry = new List<string>(); lstEntry.