]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added script to manage fritz box
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Fri, 24 Feb 2023 22:28:41 +0000 (23:28 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Fri, 24 Feb 2023 22:28:41 +0000 (23:28 +0100)
.storage/lovelace.lovelace_dispositivi
packages/fritz.yaml [new file with mode: 0644]
shell_scripts/fritzBox.sh [new file with mode: 0755]
www/images/devices/fritzbox_7530_ax.png [new file with mode: 0644]
www/images/devices/fritzbox_7590.png [new file with mode: 0644]

index 8b3a56305366df1f8f428ba10ae34c1c17863293..2414ec6ed7a518e03988ebb16f37047c70ba61c3 100644 (file)
                 }
               ]
             },
+            {
+              "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 (file)
index 0000000..8c027b8
--- /dev/null
@@ -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 (executable)
index 0000000..39f4072
--- /dev/null
@@ -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 (file)
index 0000000..6bf7150
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 (file)
index 0000000..1f539dc
Binary files /dev/null and b/www/images/devices/fritzbox_7590.png differ