diff --git a/full.yml b/full.yml index ba6cecc..56d5708 100644 --- a/full.yml +++ b/full.yml @@ -1,17 +1,27 @@ --- -- hosts: bedroompi, kitchenpi - roles: - - pi-standard-setup - - pi-squeezelite-custom - - pi-shairport - - pi-lirc - - pi-dhtsensor +#- hosts: bedroompi, kitchenpi +# roles: +# - pi-standard-setup +# - pi-squeezelite-custom +# - pi-shairport +# - pi-lirc +# - pi-dhtsensor +# +#- hosts: esszimmerradio +# roles: +# - pi-standard-setup +# - pi-squeezelite-custom +# - pi-shairport +# - pi-lirc +# - pi-sispmctl +# -- hosts: esszimmerradio +- hosts: musikserverwohnzimmeroben roles: - - pi-standard-setup - - pi-squeezelite-custom - - pi-shairport - - pi-lirc - - pi-sispmctl + #- pi-standard-setup + #- pi-squeezelite-custom + #- pi-shairport + - pi-irserver #- pi-dhtsensor + #- pi-squeezeserver + diff --git a/inventory.yml b/inventory.yml index 98735de..efff5a0 100644 --- a/inventory.yml +++ b/inventory.yml @@ -21,9 +21,17 @@ all: sensor_room_name: Küche esszimmerradio: # oben, eltern squeezelite_name: Esszimmer - shairport_name: EsszimmerRadio - wifi_ssid: BauerWLAN + shairport_name: EsszimmerRadioOben + alsa_card_name: Device + squeezeserver: 192.168.178.100 + configure_wifi: true + musikserverwohnzimmeroben: # oben, eltern + squeezelite_name: Wohnzimmer + shairport_name: WohnzimmerRadioOben alsa_card_name: 0 + squeezeserver: 192.168.178.100 + sensor_room_name_ascii: wohnzimmeroben + sensor_room_name: WohnzimmerOben newrpi: squeezelite_name: MyTestRaspberry shairport_name: MyTestRaspberry @@ -35,5 +43,8 @@ all: ansible_user: root ansible_python_interpreter: /usr/bin/python3 squeezeserver: 192.168.178.80 + router_ip: 192.168.178.1 home_assistant_url: https://ha.bauer.tech home_assistant_token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIxNjkxMWIzZmQ4ZWU0NDI0OTg0MjA0ZDllMDhkNGRlMCIsImlhdCI6MTU3ODE3MDU5MSwiZXhwIjoxODkzNTMwNTkxfQ.i7CdXEZy9DV9KPHAl-msK0rOfIUlPYo4zwwJ4UGhXuc + configure_wifi: false + wifi_ssid: BauerWLAN diff --git a/roles/pi-dhtsensor/files/__pycache__/dht22_sensing.cpython-37.pyc b/roles/pi-dhtsensor/files/__pycache__/dht22_sensing.cpython-37.pyc new file mode 100644 index 0000000..f356404 Binary files /dev/null and b/roles/pi-dhtsensor/files/__pycache__/dht22_sensing.cpython-37.pyc differ diff --git a/roles/pi-dhtsensor/files/dht22_sensing.py b/roles/pi-dhtsensor/files/dht22_sensing.py index f723a96..3e96fb1 100644 --- a/roles/pi-dhtsensor/files/dht22_sensing.py +++ b/roles/pi-dhtsensor/files/dht22_sensing.py @@ -25,6 +25,9 @@ class Filter: return abs(val - self.mean()) < self.max_mean_deviation def add_if_valid(self, val): + if val is None: + return False + if self.is_valid_value(val): self.values.append(val) if len(self.values) > self._length: @@ -66,16 +69,9 @@ def send_to_home_assistant(temperature, humidity): requests.post(humidity_url, json=humidity_data, headers=headers) -last_values = [] - - -def filter(value): - last_values.append(value) - - if __name__ == "__main__": - temp_filter = Filter(10, 5) - humidity_filter = Filter(10, 5) + temp_filter = Filter(2, 5) + humidity_filter = Filter(3, 5) while True: sensor = Adafruit_DHT.DHT22 diff --git a/roles/pi-irserver/files/hauppauge.rem b/roles/pi-irserver/files/hauppauge.rem new file mode 100644 index 0000000..2850a2d --- /dev/null +++ b/roles/pi-irserver/files/hauppauge.rem @@ -0,0 +1,53 @@ +[REMOTE] + [NAME]hauppauge + +[TIMING] + [0][N]0[RC]2[RP]87[FREQ]36[RC5] + +[COMMANDS] + [BTN_1][T]0[D]11011110000001 + [BTN_2][T]0[D]11011110000010 + [BTN_3][T]0[D]11011110000011 + [BTN_4][T]0[D]11011110000100 + [BTN_5][T]0[D]11011110000101 + [BTN_6][T]0[D]11011110000110 + [BTN_7][T]0[D]11011110000111 + [BTN_8][T]0[D]11011110001000 + [BTN_9][T]0[D]11011110001001 + [BTN_0][T]0[D]11011110000000 + [KEY_NUMERIC_STAR][T]0[D]11011110001010 + [KEY_NUMERIC_POUND][T]0[D]11011110001110 + [KEY_RED][T]0[D]11011110001011 + [KEY_GREEN][T]0[D]11011110101110 + [KEY_YELLOW][T]0[D]11011110111000 + [KEY_BLUE][T]0[D]11011110101001 + [KEY_PLAY][T]0[D]11011110110101 + [KEY_PAUSE][T]0[D]11011110110000 + [KEY_RECORD][T]0[D]11011110110111 + [KEY_PREVIOUS][T]0[D]11011110110010 + [KEY_FORWARD][T]0[D]11011110110100 + [KEY_REWIND][T]0[D]11011110100100 + [KEY_FASTFORWARD][T]0[D]11011110011110 + [KEY_VOLUMEUP][T]0[D]11011110010000 + [KEY_VOLUMEDOWN][T]0[D]11011110010001 + [KEY_CHANNELUP][T]0[D]11011110100000 + [KEY_CHANNELDOWN][T]0[D]11011110100001 + [KEY_MUTE][T]0[D]11011110001111 + [KEY_CHANNEL][T]0[D]11011110010010 + [KEY_EXIT][T]0[D]11011110011111 + [KEY_MENU][T]0[D]11011110001101 + [KEY_LEFT][T]0[D]11011110010110 + [KEY_RIGHT][T]0[D]11011110010111 + [KEY_UP][T]0[D]11011110010100 + [KEY_DOWN][T]0[D]11011110010101 + [KEY_OK][T]0[D]11011110100101 + [KEY_POWER][T]0[D]11011110111101 + [KEY_GOTO][T]0[D]11011110111011 + [KEY_TV][T]0[D]11011110011100 + [KEY_VIDEOS][T]0[D]11011110011000 + [KEY_MUSIC][T]0[D]11011110011001 + [KEY_PICTURES][T]0[D]11011110011010 + [KEY_GUIDE][T]0[D]11011110011011 + [KEY_RADIO][T]0[D]11011110001100 + [KEY_STOP][T]0[D]11011110110110 + diff --git a/roles/pi-irserver/files/irserver b/roles/pi-irserver/files/irserver new file mode 100755 index 0000000..7434ca4 Binary files /dev/null and b/roles/pi-irserver/files/irserver differ diff --git a/roles/pi-irserver/files/irserver-src.tar.gz b/roles/pi-irserver/files/irserver-src.tar.gz new file mode 100644 index 0000000..b59b96e Binary files /dev/null and b/roles/pi-irserver/files/irserver-src.tar.gz differ diff --git a/roles/pi-irserver/files/irserver.readme b/roles/pi-irserver/files/irserver.readme new file mode 100644 index 0000000..cab6e30 --- /dev/null +++ b/roles/pi-irserver/files/irserver.readme @@ -0,0 +1,9 @@ +downloaded from +http://www.irtrans.de/de/download/linux.php + +build on raspberry pi using + +make arm_noccfgcc + +-> linker errors with libzip +-> installed libzip-dev and added lzip to linker parameters \ No newline at end of file diff --git a/roles/pi-irserver/files/irserver.service b/roles/pi-irserver/files/irserver.service new file mode 100644 index 0000000..6fc93c0 --- /dev/null +++ b/roles/pi-irserver/files/irserver.service @@ -0,0 +1,10 @@ +[Unit] +Description=IR server for IR remotes +After=multi-user.target + +[Service] +Type=simple +ExecStart=/usr/bin/irserver /dev/ttyUSB0 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/roles/pi-irserver/tasks/main.yml b/roles/pi-irserver/tasks/main.yml new file mode 100644 index 0000000..c698d2d --- /dev/null +++ b/roles/pi-irserver/tasks/main.yml @@ -0,0 +1,12 @@ +--- +- name: Copy irserver + copy: src=irserver dest=/usr/bin/irserver mode=u+rx +- name: Copy irserver systemd file + copy: src=irserver.service dest=/lib/systemd/system/ +- name: Enable irserver autostart + systemd: name=irserver state=restarted enabled=yes daemon_reload=yes +- name: Add irserver to sysdweb + include_role: + name: pi-sysdweb + vars: + sysdweb_name: irserver diff --git a/roles/pi-sispmctl/files/sispmctl.service b/roles/pi-sispmctl/files/sispmctl.service index 07a1b27..82eeb6e 100644 --- a/roles/pi-sispmctl/files/sispmctl.service +++ b/roles/pi-sispmctl/files/sispmctl.service @@ -30,7 +30,7 @@ SystemCallArchitectures=native UMask=177 Type=forking -ExecStart=/usr/local/bin/sispmctl -p 2638 -l +ExecStart=/usr/bin/sispmctl -p 2638 -l SyslogIdentifier=sispmctl Restart=always RestartSec=5 \ No newline at end of file diff --git a/roles/pi-sispmctl/tasks/main.yml b/roles/pi-sispmctl/tasks/main.yml index fc0fc4f..5f64764 100644 --- a/roles/pi-sispmctl/tasks/main.yml +++ b/roles/pi-sispmctl/tasks/main.yml @@ -1,6 +1,6 @@ --- - name: Check if sispmctl already exists - stat: path=/usr/local/bin/sispmctl + stat: path=/usr/bin/sispmctl register: sispmctl_file - name: Install dependencies apt: name="libusb-dev" cache_valid_time=7200 state=present diff --git a/roles/pi-squeezelite-custom/tasks/main.yml b/roles/pi-squeezelite-custom/tasks/main.yml index b4a7282..b1b3ad4 100644 --- a/roles/pi-squeezelite-custom/tasks/main.yml +++ b/roles/pi-squeezelite-custom/tasks/main.yml @@ -1,7 +1,16 @@ --- - - name: Uninstall system package of squeezelite apt: name=squeezelite state=absent +- name: Install dependencies + apt: + name: + - libmad0 + - libmpg123-0 + - libflac8 + - libvorbisfile3 + - libfaad2 + state: present + cache_valid_time: 7200 - name: Remove old config file if present file: path=/etc/default/squeezelite state=absent - name: Copy over custom compile version of squeezelite diff --git a/roles/pi-squeezeserver/files/logitechmediaserver_7.9.2_arm.deb b/roles/pi-squeezeserver/files/logitechmediaserver_7.9.2_arm.deb new file mode 100644 index 0000000..9aaa297 Binary files /dev/null and b/roles/pi-squeezeserver/files/logitechmediaserver_7.9.2_arm.deb differ diff --git a/roles/pi-squeezeserver/files/source_url.txt b/roles/pi-squeezeserver/files/source_url.txt new file mode 100644 index 0000000..5159e77 --- /dev/null +++ b/roles/pi-squeezeserver/files/source_url.txt @@ -0,0 +1 @@ +http://downloads.slimdevices.com/LogitechMediaServer_v7.9.2/logitechmediaserver_7.9.2_arm.deb diff --git a/roles/pi-squeezeserver/tasks/main.yml b/roles/pi-squeezeserver/tasks/main.yml new file mode 100644 index 0000000..6a52ca7 --- /dev/null +++ b/roles/pi-squeezeserver/tasks/main.yml @@ -0,0 +1,39 @@ +--- +- name: Install packages required for squeeze server + apt: + name: + - libsox-fmt-all + - libflac-dev + - libfaad2 + - libmad0 + - perl-openssl-abi-1.1 + - libnet-ssleay-perl + - libio-socket-ssl-perl + - nasm + - build-essential + - iptables-persistent + cache_valid_time: 7200 + state: present +- name: copy squeezeserver package + copy: src=logitechmediaserver_7.9.2_arm.deb dest=/tmp +- name: install squeezeserver package + apt: deb=/tmp/logitechmediaserver_7.9.2_arm.deb +- name: Enable sysdweb autostart + systemd: name=logitechmediaserver state=started enabled=yes +- name: Add to sysdweb + include_role: + name: pi-sysdweb + vars: + sysdweb_name: logitechmediaserver +- name: Forward port 80 to 9000 + iptables: + table: nat + chain: PREROUTING + in_interface: eth0 + protocol: tcp + match: tcp + destination_port: "80" + jump: REDIRECT + to_ports: "9000" + comment: Redirect web traffic to port 9000 + \ No newline at end of file diff --git a/roles/pi-standard-setup/files/motd/musikserverwohnzimmeroben b/roles/pi-standard-setup/files/motd/musikserverwohnzimmeroben new file mode 100644 index 0000000..ce1b33d --- /dev/null +++ b/roles/pi-standard-setup/files/motd/musikserverwohnzimmeroben @@ -0,0 +1,7 @@ + Musik Server Wohnzimmer oben + + |~~~~~~~~~~~~~~~| + |~~~~~~~~~~~~~~~| + | | + /~~\| /~~\| + \__/ \__/ \ No newline at end of file diff --git a/roles/pi-standard-setup/tasks/main.yml b/roles/pi-standard-setup/tasks/main.yml index 8172158..dff5943 100644 --- a/roles/pi-standard-setup/tasks/main.yml +++ b/roles/pi-standard-setup/tasks/main.yml @@ -70,19 +70,25 @@ ignore_errors: yes #to avoid error when WiFi is not present - name: Change WiFi country command: "raspi-config nonint do_wifi_country {{ wifi_country }}" - when: wifi_ssid | bool + when: configure_wifi - name: Set WiFi credentials - command: "raspi-config nonint do_wifi_ssid_passphrase {{ wifi_ssid }} {{ lookup('keepass', bauer_wifi) }}" - when: wifi_ssid | bool -- name: Copy WIFI watchdog script - copy: src=wifi-watchdog.sh dest=/usr/sbin/wifi-watchdog.sh - when: wifi_ssid | bool -- name: Run WIFI watchdog script periodically - cron: - name: "WIFI Watchdog" - minute: "*/15" - job: /usr/sbin/wifi-watchdog.sh - when: wifi_ssid | bool + command: "raspi-config nonint do_wifi_ssid_passphrase {{ wifi_ssid }} {{ lookup('keepass', 'bauer_wifi') }}" + when: configure_wifi +- name: Install watchdog + apt: name=watchdog cache_valid_time=7200 state=present + when: not wifi_ssid is defined +- name: Configure watchdog + blockinfile: + path: /etc/watchdog.conf + block: | + interface = wlan0 + retry-timeout = 90 + ping = {{router_ip}} + interval = 15 + when: configure_wifi +- name: Start watchdog + systemd: name=watchdog state=restarted enabled=yes daemon_reload=yes + when: configure_wifi # Message of the day - name: Set Message of the day copy: src=motd/{{ pi_hostname.stdout }} dest=/etc/motd diff --git a/test.yml b/test.yml deleted file mode 100644 index cb58cb9..0000000 --- a/test.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -- hosts: bedroompi, kitchenpi - roles: - - pi-standard-setup - - pi-squeezelite-custom - - pi-shairport - - pi-lirc - - pi-dhtsensor diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..e00672e --- /dev/null +++ b/todo.md @@ -0,0 +1,25 @@ +KNXd + +HomeMatic +--------- +git clone https://github.com/knxd/knxd.git +cd knxd +git checkout stable +apt-get install debhelper cdbs automake libtool libusb-1.0-0-dev git-core build-essential libsystemd-dev dh-systemd libev-dev cmake +dpkg-buildpackage -b -uc + +- ansible script +- checkout backup & restore for debmatic +- ansible playbook for debmatic setup + + + + +- AEON LED off + + +/var/lib/bluetooth//settings + +[General] +Discoverable=false +Alias=bla