Skip to content

Instantly share code, notes, and snippets.

View jcallaghan's full-sized avatar

James Callaghan jcallaghan

View GitHub Profile
@jcallaghan
jcallaghan / ESPHome - Air Freshener Config.yaml
Created March 12, 2020 23:33
This is the ESPHome configuration I use for my IoT air fresheners.
substitutions:
system_name: esph_dining_room_air_freshener
friendly_name: Esph Dining Room Air Freshener
esphome:
name: ${system_name}
platform: ESP32
board: esp32doit-devkit-v1
wifi:
# Remotely create a number of content databases using New-SPContentDatabase
# https://docs.microsoft.com/en-us/powershell/module/sharepoint-server/new-spcontentdatabase
$SPServers = @("server1")
$webApp = "https://webapp.domain.com"
$databasesRequired = 10
$databasePrefix = "AG5Q_Prefix_Content"
$databaseServer = "DBserver.domain.com"
# Prepare remote PS session and load SP module
@jcallaghan
jcallaghan / Home-Assistant - Air Freshener Deep Sleep.yaml
Created March 13, 2020 18:41
The following is used to operate the air fresheners when they're in deep sleep mode.
Deep sleep switch
@jcallaghan
jcallaghan / Home-Assistant - Sonos Say - Automation.yaml
Last active March 13, 2020 16:09
I use the following components to play text-to-speech (TTS) on one or many of my Sonos speakers.
# https://www.home-assistant.io/docs/automation/
automation: !include_dir_list ../automations
alias: 'Bathroom - Bath full alarm'
id: bath_full
trigger:
# Trigger when the water sensor in the bath turns on
@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 - 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 - 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 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