Automation Fixation https://automation.moebius.site A site dedicated to home automation and technologies. Sun, 28 May 2023 07:18:38 +0000 en-US hourly 1 https://wordpress.org/?v=6.4.3 156416546 Home Assistant and Apple Watch – Actions and Complications Guide https://automation.moebius.site/home-assistant-and-apple-watch-actions-and-complications-guide/ Thu, 29 Sep 2022 01:21:53 +0000 http://automation.moebius.site/?p=1579

Introduction

In this guide, I’ll be going through how to make the most of the integration between Apple Watch and Home Assistant including Actions and an overview and examples of key complication types for the Apple Watch.

I’m using the new Apple Watch Series 8 and the latest watch OS 9 (as of September 2022).

If you haven’t seen my video on enabling remote access and installing and integrating the iOS app, please check it out first.

For the purposes of the video and to keep it simple, I’m going to be doing all of this via the iOS Home Assistant and Watch Apps and the Apple Watch itself.

Adding an Action

First off, let’s add an Action. Despite the name, an action is a trigger that you can use from your Apple Watch for a Home Assistant automation.

  • From the Home Assistant app on your phone, Go to Settings –> Companion app
  • Then select Actions
  • Tap on the + symbol to add a new action
  • Then select a name, display text, color and icon
  • In this example, the action will be to toggle a switch
  • Keep the name simple as you will need to use this in the next step
  • Name: Light
    • Text: Light Switch
    • And then within the Icon screen, search for an appropriate icon. I’ve searched for the toggle_switch icon.
    • The screen shows a preview of what it will look like and you can also change the background colour
    • Once you have completed this, Save, go back to the previous screen and make sure you click done in the top right to save the settings in the companion app.

Linking Action to Automation

Next we need to link the iOS action we just created, to do perform an actual action. In this example, I will link the action to toggle a switch.

  • Go to Settings –> Automations & Scenes
  • Then create a new automation
    • Event type: ios.action_fired
    • Event data: actionName: “<name of action>”. In my case, we have selected light.
  • Action:
    • Service: switch:toggle
    • Choose Entity. For example, the entity I selected was my Front Door Light Switch
  • Save and select a name for your automation. For example, ‘Watch Light Automation’.

Access Action via Apple Watch

  • To use your actions on your watch, you can access this via the Home Assistant App
  • Simple go to your app screen and find the Home Assistant App
  • The action that was just created should be visible
  • Press it to toggle and fire the automation and press again to turn it off
  • You can see that the switch turned on from the history of the automation

That’s all there is in the Apple Watch Home Assistant App, however another way to quickly access the action is through adding a Home Assistant complication to your watch face and tapping on all complications will open the same actions screen.

Complication Overview

The next functionality with Home Assistant and the Apple Watch is the use of Complications and this definitely can get complicated. Let’s take a quick complication 101.

The term ‘complication’ is historically used for mechanical timepieces and regular watches and refers to additional functionality beyond simple time.

Let’s look at the positioning and examples of an Apple Watch Face. The positioning is important to understand when you build out the complications and configure them into a watch face.

Source: Apple.com

As of the recent watchOS 9 update, a number of complication templates are no longer working. The key complication templates to note that are currently working in the Home Assistant app as of the recent iOS 9 update are:

Circular

These are useful for showing quick round shaped values for ranges and simple status on Infograph and Modular watch faces:

Corner

Corner layouts show images, text and gauges in the corners of supported watch faces such as Infograph:

Inline

The Large Inline layout can be used at the bottom of a watch face such as Utility or Motion. These allow icons and text:

Rectangular

Rectangular layouts show images, text, gauges and titles across a large rectangular region:

As of the most recent iOS update, templates which are now deemed as legacy appear to no longer work in the Home Assistant app and are no longer visible. For those with existing complications, it looks like you have no current option but to re-create using the supported templates until there is a fix. The Home Assistant community has raised a bug which is still being investigated.

The impacted templates include:

  • Circular small
  • Modular Small
  • Modular large
  • Extra Large

I’d recommend avoiding any of these as they will not be visible and you will run into compatibility issues until the app has been updated to either support or remove them.

Template GroupTemplateWorking
Circular SmallCircular SmallNo
Extra LargeExtra LargeNo
GraphicBezel
GraphicCircularYes
GraphicCornerYes
GraphicRectangularYes
ModularLargeNo
ModularSmallNo
UtilitarianLargeYes
UtilitarianSmall
UtilitarianSmall Flat

Complication Limitations

  • Now there are some limitations with Complications including:
    • Automatic updates. Complications only update within a few minutes of 00, 15, 30 and 45 as Apple limits how often they are able to be updated
    • Manual Updates – You can do manual updates, however these are limited to 50 a day. Technically, you can add this as a service call, but it is limited and so complications that you want to refresh frequently might need to be reconsidered until push updates are supported.
  • App Delays – There are also app delays with complications and it takes a bit of time for the complication to reflect and be accessible in the app. You may need to play around and add/remove complications until it is visible in the Watch app. Make sure once you create, click done on the companion section of the Home Assistant app to ensure any updates get saved.

Key Complication Screens

There are three key screens that you need to get familiar with when creating complications. These are the:

  • Complication Management Screen: This is in the Home Assistant Companion App to manage created complications
  • The Face Management part of the Apple Watch app: This is to select the location of complications and build out your watch face
  • The Apple Watch Screen: To view the watch face

Complication Examples

Ok, Let’s go through each key working template using data from Home Assistant. We’ll start with the circular template.

Circular

  • Template: Closed Gauge Image
    • Gauge: {{ iif(is_state(‘switch.front_door_light’, ‘on’), 1, 0 ) }}
      In this example, I have used a binary state for the switch which will be on or off and set the formula to return 1 or 0 to add or remove the ring around the complication.
    • Icon: Light
  • Template: Open Gauge Image
    This template allows a gauge with an icon
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      I’ve had to add in the formula to convert the status to a float to support the gauge value.
    • Icon: Printer
  • Template: Open Gauge Simple Text
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Bottom: BLK
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      The difference here to the previous template is that you can use text instead of an icon.
       
  • Template: Open Gauge Range Text
    • Centre: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Leading: 0
    • Trailing: 100
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
      The Range template allows you to specify a different range e.g. if you wanted to show between two different values. In this case, I will still use 0 to 100.

