From: Giorgio Ravera Date: Fri, 24 Feb 2023 22:28:41 +0000 (+0100) Subject: Added script to manage fritz box X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=b053406e958afb97f0438c0bcf64d3c83e47f345;p=homeassistant.git Added script to manage fritz box --- diff --git a/.storage/lovelace.lovelace_dispositivi b/.storage/lovelace.lovelace_dispositivi index 8b3a5630..2414ec6e 100644 --- a/.storage/lovelace.lovelace_dispositivi +++ b/.storage/lovelace.lovelace_dispositivi @@ -580,6 +580,176 @@ } ] }, + { + "type": "entities", + "show_header_toggle": "off", + "style": ".card-header {\n padding: 0px 0px 0px 0px !important;\n}\n", + "entities": [ + { + "type": "section", + "label": "FRITZ!Box 7530 AX" + }, + { + "type": "custom:hui-element", + "card_type": "vertical-stack", + "cards": [ + { + "type": "horizontal-stack", + "cards": [ + { + "type": "picture", + "style": "ha-card { \n --paper-card-background-color: 'rgba(0, 0, 0, 0.0)';\n --ha-card-background: \"rgba(0, 0, 0, 0)\";\n --ha-card-box-shadow: 'none';\n}\n", + "image": "/local/images/devices/fritzbox_7530_ax.png", + "tap_action": { + "action": "url", + "url_path": "https://ap1.giorgioravera.it" + } + }, + { + "type": "vertical-stack", + "cards": [ + { + "type": "custom:button-card", + "layout": "icon_name_state", + "name": "Riavvia Dispositivo", + "tap_action": { + "action": "call-service", + "service": "shell_command.ap1_reboot" + }, + "show_icon": true, + "show_state": false, + "icon": "mdi:restart", + "styles": { + "grid": [ + { + "grid-template-columns": "50px auto" + } + ], + "icon": [ + { + "padding": "0px 0px" + }, + { + "height": "25px" + }, + { + "width": "25px" + }, + { + "color": "var(--state-icon-color)" + } + ], + "card": [ + { + "--ha-card-background": "rgba(0, 0, 0, 0)" + }, + { + "--ha-card-box-shadow": "none" + } + ], + "name": [ + { + "padding": "0px 10px" + }, + { + "justify-self": "start" + }, + { + "font-family": "Roboto, sans-serif" + }, + { + "font-size": "15px" + }, + { + "color": "var(--primary-text-color)" + } + ] + } + }, + { + "type": "custom:button-card", + "layout": "icon_name_state", + "entity": "switch.ap1_led", + "name": "LED", + "show_icon": true, + "show_state": false, + "styles": { + "grid": [ + { + "grid-template-columns": "50px auto" + } + ], + "icon": [ + { + "padding": "0px 0px" + }, + { + "height": "25px" + }, + { + "width": "25px" + }, + { + "color": "var(--state-icon-color)" + } + ], + "card": [ + { + "--ha-card-background": "rgba(0, 0, 0, 0)" + }, + { + "--ha-card-box-shadow": "none" + } + ], + "name": [ + { + "padding": "0px 10px" + }, + { + "justify-self": "start" + }, + { + "font-family": "Roboto, sans-serif" + }, + { + "font-size": "15px" + }, + { + "color": "var(--primary-text-color)" + } + ] + }, + "state": [ + { + "value": "on", + "styles": { + "icon": [ + { + "color": "lightgreen" + } + ] + } + }, + { + "value": "off", + "styles": { + "icon": [ + { + "color": "grey" + } + ] + } + } + ] + } + ] + } + ] + } + ] + } + ] + }, { "type": "entities", "show_header_toggle": "off", diff --git a/packages/fritz.yaml b/packages/fritz.yaml new file mode 100644 index 00000000..8c027b81 --- /dev/null +++ b/packages/fritz.yaml @@ -0,0 +1,45 @@ +###################################################################### +# Fritz Package - Switch +###################################################################### + +switch: + - platform: template + switches: + fritz_led: + turn_on: + service: shell_command.fritz_led_on + turn_off: + service: shell_command.fritz_led_off +# icon_template: >- +# {% if is_state('cover.garage_door', 'open') %} +# mdi:mdi:led-on +# {% else %} +# mdi:led-off +# {% endif %} + + - platform: template + switches: + ap1_led: + turn_on: + service: shell_command.ap1_led_on + turn_off: + service: shell_command.ap1_led_off +# icon_template: >- +# {% if is_state('cover.garage_door', 'open') %} +# mdi:mdi:led-on +# {% else %} +# mdi:led-off +# {% endif %} + +###################################################################### +# Fritz Package - Fritz Command +###################################################################### +shell_command: + fritz_reboot: 'bash /config/shell_scripts/fritzBox.sh fritz REBOOT Box' + fritz_reconnect: 'bash /config/shell_scripts/fritzBox.sh fritz WAN RECONNECT' + fritz_led_on: 'bash /config/shell_scripts/fritzBox.sh fritz LED 1' + fritz_led_off: 'bash /config/shell_scripts/fritzBox.sh fritz LED 0' + ap1_reboot: 'bash /config/shell_scripts/fritzBox.sh ap1 REBOOT Box' + ap1_reconnect: 'bash /config/shell_scripts/fritzBox.sh ap1 WAN RECONNECT' + ap1_led_on: 'bash /config/shell_scripts/fritzBox.sh ap1 LED 1' + ap1_led_off: 'bash /config/shell_scripts/fritzBox.sh ap1 LED 0' \ No newline at end of file diff --git a/shell_scripts/fritzBox.sh b/shell_scripts/fritzBox.sh new file mode 100755 index 00000000..39f40721 --- /dev/null +++ b/shell_scripts/fritzBox.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Parameters +if [ -f /.dockerenv ]; then + HASS_HOME="/config" +else + HASS_HOME="../" +fi + +if [[ $1 == fritz ]]; then # FRITZ!BOX 7590 + HOST=$(awk '/fritz_host/ { print $2 }' $HASS_HOME/secrets.yaml) + USERNAME=$(awk '/fritz_user/ { print $2 }' $HASS_HOME/secrets.yaml) + PASSWORD=$(awk '/fritz_password/ { print $2 }' $HASS_HOME/secrets.yaml) +elif [[ $1 == ap1 ]]; then # FRITZ!BOX 7530 AX + HOST=$(awk '/ap1_host/ { print $2 }' $HASS_HOME/secrets.yaml) + USERNAME=$(awk '/ap1_user/ { print $2 }' $HASS_HOME/secrets.yaml) + PASSWORD=$(awk '/ap1_password/ { print $2 }' $HASS_HOME/secrets.yaml) +fi +SCRIPT=$HASS_HOME/git_repos/FritzBoxShell/fritzBoxShell.sh + +$SCRIPT --boxip $HOST --boxuser $USERNAME --boxpw $PASSWORD ${@:2} diff --git a/www/images/devices/fritzbox_7530_ax.png b/www/images/devices/fritzbox_7530_ax.png new file mode 100644 index 00000000..6bf71507 Binary files /dev/null and b/www/images/devices/fritzbox_7530_ax.png differ diff --git a/www/images/devices/fritzbox_7590.png b/www/images/devices/fritzbox_7590.png new file mode 100644 index 00000000..1f539dcd Binary files /dev/null and b/www/images/devices/fritzbox_7590.png differ