Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes since March 2022 #14

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lovelace: remove custom header and migrate to mushroom/tile cards
  • Loading branch information
agneevX committed Apr 12, 2023
commit bd4709b9db1063f2ef6a4a5159daa5505028c2c4
55 changes: 24 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,10 @@ Stream lofi-beats from YouTube.

<details><summary>Expand</summary>

Compile Docker image:
Pull Docker image:

```sh
# Clone repository
git clone https://github.com/agneevX/mpv-ytdl-docker
cd mpv-ytdl-docker
git checkout testing

# Build Docker image
docker build -t mpv-ytdl:latest .
docker pull agneev/mpv-ytdl:lofi
```

```yaml
Expand All @@ -286,10 +280,13 @@ Once a switch is turned on, this script is called that starts the playback...

```bash
#!/bin/bash
read MESSAGE
read -r MESSAGE

if [[ $MESSAGE == 'lofi_on' ]]; then
docker run -d --rm --name=lofi-beats -e "VIDEO_ID=abcdef" --device=/dev/snd:/dev/snd mpv-ytdl:latest
docker run -d --rm --name=lofi-beats \
-e "VIDEO_ID=abcdef" \
--device=/dev/snd:/dev/snd \
agneev/mpv-ytdl:lofi
if [[ $MESSAGE == 'lofi_off' ]]; then
docker stop lofi-beats
fi
Expand All @@ -312,33 +309,26 @@ fi

### State row

- People presence
- Shows states of various entities.

<!-- - People presence
- ASUS laptop
- Front gate camera
- Mesh router satellite/reboot
- Mesh router satellite/reboot -->

### Graph row

- Bedroom temperature
- Bedroom humidity
- Bedroom temperature/humidity

### Lights card

- Desk light
- ... Color temp card
- TV lamp
- ... RGB card
- ...
- Soundbar volume

Custom implementation that controls alsa volume, using `input_boolean`, `shell_command` and an automation.
Custom implementation that controls system alsa volume, using `input_boolean`, `shell_command` and an automation.

### Switch rows

- Adaptive Lighting
- Lofi beats/2/music radio
- Adaptive Lighting Sleep mode
- Bedroom AC/swing
- Bulb

### Now Playing card