Corner

  • Template: Gauge Text
    • Leading: 0
    • Outer:  {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Trailing: 100
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }}
    • Style
      • Fill – Shows a line completed up to the value
      • Ring – Shows a filled line with a ring on the value
  • For the corner, the values are similar to the other circular templates that we just went through and so will go through a gauge text example. This includes the leading and trailing values of the gauge with style fill showing the fill line up to the value or ring which shows a circle at the state value along a line.

Rectangular

  • The next template example is the rectangular standard. I’ve added in the Printer Ink header with the two body lines showing black and cyan ink levels
  • Template: Standard Body
    • Header: Printer Ink
    • Body 1: Black: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Body 2: Cyan: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Icon: Printer
  • Template: Text Gauge
    • Header: {{ states(‘sensor.epson_wf_3520_series’) }}
    • Body 1: {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}
    • Gauge: {{ float(states(‘sensor.epson_wf_3520_series_black_ink’)) / 100 }
    • Style
      • Fill Shows a line completed up to the value
      • Ring Shows a filled line with a ring on the value

Inline

  • For the large inline example (Utilitarian Large), I’ll add some extra text to show PRINTER BLACK INK and the state and the % symbol at the end.
  • Template: Flat
  • Centre: PRINTER BLACK INK {{ states(‘sensor.epson_wf_3520_series_black_ink’) }}%
  • Icon: printer

Conclusion

Thanks for getting to the end of this guide. Hopefully you have a better understanding of the Apple Watch integration with Home Assistant and now have some ideas on how to build out your actions and complications based on your own setup.

]]>
1579
Home Assistant with a Ring Doorbell in 2022 https://automation.moebius.site/home-assistant-with-a-ring-doorbell-in-2022/ Sun, 28 Aug 2022 11:07:00 +0000 http://automation.moebius.site/?p=1549 In this post, we will go through in detail how to integrate Home Assistant with a Ring doorbell, add an automation and download videos locally. If you haven’t seen my introduction video for first time users, please check it out as this video follows on directly from there including the Samba and Visual Studio Plugins used in this video.

What you need for this tutorial:

Step 1Adding the Ring Doorbell with Home Assistant

  • Open up your Home Assistant Browser
  • Navigate to Settings and then Device and Services
  • Select Add Integration in the bottom right
  • Search for Ring and select it
Home Assistant Ring Doorbell Tutorial
  • Follow the prompts to enter in the associated account details including 2FA if this has been enabled
  • Select the area where the device is located and then finish. If you need to create an area, select add new area and then add
  • The Ring integration should now be visible in the integration screen
Home Assistant Ring Doorbell Tutorial
  • If you go to the overview screen, the Ring sensors and key values should have been added as a new card
  • From here, you can see the sensors which show if a ding or motion is currently active, and historical details on the last activity, ding or motion. You can also see the volume settings and there are additional values to add such as battery level if you need them.
Home Assistant Ring Doorbell Tutorial
  • If you click on a value, you will be able to see the historical details.

Step 2Adding an Ring Doorbell Automation

Ok, now that we have integrated Home Assistant with the Ring platform, let’s add an automation for when something occurs with the doorbell.

  • Navigate to Settings and then Automations and Scenes
  • Click Create Automation and then Start with an empty automation
  • Let’s call this automation – “Front Door Light Motion” as I want to be able to turn on a switch when there is motion at the door
  • First we need to set up a Trigger to specify when the automation will start
  • Select Trigger type State and then the entity. We are going to select the binary sensor Front Door Motion
  • I will leave the From and To blank so that it switches on when the motion sensor is triggered
Front door light motion triggers
  • Now we need to select an Action, so select Action type call service and then switch turn on and then select the entity. In this case, I’m going to use the Front Door light switch.
Front door light motion actions
  • Once complete, Save the automation and return

Step 3 – Saving the Ring Doorbell Videos Locally

I’ve received a lot of requests on my older Ring video on how to save videos locally. Please note that you will need to have a Ring Plan for this to work.

  • To start, open up your configuration yaml file to add in the downloader module config.
  • Paste the following config and select an appropriate downloads folder:
Configuration.yaml file editing with download module
downloader: 
  download_dir: downloads 
  • Make sure you create also create a downloads folder that matches the config or you will get an error when trying to download
  • Go to Developer Tools and check that the configuration is fine and then restart Home Assistant.
Home Assistant Configuration validation
  • Back now in Settings, select Devices and Services and confirm the camera name so that we can use it in the next automation. e.g. camera.front_door
Ring Doorbell entity name
  • Go back to Settings, select Automations and Scenes
  • Click Create Automation and then Start with an empty automation
  • Let’s name this automation “Download Ring on Motion”
  • The Trigger again will be State and Front Door Motion
Download Ring Video on motion automation
  • You will need to add in a couple of Actions
  • Generally there will be some time required before the video is ready on the Ring Server, so I suggest adding a Delay step.
  • Add in “Wait for Time to Pass” and a 2 minute period to allow time for the video to upload to Ring and then download
  • Now we need a second action to download the file
  • Select “Call Service” and search for downloader
Ring Doorbell automation actions
  • Now click on the extra options to edit in YAML
  • Paste the code and adjust based on your camera name which we confirmed previously. In my case, it is camera.front_door and add in the filename script to name the file with an appropriate timestamp
Ring Doorbell automation Actions
data:
  url: "{{ state_attr('camera.front_door', 'video_url') }}"
  subdir: "{{ state_attr('camera.front_door', 'friendly_name') }}/{{ now().strftime("%m.%Y") }}"
  filename: "{{ now().strftime('%Y-%m-%d-at-%H-%M-%S') }}.mp4"
  • Save the automation and return to the previous screen
  • Trigger the automation to check if it worked
  • Navigate to the downloads directory using the Samba share addon and see if the video worked. This should show the last video recorded by the Ring.
