From a2c3fabfe9ff628a79062d45350ffc66a035e2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Thu, 30 May 2024 12:13:40 +0100 Subject: [PATCH] added config folder to git --- .gitignore | 3 - ...docker-compose.yaml => docker-compose.yaml | 0 volumes/config/.gitignore | 50 +++++++ volumes/config/automations.yaml | 39 ++++++ .../homeassistant/motion_light.yaml | 50 +++++++ .../homeassistant/notify_leaving_zone.yaml | 43 ++++++ .../confirmable_notification.yaml | 84 ++++++++++++ volumes/config/configuration.yaml | 81 ++++++++++++ volumes/config/configuration.yaml.save | 67 ++++++++++ volumes/config/groups.yaml | 0 volumes/config/scenes.yaml | 0 volumes/config/scripts.yaml | 122 ++++++++++++++++++ volumes/config/scripts/limbowiki_get_info.py | 18 +++ volumes/config/www/pimusicbox | 1 + volumes/config/www/pimusicbox-mydev | 1 + 15 files changed, 556 insertions(+), 3 deletions(-) rename docker/docker-compose.yaml => docker-compose.yaml (100%) create mode 100644 volumes/config/.gitignore create mode 100644 volumes/config/automations.yaml create mode 100644 volumes/config/blueprints/automation/homeassistant/motion_light.yaml create mode 100644 volumes/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml create mode 100644 volumes/config/blueprints/script/homeassistant/confirmable_notification.yaml create mode 100644 volumes/config/configuration.yaml create mode 100755 volumes/config/configuration.yaml.save create mode 100755 volumes/config/groups.yaml create mode 100644 volumes/config/scenes.yaml create mode 100644 volumes/config/scripts.yaml create mode 100755 volumes/config/scripts/limbowiki_get_info.py create mode 160000 volumes/config/www/pimusicbox create mode 160000 volumes/config/www/pimusicbox-mydev diff --git a/.gitignore b/.gitignore index 52ce02d..df747c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ **.env -_volumes -_volumes .vscode -.volumes diff --git a/docker/docker-compose.yaml b/docker-compose.yaml similarity index 100% rename from docker/docker-compose.yaml rename to docker-compose.yaml diff --git a/volumes/config/.gitignore b/volumes/config/.gitignore new file mode 100644 index 0000000..86d09e1 --- /dev/null +++ b/volumes/config/.gitignore @@ -0,0 +1,50 @@ +# Created by https://www.toptal.com/developers/gitignore/api/homeassistant +# Edit at https://www.toptal.com/developers/gitignore?templates=homeassistant + +### HomeAssistant ### +# Files with personal details +*.crt +*.csr +*.key +.cloud +.google.token +.HA_VERSION +.storage +.uuid +icloud/ +google_calendars.yaml +harmony_media_room.conf +home-assistant.db +home-assistant_v2.db +home-assistant_v2.db-* +html5_push_registrations.conf +image +ip_bans.yaml +known_devices.yaml +phue.conf +plex.conf +pyozw.sqlite +secrets.yaml +tradfri.conf +webostv.conf + +# Temporary files +*.db-journal +*.pid +tts + +# automatically downloaded dependencies +deps +lib + +# Log files +home-assistant.log +home-assistant.log.* +ozw_log.txt + +# Development files +custom_components + +# End of https://www.toptal.com/developers/gitignore/api/homeassistant + + diff --git a/volumes/config/automations.yaml b/volumes/config/automations.yaml new file mode 100644 index 0000000..da8db19 --- /dev/null +++ b/volumes/config/automations.yaml @@ -0,0 +1,39 @@ +- id: '1713172414513' + alias: Door Batery Low + description: '' + trigger: + - platform: numeric_state + entity_id: + - sensor.portadaentrada_battery + below: 40 + enabled: false + - type: bat_low + platform: device + device_id: 3bc6bb9f522dc44ba7b223511d124978 + entity_id: d1a83c7b24d0cb0e3d98221176596f21 + domain: binary_sensor + for: + hours: 0 + minutes: 5 + seconds: 0 + - type: bat_low + platform: device + device_id: 3bc6bb9f522dc44ba7b223511d124978 + entity_id: cc070eaef8e0231e7a580b17e4826b73 + domain: binary_sensor + for: + hours: 0 + minutes: 5 + seconds: 0 + condition: [] + action: + - service: notify.mobile_app_mfs9plus + metadata: {} + data: + title: Porta da entrada + message: low bat + - service: notify.persistent_notification + data: + title: Porta da entrada + message: low bat + mode: single diff --git a/volumes/config/blueprints/automation/homeassistant/motion_light.yaml b/volumes/config/blueprints/automation/homeassistant/motion_light.yaml new file mode 100644 index 0000000..c11d22d --- /dev/null +++ b/volumes/config/blueprints/automation/homeassistant/motion_light.yaml @@ -0,0 +1,50 @@ +blueprint: + name: Motion-activated Light + description: Turn on a light when motion is detected. + domain: automation + source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml + input: + motion_entity: + name: Motion Sensor + selector: + entity: + domain: binary_sensor + device_class: motion + light_target: + name: Light + selector: + target: + entity: + domain: light + no_motion_wait: + name: Wait time + description: Time to leave the light on after last motion is detected. + default: 120 + selector: + number: + min: 0 + max: 3600 + unit_of_measurement: seconds + +# If motion is detected within the delay, +# we restart the script. +mode: restart +max_exceeded: silent + +trigger: + platform: state + entity_id: !input motion_entity + from: "off" + to: "on" + +action: + - service: light.turn_on + target: !input light_target + - wait_for_trigger: + platform: state + entity_id: !input motion_entity + from: "on" + to: "off" + - delay: !input no_motion_wait + - service: light.turn_off + target: !input light_target diff --git a/volumes/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml b/volumes/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml new file mode 100644 index 0000000..d3a70d7 --- /dev/null +++ b/volumes/config/blueprints/automation/homeassistant/notify_leaving_zone.yaml @@ -0,0 +1,43 @@ +blueprint: + name: Zone Notification + description: Send a notification to a device when a person leaves a specific zone. + domain: automation + source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml + input: + person_entity: + name: Person + selector: + entity: + domain: person + zone_entity: + name: Zone + selector: + entity: + domain: zone + notify_device: + name: Device to notify + description: Device needs to run the official Home Assistant app to receive notifications. + selector: + device: + integration: mobile_app + +trigger: + platform: state + entity_id: !input person_entity + +variables: + zone_entity: !input zone_entity + # This is the state of the person when it's in this zone. + zone_state: "{{ states[zone_entity].name }}" + person_entity: !input person_entity + person_name: "{{ states[person_entity].name }}" + +condition: + condition: template + value_template: "{{ trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}" + +action: + domain: mobile_app + type: notify + device_id: !input notify_device + message: "{{ person_name }} has left {{ zone_state }}" diff --git a/volumes/config/blueprints/script/homeassistant/confirmable_notification.yaml b/volumes/config/blueprints/script/homeassistant/confirmable_notification.yaml new file mode 100644 index 0000000..d52e5a6 --- /dev/null +++ b/volumes/config/blueprints/script/homeassistant/confirmable_notification.yaml @@ -0,0 +1,84 @@ +blueprint: + name: Confirmable Notification + description: >- + A script that sends an actionable notification with a confirmation before + running the specified action. + domain: script + source_url: https://github.com/home-assistant/core/blob/master/homeassistant/components/script/blueprints/confirmable_notification.yaml + input: + notify_device: + name: Device to notify + description: Device needs to run the official Home Assistant app to receive notifications. + selector: + device: + integration: mobile_app + title: + name: "Title" + description: "The title of the button shown in the notification." + default: "" + selector: + text: + message: + name: "Message" + description: "The message body" + selector: + text: + confirm_text: + name: "Confirmation Text" + description: "Text to show on the confirmation button" + default: "Confirm" + selector: + text: + confirm_action: + name: "Confirmation Action" + description: "Action to run when notification is confirmed" + default: [] + selector: + action: + dismiss_text: + name: "Dismiss Text" + description: "Text to show on the dismiss button" + default: "Dismiss" + selector: + text: + dismiss_action: + name: "Dismiss Action" + description: "Action to run when notification is dismissed" + default: [] + selector: + action: + +mode: restart + +sequence: + - alias: "Set up variables" + variables: + action_confirm: "{{ 'CONFIRM_' ~ context.id }}" + action_dismiss: "{{ 'DISMISS_' ~ context.id }}" + - alias: "Send notification" + domain: mobile_app + type: notify + device_id: !input notify_device + title: !input title + message: !input message + data: + actions: + - action: "{{ action_confirm }}" + title: !input confirm_text + - action: "{{ action_dismiss }}" + title: !input dismiss_text + - alias: "Awaiting response" + wait_for_trigger: + - platform: event + event_type: mobile_app_notification_action + event_data: + action: "{{ action_confirm }}" + - platform: event + event_type: mobile_app_notification_action + event_data: + action: "{{ action_dismiss }}" + - choose: + - conditions: "{{ wait.trigger.event.data.action == action_confirm }}" + sequence: !input confirm_action + - conditions: "{{ wait.trigger.event.data.action == action_dismiss }}" + sequence: !input dismiss_action diff --git a/volumes/config/configuration.yaml b/volumes/config/configuration.yaml new file mode 100644 index 0000000..79dc152 --- /dev/null +++ b/volumes/config/configuration.yaml @@ -0,0 +1,81 @@ + +# Configure a default setup of Home Assistant (frontend, api, etc) +default_config: +# enable wake on lan integration +wake_on_lan: + +http: + server_port: 80 + use_x_forwarded_for: true + trusted_proxies: + - 0.0.0.0/0 #cuidado com isto +# Text to speech +tts: + - platform: google_translate + +group: !include groups.yaml +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml + +#light: +# Example configuration.yaml entry +# - platform: flux_led +# devices: +# 192.168.2.48: +# name: movel_tv_strip +# mode: rgb + +#sensor: +# - platform: command_line +# command: "python3 /config/scripts/limbowiki_get_info.py" +# name: limbowiki_info +# json_attributes: +# - status +# - version +# - platform: template +# sensors: +# limbowiki_info_status: +# value_template: "{{ state_attr('sensor.limbowiki_info', 'status') }}" +# limbowiki_info_version: +# value_template: "{{ state_attr('sensor.limbowiki_info', 'version') }}" + + +# sensor livingroom audio: +# platform: mqtt +# state_topic: "home/devices/livingroom/audio/input" +# name: "livingroom Audio" + +#sensor pilivingroom bluetoothctl-dev: +# platform: mqtt +# state_topic: "home/devices/pimusicmydev/bluetooth" +# json_attributes_topic: "home/devices/pimusicmydev/bluetooth" +# name: "pilivingroom-dev bluetoothctl-dev" +# value_template: Bluetoothctl mqtt +# json_attributes_template: > +# { +# "mqttTopic":"{{value_json.mqttTopic}}", +# "devices":{{value_json.devices|to_json}} +# } + +#sensor livingroom bluetooth devices: +# platform: mqtt +# state_topic: "home/devices/livingroom/bluetooth/devices" +# json_attributes_topic: "home/devices/livingroom/bluetooth/devices" +# name: "livingroom bluetooth devices" +# value_template: Bluetooth Devices Counter {{ value_json|length }} +# json_attributes_template: > +# {"devices":{{value_json|to_json}}} + +panel_iframe: + homeserver_dashboad: + title: "HomeServer Admin" + icon: mdi:qrcode-edit + url: "http://homesrv01.dev.lan:9777" + require_admin: true + lms: + title: "LMS" + icon: mdi:music-box + url: "http://homesrv01.dev.lan:9000" + require_admin: false + diff --git a/volumes/config/configuration.yaml.save b/volumes/config/configuration.yaml.save new file mode 100755 index 0000000..c9f7421 --- /dev/null +++ b/volumes/config/configuration.yaml.save @@ -0,0 +1,67 @@ + +# Configure a default setup of Home Assistant (frontend, api, etc) +default_config: + +http: + server_port: 80 + use_x_forwarded_for: true + trusted_proxies: + - 192.168.1.0/24 +# Text to speech +tts: + - platform: google_translate + + +webostv: + name: Living Room TV + host: 192.168.1.249 + #other settings + turn_on_action: + service: wake_on_lan.send_magic_packet + data: + mac: B0:37:95:8D:06:78 +wake_on_lan: + +group: !include groups.yaml +automation: !include automations.yaml +script: !include scripts.yaml +scene: !include scenes.yaml + +light: +# Example configuration.yaml entry + - platform: flux_led + devices: + 192.168.2.48: + name: movel_tv_strip + mode: rgb + +sensor: + - platform: command_line + command: "python3 /config/scripts/limbowiki_get_info.py" + name: limbowiki_info + json_attributes: + - status + - version + - platform: template + sensors: + limbowiki_info_status: + value_template: "{{ state_attr('sensor.limbowiki_info', 'status') }}" + limbowiki_info_version: + value_template: "{{ state_attr('sensor.limbowiki_info', 'version') }}" + + +sensor livingroom audio: + platform: mqtt + state_topic: "home/devices/livingroom/audio/input" + name: "livingroom Audio" + +sensor livingroom bluetooth devices: + platform: mqtt + state_topic: "home/devices/livingroom/bluetooth/devices" + json_attributes_topic: "home/devices/livingroom/bluetooth/devices" + name: "livingroom bluetooth devices" + value_template: Bluetooth Devices Counter {{ value_json|length }} + json_attributes_template: > + {"json":"{{value_json|json}}"} + + | json diff --git a/volumes/config/groups.yaml b/volumes/config/groups.yaml new file mode 100755 index 0000000..e69de29 diff --git a/volumes/config/scenes.yaml b/volumes/config/scenes.yaml new file mode 100644 index 0000000..e69de29 diff --git a/volumes/config/scripts.yaml b/volumes/config/scripts.yaml new file mode 100644 index 0000000..0d1010c --- /dev/null +++ b/volumes/config/scripts.yaml @@ -0,0 +1,122 @@ +livingroom_start_playing_xbox_script: + sequence: + - service: script.livingroom_tvon_if_off + data: {} + - type: turn_on + device_id: ab5d0bc41be685464f6308e6a96f6bbe + entity_id: remote.xbox_remote + domain: remote + - service: media_player.select_source + target: + entity_id: media_player.living_room_tv + data: + source: XBOX Game Console + - service: remote.send_command + data: + device: irblaster-01 + command: bddvd + target: + entity_id: remote.irblaster_01_remote + mode: single + alias: livingroom_start_playing_xbox + icon: mdi:microsoft-xbox +livingroom_start_watching_amazonprime: + alias: livingroom_start_watching_amazonprime + sequence: + - service: script.livingroom_tvon_if_off + data: {} + - service: media_player.select_source + target: + entity_id: media_player.living_room_tv + data: + source: Prime Video + - service: remote.send_command + data: + device: irblaster-01 + command: bddvd + target: + entity_id: remote.irblaster_01_remote + mode: single + icon: mid:microsoft-xbox +livingroom_start_watching_youtube: + alias: livingroom_start_watching_youtube + sequence: + - service: script.livingroom_tvon_if_off + data: {} + - service: media_player.select_source + target: + entity_id: media_player.living_room_tv + data: + source: YouTube + - service: remote.send_command + data: + device: irblaster-01 + command: bddvd + target: + entity_id: remote.irblaster_01_remote + mode: single + icon: mid:microsoft-xbox +livingroom_start_watching_hbomax: + alias: livingroom_start_watching_hbomax + sequence: + - service: script.livingroom_tvon_if_off + data: {} + - service: media_player.select_source + target: + entity_id: media_player.living_room_tv + data: + source: HBO Max + - service: remote.send_command + data: + device: irblaster-01 + command: bddvd + target: + entity_id: remote.irblaster_01_remote + mode: single + icon: mdi:television +livingroom_start_watch_vodafone: + alias: livingroom_start_watch_vodafone + sequence: + - service: script.livingroom_tvon_if_off + data: {} + - service: media_player.select_source + target: + entity_id: media_player.living_room_tv + data: + source: HBO Max + - service: remote.send_command + data: + device: irblaster-01 + command: bddvd + target: + entity_id: remote.irblaster_01_remote + mode: single + icon: mdi:television +livingroom_tvon_if_off: + alias: livingroom_tv_on_if_off + sequence: + - if: + - condition: device + device_id: 40438b8ef2cbd6e06c3a1835498c70f0 + domain: media_player + entity_id: media_player.living_room_tv + type: is_off + then: + - service: wake_on_lan.send_magic_packet + data: + mac: B0:37:95:8D:06:78 + - delay: + hours: 0 + minutes: 0 + seconds: 5 + milliseconds: 0 + mode: single + icon: mdi:television +livingroom_power_off: + alias: livingroom_power_off + sequence: + - service: media_player.turn_off + data: {} + target: + entity_id: media_player.living_room_tv + mode: single diff --git a/volumes/config/scripts/limbowiki_get_info.py b/volumes/config/scripts/limbowiki_get_info.py new file mode 100755 index 0000000..e602236 --- /dev/null +++ b/volumes/config/scripts/limbowiki_get_info.py @@ -0,0 +1,18 @@ +from lxml import html +import requests + +# Request the page +try: + page = requests.get('https://wiki.limbosolutions.com/index.php/P%C3%A1gina_principal', timeout=2) + +# Parsing the page +# (We need to use page.content rather than +# page.text because html.fromstring implicitly +# expects bytes as input.) + tree = html.fromstring(page.content) + +# Get element using XPath + buyers = tree.xpath('string(//html//head//meta//@content)') + print("{\"status\":\"On\",\"version\":\"" + buyers + "\"}") +except: + print("{\"status\":\"error\"}") diff --git a/volumes/config/www/pimusicbox b/volumes/config/www/pimusicbox new file mode 160000 index 0000000..ff39143 --- /dev/null +++ b/volumes/config/www/pimusicbox @@ -0,0 +1 @@ +Subproject commit ff3914345a56b27666ad8c2a0c19884c54db9bd4 diff --git a/volumes/config/www/pimusicbox-mydev b/volumes/config/www/pimusicbox-mydev new file mode 160000 index 0000000..845f129 --- /dev/null +++ b/volumes/config/www/pimusicbox-mydev @@ -0,0 +1 @@ +Subproject commit 845f129515ee8b7c8bf508b485a4896a37703227