Ansible files

This commit is contained in:
Martin Bauer
2020-03-30 22:49:44 +02:00
parent 274f15b213
commit 4308dae03d
33 changed files with 524 additions and 184 deletions

58
pis/configs/asound.conf Normal file
View File

@@ -0,0 +1,58 @@
pcm.soundcard {
type hw
card {{alsa_card_name}}
}
ctl.dmixer {
type hw
card {{alsa_card_name}}
}
pcm.dmixer {
type dmix
ipc_key 1024
slave {
pcm "soundcard"
channels 2
}
}
pcm.dmixer_plug {
type plug
slave {
pcm "dmixer"
}
}
pcm.softvol_shairport {
type softvol
slave {
pcm "dmixer_plug"
}
control {
name "ShairPort-Sync Volume"
card 0
}
}
pcm.softvol_squeezelite {
type softvol
slave {
pcm "dmixer_plug"
}
control {
name "SqueezeLite Volume"
card 0
}
}
pcm.softvol_effects {
type softvol
slave {
pcm "dmixer_plug"
}
control {
name "Effect Volume"
card 0
}
}

View File

@@ -0,0 +1,12 @@
{
"ha_url": "https://ha.bauer.tech",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxNjkxMWIzZmQ4ZWU0NDI0OTg0MjA0ZDllMDhkNGRlMCIsImlhdCI6MTU3ODE3MDU5MSwiZXhwIjoxODkzNTMwNTkxfQ.i7CdXEZy9DV9KPHAl-msK0rOfIUlPYo4zwwJ4UGhXuc",
"dht_pin": "D12",
"polling_sleep_time_seconds": 5,
"ha_temp_sensor_name": "{{sensor_room_name_ascii|lower}}_dht22_temperatur",
"ha_temp_friendly_name": "{{sensor_room_name}} Temperatur",
"ha_humidity_sensor_name": "{{sensor_room_name_ascii|lower}}_dht22_luftfeuchtigkeit",
"ha_humidity_friendly_name": "{{sensor_room_name}} Luftfeuchtigkeit"
}

View File

@@ -0,0 +1,53 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import requests
import json
import time
import board
import adafruit_dht
config = json.load(open("/etc/dht22_sensing.json"))
dht_device = adafruit_dht.DHT22(getattr(board, config['dht_pin']))
def send_to_home_assistant(temperature, humidity):
headers = {
'x-ha-access': config['token'],
'Authorization': "Bearer {}".format(config['token'])
}
temperature_url = "{}/api/states/sensor.{}".format(config['ha_url'], config['ha_temp_sensor_name'])
temperatur_data = {
"state": str(temperature),
"attributes": {
"device_class": "temperature",
"friendly_name": config['ha_temp_friendly_name'],
"unit_of_measurement": "°C"
}
}
requests.post(temperature_url, json=temperatur_data, headers=headers)
humidity_url = "{}/api/states/sensor.{}".format(config['ha_url'], config['ha_humidity_sensor_name'])
humidity_data = {
"state": str(humidity),
"attributes": {
"device_class": "humidity",
"friendly_name": config['ha_humidity_friendly_name'],
"unit_of_measurement": "%"
}
}
requests.post(humidity_url, json=humidity_data, headers=headers)
def sense():
try:
send_to_home_assistant(dht_device.temperature, dht_device.humidity)
except RuntimeError as error:
# Errors happen fairly often, DHT's are hard to read, just keep going
print(error.args[0])
time.sleep(config['polling_sleep_time_seconds'])
while True:
sense()

View File