Samba share download screenshot of Ring video
  • If the automation is triggered by actual motion, you will be able to see the history showing that it was triggered by state of Front Door Motion.
Download Ring on Motion History

Thanks for reading. If you liked this article, please like and subscribe to the YouTube video at the start of this page.

Additional Links:

]]>
1549
Home Assistant Beginner’s Guide in 2022 https://automation.moebius.site/beginners-guide-to-home-assistant-in-2022/ Sat, 27 Aug 2022 14:31:59 +0000 http://automation.moebius.site/?p=1518

Home Assistant is an Open source home automation tool that is constantly being updated and enhanced through contributions from a large DIY community. Home Assistant is perfect to run on a Raspberry Pi or a local server to bring together various different technologies for a cohesive ecosystem, create automation and rules and integrate with your smart speaker. This post is a Home Assistant Beginner’s Guide in 2022 and targeted to those who are planning to set up Home Assistant using for the first time and will cover the following topics:

  • Installing Home Assistant – Basic install from scratch on a Raspberry Pi
  • Understanding addons and top recommended Addons – Making use of the community and some of the great addons that are out there
  • Adding devices – Installing an example device for each installation type

Refer to my Instruction video here or follow the detailed instructions below:

What will you need:

  • Raspberry Pi (Model 3 or 4)
  • Power Supply (make sure the power supply is sufficient to avoid stability issues)
  • USB Cable for Raspberry Pi Power
  • > 32GB microSD card
  • Ethernet Cable

Installation

Step 1 – Determine which type of the Home Assistant build is correct for you.

Home Assistant is the program which we will be using and can pretty much be built to work on most key operating systems.

For the purposes of this article, we will be using Home Assistant for the Raspberry Pi.

Step 2 – Determine the correct image

Determine which device to which you will be deploying Home Assistant. For this guide, we will be installing onto a Raspberry Pi 3 Model B and have selected the Raspberry Pi 3 Model B and B+ 32bit image at the following link. You will need to copy the link to use in Step 4.

Home Assistant Beginner's Guide in 2022

Step 3 – Download and install flashing software

You will need software to install the Home Assistant image onto your MicroSD card. Etcher is a good option which is a free, open source software to flash devices.

Home Assistant Beginner's Guide in 2022

Step 4 – Flash Home Assistant image to MicroSD card

Use your preferred software to flash the image URL that you copied in Step 2.

Etcher image installation

Step 6 – Start up the Raspberry Pi

After inserting the MicroSD memory card, connecting Ethernet and power, you will need to wait for the device to initialise.

Step 7 – Connect to your Home Assistant installation

If all has gone well, you should now be able to connect to your Home Assistant installation through your browser. If your router supports mDNS then it will be accessible through http://homeassistant.local:8123 or else you will need to identify the IP address from your router e.g. http://192.168.x.x:8123. If it is not ready, then refresh and wait until you can see the “Preparing Home Assistant” screen.

Preparing Home Assistant

The screen will then automatically change and allow you to configure locale settings and create an initial account and password and confirm any discovered devices.

You should then be presented with the initial overview screen and potentially some devices that have automatically been detected on your network.

Home Assistant overview screen

The left sidebar has useful screens including:

  • Overview: The main screen to configure cards and views for managing and using your automations.
  • Energy: To view smart energy data
  • Map: To view devices sharing location in the Home Assistant App
  • Logbook: To view logs generated for Home Assistant system and linked services and devices
  • History: To view a historical view of logs
  • Media: To manage any configured media devices

Top Addons

Step 8 – Install Samba share add-on

You may already have some devices discovered, however you may need to edit configuration files to add additional devices and sensors. An easy way to do this is to add the Samba share add-on to allow editing outside of the browser. To do this:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for Samba share and then Install
Samba share addon
  • Once installed, Click Start
  • Click Edit Config and be sure to enter in a user name and password as Samba share will open your Home Assistant device to the network:
Samba share addon configuration screen
  • Click Save and return to the previous screen.
  • Click Start to enable Samba share

Step 9 – Edit your configuration files

Your configuration files should now be accessible through Windows Explorer e.g. \\homeassistant.local\config or an IP address (same IP as how you reached Home Assistant in the browser):

Configuration files shared folder

The key configuration files are:

  • automations.yaml – Used to specify your automations and the underlying scripts that are executed. These can also be added from within the Home Assistant interface
  • configuration.yaml – The key configuration file which is where you will add your manual components and key configurations
  • scripts.yaml – Used to specify a sequence of actions to be executed by Home Assistant when turned on
  • secrets.yaml – Used to store your user names, passwords, APIs and other sensitive information to avoid disclosing via the configuration.yaml file

Additional Hints:

  • I use Visual Studio Code to edit my files as it helps maintain the strict formatting for the configurations and is free and open source.
Visual Studio editing screen
  • If you make changes to your configuration files, you can run a validation over the files to check if you have made any errors. Go to Developer Tools > Check Configuration.
Check configuration screen

Step 10 – Install Studio Code Server Addon

In the hint noted above, I use a locally installed version of Visual Studio Code, however there are new addons available to edit in-browser with Studio Code. To install, follow these steps:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for Studio Code Server and then Install
  • Once installed, Start the addon
  • Select ‘Show in sidebar’ to make it visible
Studio Code Server tab

  • You will now be able to edit your configuration files from the browser
Studio Code Server configurations

Step 11 – Install MQTT Mosquito Broker

Local MQTT is one of the best options for communicating between devices and Home Assistant. Using MQTT locally will mean that in the event that you have power or internet issues, your devices can still communicate back and forth with Home Assistant. Toinstall, follow these steps:

  • Go to the Settings link in the left-hand side navigation panel
  • Click on Add-ons
  • Click Add-on store button
  • Click/search for MQTT Mosquito Broker and then Install
