Skip to content

Instantly share code, notes, and snippets.

View jcallaghan's full-sized avatar

James Callaghan jcallaghan

View GitHub Profile
@jcallaghan
jcallaghan / Home-Assistant - Air Freshener Entities.yaml
Created March 11, 2020 20:02
These entities are used with my IoT air freshener to provide additional data points for my to study.
input_datetime:
air_freshener_changed_date:
name: Bathroom Air Freshener
has_date: true
has_time: false
icon: mdi:air-purifier
counter:
air_freshener_bathroom:
name: Bathroom Air Freshener
@jcallaghan
jcallaghan / Home-Assistant - Task Scheduler - Unlocked.xml
Created March 2, 2020 10:33
These are exported from Task Scheduler and can be imported back. These use the launcher VB script to call the Home Assistant Service PowerShell script to turn an input_boolean on or off when workstation is locked or unlocked.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-01-18T11:20:27.7660341</Date>
<Author>James Callaghan</Author>
<URI>\Home Assistant\Desk Lights on with Unlock</URI>
</RegistrationInfo>
<Triggers>
<SessionStateChangeTrigger>
<Enabled>true</Enabled>
@jcallaghan
jcallaghan / Home-Assistant - Desk Lights Automation.yaml
Created March 1, 2020 21:55
Example automation that turns my desk lights on based on the state of my input_boolean.
alias: 'Office - James desk lights on/off with workstation state'
trigger:
- platform: state
entity_id: input_boolean.james_desk
action:
- service: scene.turn_on
@jcallaghan
jcallaghan / Home-Assistant - Workstation Locked.yaml
Created March 1, 2020 21:49
This is an example of the input_boolean I use to indicate if my workstation is locked or not.
input_boolean:
james_desk:
name: James' Workstation Unlocked
initial: false
icon: mdi:desk
@jcallaghan
jcallaghan / Home-Assistant - Task Scheduler - Locked.xml
Last active March 2, 2020 10:33
These are exported from Task Scheduler and can be imported back. These use the launcher VB script to call the Home Assistant Service PowerShell script to turn an input_boolean on or off when workstation is locked or unlocked.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2020-01-18T11:19:09.6988975</Date>
<Author>James Callaghan</Author>
<URI>\Home Assistant\Desk Lights off with Lock</URI>
</RegistrationInfo>
<Triggers>
<SessionStateChangeTrigger>
<Enabled>true</Enabled>
@jcallaghan
jcallaghan / Home-Assistant - Invoke-HomeAssistantService.ps1
Last active March 1, 2020 15:56
This script calls the Home Assistant API with a service call and entity ID passed as parameters.
# This leverages Flemming's Home Assistant Module https://github.com/flemmingss/Home-Assistant-PowerShell-Module
Param(
[Parameter(Mandatory=$true)][string]$service,
[Parameter(Mandatory=$true)][string]$entity_id
)
$home_assistant_ip = "127.0.0.1"
$home_assistant_port = "8123"
$home_assistant_token = "token key here"
@jcallaghan
jcallaghan / Home-Assistant - Task Scheduler Launcher.vbs
Last active March 1, 2020 18:32
This is triggered by Task Scheduler tasks and in turn calls a PowerShell script. This is to avoid the PowerShell console from flashing up.
Set objShell = CreateObject("Wscript.Shell")
Set args = Wscript.Arguments
For Each arg In args
Dim PSRun
PSRun = "powershell.exe -WindowStyle hidden -ExecutionPolicy bypass -NonInteractive -File " & arg
objShell.Run(PSRun),0
Next
WScript.Quit
@jcallaghan
jcallaghan / Home-Assistant-Actionable-Push.yaml
Last active February 13, 2020 10:05
Example configuration and automation for actionable push notifications - this is triggered by motion when away and prompts me to sound an aggressive dog bar throughout the house using my Sonos speakers.
# Config
ios:
push:
categories:
- name: Alarm
identifier: 'alarm'
actions:
@jcallaghan
jcallaghan / Highlighted code.html
Last active October 24, 2019 16:41
Example Gist to show the highlighted row URL.
Multiple lines uses a -L15-L19 at the end of the URL where as just a single line used - L13
https://gist.github.com/jcallaghan/611ef3e2f400b5f089354c5d780d8c07#file-highlighted-code-html-L13
https://gist.github.com/jcallaghan/611ef3e2f400b5f089354c5d780d8c07#file-highlighted-code-html-L15-L19
<!--Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent eu velit pulvinar, porttitor neque sit amet,
lobortis erat. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec mi
orci, porta et metus eu, blandit ullamcorper neque. Morbi auctor neque tellus, nec lobortis arcu malesuada nec.
Suspendisse eleifend ligula nec massa gravida, id ultrices quam commodo. Nunc malesuada ornare consequat. Morbi
elementum neque sit amet euismod rhoncus. Duis pulvinar libero ornare risus vestibulum rhoncus. Nunc fringilla
@jcallaghan
jcallaghan / Recipe.html
Last active October 24, 2019 14:51
WordPress recipe boilerplate with schema tags. #Website
<div itemtype="http://schema.org/Recipe">
<!-- wp:heading -->
<h2 class="cooking-heading" itemprop="name" itemtype="http://schema.org/Recipe">???</h2>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<span class="cooking-description" itemprop="description">???</span>
<!-- /wp:paragraph -->