@@ -0,0 +1,10 @@
[Unit]
Description=DHT22 Temperature Humidity Sensing
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /usr/bin/dht22_sensing
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,3 @@
ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio_ir_recv", SYMLINK+="lirc-rx"
ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="gpio-ir-tx", SYMLINK+="lirc-tx"
ACTION=="add", SUBSYSTEM=="lirc", DRIVERS=="pwm-ir-tx", SYMLINK+="lirc-tx"

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,79 @@
#
# this config file was automatically generated
# using lirc-0.7.0(any) on Sun Nov 28 20:25:09 2004
#
# contributed by
#
# brand: Hauppauge 350
# Created: G.J. Werler (The Netherlands)
# Project: Mythtv Fedora Pundit-R www.mythtvportal.com
# Date: 2004/11/28
# model no. of remote control: Hauppauge A415-HPG
# devices being controlled by this remote: PVR-350
#
begin remote
name Hauppauge
bits 13
flags RC5|CONST_LENGTH
eps 30
aeps 100
one 969 811
zero 969 811
plead 1097
gap 114605
toggle_bit 2
begin codes
KEY_GOTO 0x00000000000017BB
KEY_POWER 0x00000000000017BD
KEY_TV 0x000000000000179C
KEY_VIDEO 0x0000000000001798
KEY_MUSIC 0x0000000000001799
KEY_PICTURES 0x000000000000179A
KEY_EPG 0x000000000000179B
KEY_RADIO 0x000000000000178C
KEY_UP 0x0000000000001794
KEY_LEFT 0x0000000000001796
KEY_RIGHT 0x0000000000001797
KEY_DOWN 0x0000000000001795
KEY_OK 0x00000000000017A5
KEY_EXIT 0x000000000000179F
KEY_MENU 0x000000000000178D
KEY_VOLUMEUP 0x0000000000001790
KEY_VOLUMEDOWN 0x0000000000001791
KEY_CHANNEL 0x0000000000001792
KEY_MUTE 0x000000000000178F
KEY_CHANNELUP 0x00000000000017A0
KEY_CHANNELDOWN 0x00000000000017A1
KEY_RECORD 0x00000000000017B7
KEY_STOP 0x00000000000017B6
KEY_PREVIOUS 0x00000000000017B2
KEY_PLAY 0x00000000000017B5
KEY_FORWARD 0x00000000000017B4
KEY_REWIND 0x00000000000017A4
KEY_PAUSE 0x00000000000017B0
KEY_FASTFORWARD 0x000000000000179E
BTN_1 0x0000000000001781
BTN_2 0x0000000000001782
BTN_3 0x0000000000001783
BTN_4 0x0000000000001784
BTN_5 0x0000000000001785
BTN_6 0x0000000000001786
BTN_7 0x0000000000001787
BTN_8 0x0000000000001788
BTN_9 0x0000000000001789
KEY_NUMERIC_STAR 0x000000000000178A
BTN_0 0x0000000000001780
KEY_NUMERIC_POUND 0x000000000000178E
KEY_RED 0x000000000000178B
KEY_GREEN 0x00000000000017AE
KEY_YELLOW 0x00000000000017B8
KEY_BLUE 0x00000000000017A9
end codes
end remote

View File

@@ -0,0 +1,11 @@
[lircd]
nodaemon = False
driver = default
device = /dev/lirc0
listen = 0.0.0.0:2222
output = /var/run/lirc/lircd
pidfile = /var/run/lirc/lircd.pid
plugindir = /usr/lib/arm-linux-gnueabihf/lirc/plugins
permission = 666
allow-simulate = No
repeat-max = 600

View File

@@ -0,0 +1 @@
include "hauppauge.conf"

View File

@@ -0,0 +1,14 @@
WELCOME IN THE BEDROOM
!__________!
|____ ____|
_____ {____}{____} _____
__|_*_|__%%%%%%%%%%%%__|_*_|
| | %%%%%%%%%%%%%% | |
%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%
/||||||||||||||||||||\
||||||||||||||||||||||

View File

@@ -0,0 +1,18 @@
WELCOME IN THE KITCHEN
___
.' _ '.
/ /` `\ \
| | [__]
| | {{
| | }}
_ | | _ {{
___________<_>_| |_<_>}}________
.=======^=(___)=^={{====.
/ .----------------}}---. \
/ / {{ \ \
/ / }} \ \
( '=========================' )
'-----------------------------'

4
pis/configs/motd/newrpi Normal file
View File

@@ -0,0 +1,4 @@
THIS IS A NEW RASPI - CONFIGURE IT!

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Turn Raspi LEDs off at boot
[Service]
ExecStart=/usr/sbin/raspi-leds-off.sh
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,7 @@
#!/bin/bash
echo none > /sys/class/leds/led0/trigger
echo none > /sys/class/leds/led1/trigger
echo 0 >/sys/class/leds/led0/brightness
echo 0 >/sys/class/leds/led1/brightness

View File

@@ -0,0 +1,9 @@
general =
{
name = "{{shairport_name}}";
};
alsa =
{
output_device = "softvol_shairport";
};

View File

@@ -0,0 +1,3 @@
SL_NAME="{{squeezelite_name}}"
SL_SOUNDCARD="softvol_squeezelite"
SB_SERVER_IP="192.168.178.80"