MQTT Mosquito Broker Addon

Installing MQTT takes a little bit more effort to set up and there are some additional steps.

  • First you should create a separate user account for MQTT and to do this, go to Settings, People and create an account such as mqttuser. You will need to allow the person to login and set an appropriate
  • You will need to select ‘allow login‘ to set a password and can further restrict this to allow log in from the local network.
Add user to Mosquito MQTT broker
  • If you want to lock down the account further, you can remove login ability afterwards and MQTT will still work
  • You now need to Configure the MQTT integration, so navigate to settings, configure button under MQTT
  • Follow the prompts to initialise and then under settings, enter in the mqtt user name and password that was just created
Edit Mosquito MQTT Broker options

Adding Devices

There are a few different ways to add devices including:

  • Automatically Discover
  • Installing Platform integration or Device
  • Manual

There are also different device classifications based on how the device communicates with Home Assistant:

ClassifierDescriptionProsCons
Assumed StateWe are unable to get the state of the device. Best we can do is to assume the state based on our last command.N/AN/A
Cloud PollingIntegration of this device happens via the cloud.Simple integration with cloud provider– Polling the state means that an update might be noticed later.
– Requires an active internet connection.
Cloud PushIntegration of this device happens via the cloud.– Simple integration with cloud provider
– Home Assistant will be notified as soon as a new state is available.
– Requires an active internet connection.
Local PollingOffers direct communication with device. Polling the state means that an update might be noticed later.– Does not require active internet connection
– Limited lag between messaging
– Privacy maintained as used within internal network
– Polling the state means that an update might be noticed later.
– More complex setup for devices generally required
Local PushOffers direct communication with device. Home Assistant will be notified as soon as a new state is available.– Does not require active internet connection
– Limited lag between messaging
– Privacy maintained as used within internal network
– Home Assistant will be notified as soon as a new state is available.
More complex setup for devices generally required
For more information, refer to the Home Assistant Guidance.

Step 12 – Adding an automatically discovered device

  • First of all, go to the “Settings” and “Devices and Services”.
  • Any discovered devices will have a blue heading noting ‘Discovered
Epson Printer discovered by Home Assistant
  • Home Assistant has picked up that I have an Epson printer on my network and shows on the screen.
  • Click Configure to follow the prompts to add the device and location

Step 13 – Adding a device through the UI

Next we will go through how to install a device or platform integration through the user interface.

  • Go back to Settings and “Device and Services”.
  • Select “Add Integration” in the bottom right
Add integration to Home Assistant
  • For this example, I’m going to add my Ring Doorbell
  • Search for the device or platform and select it
Ring integration with Home Assisstant
  • Enter in the associated account details including 2fA if this has been enabled.
  • Select the area where the device is located and then finish. If you need to create an area, select add new area and then add.
  • The Ring integration is now visible in the integration screen.
  • If you go to the overview screen, you can now see the last image on the camera and key details on last ding and motion.
Ring Overview Screen card

If you are interested in more Ring automations and details, check out my Ring integration post.

Step 14 – Adding a device manually

The final type of device is through manually adding it. This may be due to it not being supported or in the case I am about to show you, you want to add it through MQTT.

  • We can use Studio Code Server to edit our configuration files and add in the details.
  • For the example below, I have added in a Tasmota switch which will connect into my MQTT Broker
Ring configuration for downloader module
  • Now that we have updated the configuration file, navigate to the “Developer Tools” screen, use the Check Configuration button to see if the changes we made are valid and then Restart the system.
Home Assistant Beginner's Guide in 2022
  • Once it has restarted, in the Overview switch, I can see my Switch called “Coffee Machine” and I am able to turn it off and on.
Overview screen switch card

Hopefully you learnt something and enjoyed the Home Assistant Beginner’s Guide in 2022! If you haven’t checked out the video at the top of this page, please check it out and like and subscribe to my channel.

Good luck using Home Assistant!

]]>
1518
How to report from an Outlook Mailbox – Quick and Simple Reporting https://automation.moebius.site/how-to-report-from-an-outlook-mailbox-quick-and-simple-reporting/ Fri, 19 Nov 2021 11:03:57 +0000 http://automation.moebius.site/?p=1457

Have you ever wanted to report on an Outlook mailbox? There is a simple way using Microsoft Access to report on the emails in any mailbox and folder.

There are solutions out there to access reporting through an admin console, however there is a simpler way.

Simply:

  1. Open up Microsoft access and create a new database
  2. Click on External Data > New Data Source > From other Sources > Outlook Folder
  3. Then click on Import and OK
  4. You’ll then be shown the configured accounts in your Outlook application. Expand the mailbox you want to report on, and select the folder
  5. Now you have a data source with all the emails
  6. You can export this into Excel and use to report on email statistics.

That’s all!

]]>
1457
Introduction to Power Apps – First Time User Tutorial https://automation.moebius.site/introduction-to-power-apps-first-time-user-tutorial/ Wed, 17 Nov 2021 12:46:43 +0000 http://automation.moebius.site/?p=1449

Introduction

Today’s tutorial is to go through the basics of Microsoft Power Apps.

Power Apps is a tool from Microsoft that allows you to build custom apps with connectivity and functionality from Office 365 services and the Microsoft platform.

The main benefit of Power Apps is that it is so simple to create your own application. You don’t have to know how to code and the process to design, build and publish is very quick and simple.

This post is the first in a series of tutorials to cover the basics of PowerApps functionality. Please also check out my other videos for specific apps and use cases which I have come across while building various solutions.

Intent

  • Business Mobile applications: Simple applications to solve Business problems
  • Internal Applications: Due to licencing and technical difficulties with sharing, the main use is for internal applications
  • Browser or Mobile Device: Apps are able to be viewed through a browser or a mobile device that has access to a company’s Office 365 instance

Integrations:

As it is part of the Office 365 platform, it is very simple to integrate with a huge range of services such as SharePoint, Onedrive, SQL Server, Active Directory, Excel Online, etc. and there are also many third party connections available such as Google suite and Dropbox. Premium connectors also exist. Check out more details here.