Expand All @@ -352,22 +342,25 @@ Custom implementation that controls alsa volume, using `input_boolean`, `shell_c

[Jump to lovelace code](https://github.com/agneevX/my-ha-setup/blob/master/lovelace_raw.yaml#L551)

- Front gate camera
- Bedroom AC HVAC
- Controls
- Camera views
- AC HVAC Controls
- Humidity graphs

---

## Info view
## Room view

---

## Internet view

<img src="https://user-images.githubusercontent.com/19761269/125282540-2183f500-e335-11eb-9ead-44e163a05383.PNG" alt="Info view" align="center" width="300">

[Jump to lovelace code](https://github.com/agneevX/my-ha-setup/blob/master/lovelace_raw.yaml#L630)

### Graph rows
### Speed graphs

- Internet download speed
- Internet upload speed
- Internet download/upload speed

Custom sensors that fetch data from self-hosted [Speedtest-tracker](https://github.com/henrywhitaker3/Speedtest-Tracker) API.

Expand Down
53 changes: 46 additions & 7 deletions bash_scripts/orbi_router.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/bash
# shellcheck disable=SC2206,2046
exit

set -e
now="$(date +'%d%m%S')"

HOST=""
WEB_AUTH=""
HOST="10.0.0.1"

# Temporary code
get_satellite_uptime () {
Expand All @@ -14,6 +15,21 @@ get_satellite_uptime () {
-H 'Content-Type: application/octet-stream' \
-H "Authorization: Basic $WEB_AUTH" | grep uptime | sed 's/[^0-9]*//g')

if [[ "$o" == *"unauth"* ]]; then
exit
else
echo "$o"
fi

#sleep 2

# Log-out
# curl -s --http0.9 "http:https://10.0.0.2/logout.html" \
# -H 'Content-Type: application/octet-stream' \
# --cookie /tmp/orbi_satellite_cookie_"$now" > /dev/null

# Delete cookie
# rm /tmp/orbi_satellite_cookie_"$now"
}

ssh_command () {
Expand Down Expand Up @@ -53,6 +69,20 @@ web_scrape () {
echo "$WEB_SCRAPE" | grep var | grep '=' | grep '"' | grep "$1" | grep -o '".*"' | sed 's/"//g'
}

orbi_web_logout () {
curl -s --http0.9 "http:https://$HOST/LGO_logout.htm" \
-H 'Content-Type: application/octet-stream' \
-H "Authorization: Basic $WEB_AUTH" \
--cookie /tmp/orbi_"$now"_cookie > /dev/null
}

satellite_web_logout () {
curl -s --http0.9 "http:https://$HOST/logout.html" \
-H 'Content-Type: application/octet-stream' \
-H "Authorization: Basic $WEB_AUTH" \
--cookie /tmp/orbi_satellite_"$now"_cookie > /dev/null
}

calculate_time () {
num="$1"; min=0; hour=0; day=0
if ((num>59)); then
Expand Down Expand Up @@ -80,7 +110,10 @@ if [[ "$1" == "get_satellite_uptime" ]]; then
cat << EOF
{"status": "Connected", "Uptime": "$(calculate_time $(get_satellite_uptime))"}
EOF
else exit
else
cat << EOF
{"status": "Disconnected"}
EOF
fi
exit
fi
Expand Down Expand Up @@ -116,9 +149,13 @@ fi

#####################################################

#LOAD_AVG="$(ssh_command '/bin/cat /proc/loadavg')"
#LOAD_AVG=($LOAD_AVG)

WEB_SCRAPE=$(curl -s --http0.9 "http:https://$HOST/RST_statistic.htm" \
-H 'Content-Type: application/octet-stream' \
-H "Authorization: Basic $WEB_AUTH"
-H "Authorization: Basic $WEB_AUTH" )
#\ --cookie-jar /tmp/orbi_"$now"_cookie)

# Exit script if logged in on another device
if [[ "$WEB_SCRAPE" == *multi_login.html* ]]; then
Expand All @@ -128,6 +165,9 @@ EOF
exit
fi

#web_logout
#rm /tmp/orbi_"$now"_cookie

# Get WAN port speed/state
WAN_PORT_SPEED="$(web_scrape wan_status)"

Expand All @@ -142,9 +182,8 @@ cat << EOF
{
"status": "$WAN_STATUS",
"Uptime": "$(calculate_time $(web_scrape sys_uptime))",
"WAN Uptime": "$(calculate_time $(web_scrape wan_systime))",
"WAN Port": "$WAN_PORT_SPEED",
"LAN Port 1": "$(web_scrape lan_status0)",
"WAN Port Uptime": "$(calculate_time $(web_scrape wan_systime))",
"WAN Port": "$WAN_PORT_SPEED", "LAN Port 1": "$(web_scrape lan_status0)",
"LAN Port 2": "$(web_scrape lan_status1)",
"LAN Port 3": "$(web_scrape lan_status2)"
}
Expand Down
26 changes: 13 additions & 13 deletions config/sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@
- platform: command_line
unique_id: router_current_traffic_upload
name: Router current traffic (upload)
command: curl -s 'http:https://10.0.0.1:19999/api/v1/data?chart=net.brwan&points=1&options=jsonwrap' | jq '.latest_values[0]'
command: curl -s 'http:https://10.0.0.1:19999/api/v1/data?chart=net.eth0&points=1&options=jsonwrap' | jq '.latest_values[1]' | sed 's/-//g'
scan_interval: 3
value_template: "{{ (( value | int) / 1000) | round (1) }}"
unit_of_measurement: Mb/s

- platform: command_line
unique_id: router_current_traffic_download
name: Router current traffic (download)
command: curl -s 'http:https://10.0.0.1:19999/api/v1/data?chart=net.brwan&points=1&options=jsonwrap' | jq '.latest_values[1]' | sed 's/-//g'
command: curl -s 'http:https://10.0.0.1:19999/api/v1/data?chart=net.eth0&points=1&options=jsonwrap' | jq '.latest_values[0]'
scan_interval: 3
value_template: "{{ (( value | int) / 1000) | round (1) }}"
unit_of_measurement: Mb/s

- platform: command_line
unique_id: router_daily_traffic_upload
name: Router daily traffic (upload)
scan_interval: 180
command: curl -s http:https://10.0.0.10:8660/json.cgi | jq '.interfaces[3].traffic.day[-1].tx'
scan_interval: 180
unit_of_measurement: 'MB'
value_template: >-
{% if value_json != None %}
Expand All @@ -32,8 +32,8 @@
- platform: command_line
unique_id: router_daily_traffic_download
name: Router daily traffic (download)
scan_interval: 180
command: curl -s http:https://10.0.0.10:8660/json.cgi | jq '.interfaces[3].traffic.day[-1].rx'
scan_interval: 180
unit_of_measurement: 'MB'
value_template: >-
{% if value_json != None %}
Expand All @@ -50,7 +50,7 @@
scan_interval: 300
json_attributes:
- Uptime
- WAN Uptime
- WAN Port Uptime
- WAN Port
- LAN Port 1
- LAN Port 2
Expand All @@ -67,32 +67,32 @@
- platform: command_line
unique_id: speedtest_net_upload_speed
name: Speedtest.net upload speed
command: curl -s http:https://10.0.0.10:8700/api/speedtest/latest | jq -r '.data.upload'
command: curl -s http:https://10.0.0.10:8700/api/speedtest/latest
unit_of_measurement: 'Mb/s'
value_template: >-
{% if value_json | int < 0.1 %}
{% if value_json.data.upload | int < 0.1 %}
NaN
{% else %}
{{ value_json | round(2) }}
{{ value_json.data.upload | round(2) }}
{% endif %}

- platform: command_line
unique_id: speedtest_net_download_speed
name: Speedtest.net download speed
command: curl -s http:https://10.0.0.10:8700/api/speedtest/latest | jq -r '.data.download'
command: curl -s http:https://10.0.0.10:8700/api/speedtest/latest
unit_of_measurement: 'Mb/s'
value_template: >-
{% if value_json | int < 0.1 %}
{% if value_json.data.download | int < 0.1 %}
NaN
{% else %}
{{ value_json | round(2) }}
{{ value_json.data.download | round(2) }}
{% endif %}

- platform: command_line
unique_id: server_network_traffic_upload
name: Server network traffic (upload)
command: curl -s --interface eth0 http:https://10.0.0.11:7077/json.cgi | jq '.interfaces[0].traffic.day[-1].tx'
scan_interval: 180
command: curl -s http:https://10.0.0.11:7077/json.cgi | jq '.interfaces[0].traffic.day[-1].tx'
unit_of_measurement: 'MB'
value_template: >-
{% if value_json != None %}
Expand All @@ -104,8 +104,8 @@
- platform: command_line
unique_id: server_network_traffic_download
name: Server network traffic (download)
command: curl -s --interface eth0 http:https://10.0.0.11:7077/json.cgi | jq '.interfaces[0].traffic.day[-1].rx'
scan_interval: 180
command: curl -s http:https://10.0.0.11:7077/json.cgi | jq '.interfaces[0].traffic.day[-1].rx'
unit_of_measurement: 'MB'
value_template: >-
{% if value_json != None %}
Expand Down
Loading