Use Cases

Returning to the workplace:

  1. Desk Booking
  2. Visitor Registration
  3. Attendance Registration
  4. Communication Apps

More traditional applications:

  1. Leave/Holiday Management
  2. Employee Directories
  3. Expense Approval
  4. Employee Onboarding

How to use it

Open Power Apps

There are a couple of approaches to access PowerApps

For those that don’t have Office 365 licences, you will need to head to the Power Apps Website and click “Start Free” to start a trial.

However, if you or your company already have an Office 365 licence, then you can go through office.com, click “More Apps” in the bottom-left hand corner and click on Power Apps.

Create first app

There are a couple of options to quickly create your first app.

You have the ability to “start from data” using any number of sources that exist within the Office 365 environment. The most common and simple ones are SharePoint and Excel, however there are many other sources available as required.

The second most common option is to start your app from blank and build out the screens and sources yourself.

Prepare Data

For the first example, I’m going to select a SharePoint list as the data source.

It is very simple to create a SharePoint site and create a list.

Simply go to “SharePoint”, click create, then create list.

In the example list “ExpenseList”, I’ve pre-populated some entries to use for the sample app.

Create App

Back in PowerApps, I’m going to select the SharePoint option to “Start from Data”.

First I need to select the SharePoint site that I am using for this example.

Then select the list that was created and pre-populated.

Once Site and List are selected, click on the “Connect” button.

Basic Generated App

We are now in the Studio section of PowerApps and our very first app has been generated.

To test out the app as is, we can click on the “Play” Icon to Preview the app. You can also use F5 shortcut key to toggle between preview and edit.

Navigating – Preview App

Powerapps has automatically added a number of default icons and functionality for our list including.

  • A search bar – to allow you to search through the list.
  • Sort – To adjust the alphabetical sort of the list.
  • Add + Icon – To enter in a new record in the list.

Navigating – In Edit Mode

An alternative to going into the preview mode is to hold the “Alt” Key on the Keyboard to navigate  through the application while in Edit Mode.

As you hold the “Alt” key, you will see your cursor change when you are able to click and the color of the icons change if they have a hover color set.

Navigating – Tree View

The next key part to navigating through PowerApps is the “Tree View” on the left hand side.

This is a view of all the screens and underlying “Controls” within each screen.  “Controls” are what PowerApps refers to as things within your screen, such as Labels, Text, Icons, Inputs to name a few.

You will also see the “Components” tab which I explain how to use in a separate video, however that is used for reusable “Controls” across multiple screens. Examples include Menus, Headers and Footers.

In this generated app, the screens are set up in three different views. When using Lists (such as SharePoint), you will generally have three different Screens to view and manage the list data:

  • Browse Screen – to view the total records. This is generally the home screen to browse and drill down into the item
  • Detail Screen – to view the details of an individual item when navigating from the browse screen.
  • Edit Screen – to edit an existing item (via the Detail Screen) or create a new item (via the Browse Screen)

A few useful things to note about the Tree view is:

  • When you select the “Control” on the left, it will highlight on the right and so everything that is visible in your screen will correspond to a “Control” on the left.
  • You can also do it the other way around and select an item on the right to view the detail on the left
  • You can double click on the “Control” to rename to something more useful
  • You can change the depth of the individual items to bring forward or send backward (similar to other office applications)

Navigating – Properties

For an overall view of the properties, the next area of interest is on the right hand side. As shown on the screen, if you are selecting a “Text” control, you can also edit the text or update formatting, size or colors.

Another example is to modify the view of the list. PowerApps refers to these lists as “Galleries”. You can manually move around the content for each line, or you can use the Layout option to automatically adjust the content and spacing.

Other options include clicking on icons to change their icon, color, action, etc.

Customising the app

Chances are that you want to further customise the app including additional screens, additional navigation and this is very simple to do.

In this example, I would like to add a “Help” screen.

First of all, let’s create the new Screen to which we will navigate.

At the top of the screen, we have the “Insert” Ribbon and you will be able to select “New Screen”.

Let’s select a blank screen and once created, you can go to the new screen from the Tree View.

I’d suggest at this point, you rename the screen to something that makes sense. In this case, I will rename it to “HelpScreen”.

Now let’s create an icon that will be able to navigate towards the new screen.

Go back to your “Browse” screen and click on the Insert Ribbon. There are many other options for inserting controls, however let’s select an “Icon”.

You will likely want to adjust the Icon, colour and size to match the other “Icons”. In this case, let’s change the colour to white, shrink the size and change the position to match the other icons. You can also copy an existing icon and adjust and rename as required,

Now, you can’t click on the icon as it is, so we need to make the icon navigate to the “Help” Screen. To do this, we need to assign an action. At the top menu, click on “Action”, then “Navigate” and select the required screen and Transition effects. Once we have completed this, you will notice that a formula has been applied against the “OnSelect” property. This shows the function Navigate with the values of the screen and the transition effect.

Once the Navigate action has been assigned, you can now hold down “Alt” and click on the icon to navigate to our Help Screen.

In the Help Screen, we need a way to get back to the main screen, so to do this you can add a button or you can add an Icon using the back or home symbol.

In the same way that we applied the Navigate action for the Help Screen button, you can easily click on the icon, Action, Navigate and select the Home Screen.

The Help Screen is blank, so let’s start filling it in with some Text. To add text, you can either click on Insert Ribbon as previously shown, or you can use the + symbol on the left. Let’s click Text Lable and we can edit the text.

Other useful functions include

  • Reorder – To change the layering of the controls
  • Align – To move the control alignment within the screen e.g. left, right, center
  • Grouping – To group similar items to help moving or applying certain formulas and logic.

Now that our screen has some details and our home button is working, let’s click back through to our home screen.

Navigating – Formula Bar

The formula bar is located at the top of the screen and allows you to edit certain properties after clicking on a “Control”. An example is by clicking on something like this text and updating the details directly in the formula bar. You can select the various properties by using the dropdown menu on the left of the formula bar.

If you are familiar with Excel, the formula bar and formulas themselves are very similar.

For existing buttons, you can use the formula bar to understand the logic behind how these buttons have been defined.

You can also click through the formula symbol to see formulas that are available for use or for more information on each formula, you can click through to “Learn More” for an external guidance page.

Navigating – Navigation Bar

You now should have a fairly good view over the basics of the Studio when editing an application

There are a few additional areas of the studio that will be of use. On the left hand side, we can expand the navigation bar and see what each symbol means. We have gone through “Tree View” and “Insert”. The next section of importance is the “Data” view and this will show all the connections that your application has. As we only have the one SharePoint list, this is shown here. You can use this to “Refresh” data if the underlying data has changed and the Application has not automatically refreshed. If you have uploaded Media, then you can see the overall media in the application here.

Saving

To make sure that you don’t lose your application, let’s go back to Save and save a version. Once you have saved initially, Power Apps automatically saves. However, you might want to save at certain points to make sure you don’t lose anything.

Share

Now we have saved, we can go and Share the application.

In order for users to be able to use the shared application, you must share the underlying data with them.

In this example we used SharePoint and so users must have access to the underlying list data in SharePoint.

You can also access the application via the listed direct link.

Conclusion

If you found this video useful, make sure you check out other videos and subscribe to my YouTube channel.

Feel free to leave a comment if you are interested in seeing something specific covered in a future video.

]]>
1449
Connecting a stepper motor to Hassio/Home Assistant using a NodeMCU via MQTT https://automation.moebius.site/connecting-a-stepper-motor-to-hassio-home-assistant-using-a-nodemcu-via-mqtt/ Wed, 11 Sep 2019 13:56:50 +0000 http://automation.moebius.site/?p=304 What you will need (or equivalent):

Step 1 – Connect your NodeMCU to the driver board and stepper motor

First of all, connect up your NodeMCU to the controller board using the following pin mappings. These are required as the code used below maps to these pins.

Step 2 – Install Arduino software, required libraries and configure

  • Software Install:
  • Board Support:
  • Install Board Support:
    • Install the board to allow additional board support for the NodeMCU. Select Tools –> Board –> Board Manager
    • Once loaded, search for ‘ESP’ and select and install the ‘ESP8266’ board
  • Install Libraries:
    • There are two libraries required for this code, ‘PubSubClient’ and ‘Stepper’
    • Click on Sketch –> Include Library –> Manage Libraries
    • When it has loaded, search for ‘Pubsub’ and select ‘PubSubClient’ and install
    • Then install ‘Stepper’ library by searching for ‘Stepper’ and installing
  • Configure Board:
    • Now you will need to configure the board by selecting board under Tools –> Board and find the ‘NodeMCU 1.0 (ESP-12E Module)’
    • Select the following options:
      • Upload frequency speed of ‘115200’
      • CPU frequency of ’80 MhZ’
      • Flash Size of ‘4M’
    • You shouldn’t need to change the others settings, so leave as default
    • Select the Port once you have plugged the NodeMCU into your computer. In my case it is coming up as ‘COM5’.

Step 3 – Configure Home Assistant MQTT

  • In your Home Assistant configuration.yaml file, make sure you have added in the MQTT component and selected a password
  • You can write the password directly in here or use the secrets file as I’ve done below and leveraged off the existing http_password:
mqtt:
password: !secret http_password

Step 3 – Upload and compile code on NodeMCU

For the code used in this example, I have used the original code from osoyoo.com (http://osoyoo.com/2017/05/17/nodemcu-lesson-16-stepper-motor-mqtt/) and adjusted as required. For a copy of the custom code used, download this file and update the following details:
  • The wifi ‘ssid’ and ‘password’ to your own network
  • The ‘mqtt_server’ to the IP address of your Home Assistant
  • Update the client.subscribe(“chickenDoor”) to the relevant topic. I’ve put ‘chickenDoor’ which is the topic that will be published to via Home Assistant and used in my scripts in the steps below
For noting:
  • ‘userName’ is the default home assistant MQTT username (i.e. ‘homeassistant’) and ‘passWord’ is the one that was selected in the MQTT component in your configuration.yaml file in Step 3
  • ‘clientId’ doesn’t matter for HomeAssistant, so put anything here
  • Changes to the original code:
    • I have added a few additional options such as the clockwise and counterclockwise loop (values 3 and 4), which runs the stepper 72 times. This is the amount I need my stepper to spin for the chicken door to go fully up and down. I’ve also put a delay of 50 so that it gives the motor enough time to think and continues the revolution immediately
    • I’ve also added in another option to turn off the motor (value 0) as the stepper will stay on and stay in place at the end of the cycle unless directed to turn off
    • Some other tweaks to make the Serial monitor show additional details and status

Step 4 – Configure Home Assistant/Hassio Scripts & Automations

  • Now in Home Assistant, I’ve made a few scripts which publish to the ChickDoor topic. These correspond to the values in the code, 1 and 2 for incremental spins and 3 and 4 for longer spins. I’ve also put in the stepper off for a value of 0.
  • I’ve also added a couple of automations to open and close the door. The first one is to close the chicken door at sunset.
  • This uses the sun trigger for when it is sunset and it will call the chicken door close (anticlockwiseloop) script and then turn off the stepper.
Scripts:
stepper_clockwise:
  alias: Chicken Door Step Up
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “1”
stepper_anticlockwise:
  alias: Chicken Door Step Down
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “2”
stepper_clockwiseloop:
  alias: Chicken Door Full Up
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “3”
    – service: script.turn_on
      data:
entity_id: script.stepper_off
stepper_anticlockwiseloop:
  alias: Chicken Door Full Down
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “4”
    – service: script.turn_on
      data:
        entity_id: script.stepper_off
stepper_off:
  alias: Chicken Door Off
  sequence:
    – service: mqtt.publish
      data:
        topic: “chickenDoor”
        payload: “0”
Sunrise Automation
The following automation is configured to open the chicken door and execute the clockwise loop script when the sun is rising.
Sunset Automation
The following automation is configured to close the chicken door and execute the anticlockwise loop script when the sun is setting. I’ve added a delay because my chickens like to stay out a bit later.

Step 5 – Compile and Upload

  • Just to make sure everything is fine, compile the code by clicking ‘Sketch’ –> ‘Verify/Compile’
  • Once completed, click ‘Upload’ to load the code into the NodeMCU
  • To view the status of the device, click ‘Tools’ –> ‘Serial Monitor’ (do this while it is uploading so that you don’t miss the log when the device starts)
  • If all is well, the Serial Monitor will show ‘Attempting MQTT connection.. connected’.

Step 6 – Test the scripts

  • Execute the scripts that were configured in ‘Step 4’:
  • When executing scripts, the Serial Monitor should show the commands received and action taken:
If everything went well then you should have a working stepper motor. This is a really cheap way to get a stepper motor working and connected to your Home Assistant/Hassio. There will be other uses besides a chicken door (e.g. blinds). Feel free to post here or on my video for any suggestions, feedback or questions.]]>
304
Home Assistant: Cheap and Easy Sprinkler Automation https://automation.moebius.site/hassio-home-assistant-cheap-and-easy-sprinkler-automation/ Wed, 30 Jan 2019 12:10:10 +0000 http://automation.moebius.site/?p=278 What you will need:
  • Sonoff Switch – I’m using the Sonoff Wifi Smart Switch with Tasmota firmware installed. See my video on how to install the switches ($15.57)
  • 24V Solenoid Valve – A quick search on Amazon. will find something similar
  • 24V Power Supply (1A 24W) – This one from Amazon will work
  • Dual end hose connector
  • Optional items
    • Reducer
    • Metal adapters – I bought these from Bunnings ($10.31 x 2)
  • Assumed existing items
    • Existing pump/mains water supply with a tap head
    • Existing Sprinkler System and pipes
Total Cost: $72.01 (or $92.63 with optional parts) If you haven’t already seen my initial Hassio setup guide, please visit this link.

Step 1 – Connect the Hose parts

Note: I’ve tried to keep the connections as simple as possible to avoid failure of connectors and potentially draining your tank or wasting mains water.
  • Add a reducer between the brass tap adapter (optional) and the tap to limit the amount of water coming through and to prevent unnecessary pressure on the connectors
  • Screw the brass top adapters (brass is optional — but recommended to ensure hose parts do not break and waste water) to the tap and the solenoid value
  • Connect the solenoid valve together with the tap using the Dual end hose connector

Step 2 – Connect the power

  • Wire up the power plug adapter to the solenoid cable
  • Plug the Sonoff switch into the power point
  • Plug the power supply in the Sonoff Switch
  • Turn on the power and test that the solenoid valve is working as expected

Step 3 – Ensure everything is water safe

Given that you are working around water, ensure the power supply, switch and power plugs are protected from water. I have taped up the connectors and used a plastic container for the switch and keeping my electric components in my pump’s water safe housing.

Step 4 – Turn on the water supply and power

Turn on the water supply and power and test if the sprinklers are turning on as expected.

Step 5 (Optional) – Install Automations for automatic sprinkler shutoff

If you are as forgetful as I am, you might want to add an automation to automatically shut off the sprinkler after a set period of time. I’ve set the following to turn off the switch after 15 minutes:   That’s all it takes for a simple, cheap automated sprinkler system. If you have any comments or questions, please feel free to leave them below.]]>
278
Top basic and advanced Excel formulas and shortcuts https://automation.moebius.site/top-basic-and-advanced-excel-formulas-and-shortcuts/ Fri, 18 Jan 2019 11:33:43 +0000 http://automation.moebius.site/?p=152 Whether you love or hate using Excel, it is an extremely useful tool in a workplace or even home to easily calculate, analyse, audit and display data in a logical and meaningful way.

I’ve been working in a number of roles over the past decade including Technology auditing and risk management and Excel is one of the key tools that I have needed to be familiar with as part of my daily work. Knowing the formulas listed below can help to change an otherwise manual task into an automatic and repeatable process. This post assumes you have a basic knowledge of Excel and is to take you through some very useful formulas for both basic and advanced levels.

For more information on each example, click through to see a demonstration .

Basic Formulas

Summing up numbers

SUM=SUM(number1, [number2], …)Adds all the numbers in a range of cells
SUMIF=SUMIF(range, criteria, [sum_range])Adds the cells specified by a given condition or criteria
SUMIFS=SUMIFS(sum_range, criteria_range1, criteria1, …)Adds the cells specified by a given set of conditions or criteria

Counting Cells

COUNT=COUNT(value1, [value2], …)Counts the number of cells in a range that contains numbers
COUNTIF=COUNTIF(range, criteria)
Counts the number of cells within a range that meet the given condition
COUNTIFS=COUNTIFS(criteria_range1, criteria1, …)Counts the number of cells specified by a given set of conditions or criteria

Basic Statistics

AVERAGE=AVERAGE(number1, [number2], …)Returns the average (arithmetic mean) of its arguments, which can be numbers or names, arrays, or references that contain numbers
MIN=MIN(number1, [number2], …)Returns the smallest number in a set of values. Ignores logical values and text
MAX=MAX(number1, [number2], …)Returns the largest number in a set of values. Ignores logical values and text
MEDIAN=MEDIAN(number1, [number2], …)Returns the median, or the number in the middle of the set of given numbers
MODE=MODE(number1, [number2], …)Returns the most frequently occurring, or repetative value, in an array or range of data

Logic / Conditional

IF=IF(logical_test, [value_if_true], [value_if_false])Checks whether a condition is met, and returns one value if TRUE and another value if FALSE
AND=AND(logical1, [logical2], …)Checks whether all arguments are TRUE, and returns TRUE if all arguments are TRUE
OR=OR(logical1, [logical2], …)Checks whether any of the arguments are TRUE and returns TRUE or FALSE. Returns FALSE only if all arguments are false
NOT=NOT(logical)Changes FALSE to TRUE and TRUE to FALSE
ISNA=ISNA(value)Checks whether a value is #N/A, and returns TRUE or FALSE
ISERR=ISERR(value)Checks whether a value is an error other than #N/A, and returns TRUE or FALSE
ISBLANK=ISBLANK(value)Checks whether the reference is to an empty cell, and returns TRUE or FALSE

Date Conversion

EOMONTH=EOMONTH(start_date, months)Returns the serial number of the last day of the month before or after a specified number of months
and start of month
DAY=DAY(serial_number)Returns the day of the month, a number from 1 to 31
MONTH=MONTH(serial_number)Returns the month, a number from 1 (January) to 12 (December)
YEAR=YEAR(serial_number)Returns the year of a date, an integer in the range 1900 and 9999
DATE=DATE(year, month, day)Returns the number that represents the date in Microsoft Excel date-time code.
Julian date example

Date Calculation

DAYS=DAYS(end_date, start_date)Returns the number of days between two dates
NETWORKDAYS=NETWORKDAYS(start_date, end_date, [holidays])Returns the number of whole workdays between two dates
NOW=NOW()Returns the current date and time formatted as a date and time
TODAY=TODAY()Returns the current date formatted as a date

Data Cleanup

TRIM=TRIM(text)Removes all space from a text string except for single spaces between words
CONCATENATE=CONCATENATE(text1, [text2], …)Joins several text strings into one text string
LEN=LEN(text)Returns the number of characters in a text string
RIGHT=RIGHT(text, [num_chars])Returns the specified number of characters from the end of a text string
LEFT=LEFT(text, [num_chars])Returns the specified number of characters from the start of a text string
MID=MID(text, start_num, num_chars)Returns the characters from the middle of a text string, given a starting position and length

Rounding

ROUND=ROUND(number, num_digits)Rounds the number to a specified number of digits
ROUNDUP=ROUNDUP(number, num_digits)Rounds a number up, away from zero
ROUNDDOWN=ROUNDDOWN(number, num_digits)Rounds a number down, toward zero

Looking up Values

VLOOKUP
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Looks for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify. By default, the table must be assorted in ascending order.
INDEX
=INDEX(array, row_num, [column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range
MATCH
=MATCH(lookup_value, lookup_array, [match_type])
Returns the relative position of an item in an array that matches a specified value in a specified order
Wildcards“*”
Usually followed or preceded by the concatenation & to be used for lookups or formulas.

Calculations on a filtered list

SUBTOTAL=SUBTOTAL(function_num, ref1, [ref2], …)Returns a subtotal in a list or database

Key Excel Shortcuts

Edit CellF2To edit a cell
Undo / RedoCtrl + z / Ctrl + yUsed to undo a mistake or to redo what you mistakenly undid
New Line in cellAlt + EnterTo add a new line character into a cell
New RowCtrl + “+”A quick way to insert a large number of new rows instead of right clicking and inserting row
Absolute ReferncesF4While editing a cell, you can rotate through the “$” for cell references for absolute references. This is useful to avoid having to type it in manually
Skip to end of rowCtrl + ArrowTo quickly navigate to the end of the row (or next blank cell)
Autofill cellsCtrl + DWhile highlighting the cells, to fill cells with a value or autofill the formula

Key Excel Tools

Conditional FormattingLocated under Ribbon Home > Styles > Conditional FormattingBased on a certain criteria, format a cell (e.g. font, background colour, etc.)
Slicer FiltersLocated under Ribbon Design > Tools > Insert Slicer (only when selecting a table)Add a filter that can be clicked based on the available values. Useful for dashboards.
Freeze PanesLocated under Ribbon View > Window > Freeze PanesLock the view of columns or rows so that scrolling will keep the specified rows/columns visible
Text to columnsLocated under Ribbon Data > Data Tools > Text to ColumnsFor a pasted data source, transform the data into columns based on either specific characters (e.g. “,”) or based on a specified fixed width
Remove DuplicatesLocated under Ribbon Data > Data Tools > Remove DuplicatesSelect a list of cells and remove all the duplicates
GroupLocated under Ribbon Data > Outline > GroupGroup columns or rows to make an outline (i.e. ability to expand or collapse)

]]>
152
Excel Looking up values (VLOOKUP, INDEX, MATCH https://automation.moebius.site/excel-looking-up-values-vlookup-index-match/ Fri, 18 Jan 2019 11:28:00 +0000 http://automation.moebius.site/?p=246 VLOOKUP =VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]) Looks for a value in the leftmost column of a table, and then returns a value in the same row from a column you specify. By default, the table must be assorted in ascending order. INDEX =INDEX(array, row_num, [column_num]) Returns a value or reference of the cell at the intersection of a particular row and column, in a given range MATCH =MATCH(lookup_value, lookup_array, [match_type]) Returns the relative position of an item in an array that matches a specified value in a specified order Wildcards “*” Usually followed or preceded by the concatenation & to be used for lookups or formulas.

 

]]>
246
Excel Basic Statistics (AVERAGE, MIN, MAX, MEDIAN, MODE) https://automation.moebius.site/excel-basic-statistics-average-min-max-median-mode/ Fri, 18 Jan 2019 11:24:53 +0000 http://automation.moebius.site/?p=232 AVERAGE =AVERAGE(number1, [number2], …) Returns the average (arithmetic mean) of its arguments, which can be numbers or names, arrays, or references that contain numbers MIN =MIN(number1, [number2], …) Returns the smallest number in a set of values. Ignores logical values and text MAX =MAX(number1, [number2], …) Returns the largest number in a set of values. Ignores logical values and text MEDIAN =MEDIAN(number1, [number2], …) Returns the median, or the number in the middle of the set of given numbers MODE =MODE(number1, [number2], …) Returns the most frequently occurring, or repetative value, in an array or range of data

AVERAGE / MEDIAN / MODE

MIN / MAX

]]>
232