Add IoT, Maintenance and Router pages

This commit is contained in:
Thomas Dehaeze 2021-10-25 14:27:16 +02:00
parent 137f160229
commit b511e86af2
3 changed files with 682 additions and 0 deletions

557
iot.org Normal file
View File

@ -0,0 +1,557 @@
#+TITLE: IoT
#+SETUPFILE: ./setup/org-setup-file.org
* Smart Bulbs
https://www.amazon.fr/Ecologique-Compatible-T%C3%A9l%C3%A9commande-Smartphone-%C3%A9nerg%C3%A9tique/dp/B07KWPQMHH/ref=sr_1_4?dchild=1&keywords=Anoopsyche&qid=1626991095&sr=8-4
* Smart Plugs
https://sonoff.tech/product/smart-plug/s26/
https://www.jannikarndt.de/blog/2018/01/how_to_install_tasmota_on_a_sonoff_device_without_opening_it/
https://www.youtube.com/watch?v=ONFhXM5R-t4
* ESPHome
** Sonoff S26 - Smart Socket
https://www.amazon.fr/Connect%C3%A9e-Intelligente-Compatible-Assistant-T%C3%A9l%C3%A9command%C3%A9e/dp/B07Y1N5J6Y/
*** Sonoff S26 1
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_S26_1.yaml
esphome:
name: sonoffs26_1
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Sonoff S26 1 Fallback Hotspot'
password: '<<get-password(passname="sonoff_s26/ap")>>'
status_led:
pin:
number: GPIO13
inverted: false
logger:
api:
password: '<<get-password(passname="sonoff_s26/api")>>'
ota:
password: '<<get-password(passname="sonoff_s26/ota")>>'
web_server:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff S26_1 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S26_1 Status"
sensor:
- platform: wifi_signal
name: "sonoffs26_1 WiFi Signal"
update_interval: 60s
switch:
- platform: gpio
name: "Sonoff S26_1 Relay"
pin: GPIO12
id: 'relay'
- platform: restart
name: "sonoffs26_1 Restart"
#+end_src
*** Sonoff S26 2
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_S26_2.yaml
esphome:
name: sonoffs26_2
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Sonoff S26 2 Fallback Hotspot'
password: '<<get-password(passname="sonoff_s26/ap")>>'
status_led:
pin:
number: GPIO13
inverted: false
logger:
api:
password: '<<get-password(passname="sonoff_s26/api")>>'
ota:
password: '<<get-password(passname="sonoff_s26/ota")>>'
web_server:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff S26_2 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S26_2 Status"
sensor:
- platform: wifi_signal
name: "sonoffs26_2 WiFi Signal"
update_interval: 60s
switch:
- platform: gpio
name: "Sonoff S26_2 Relay"
pin: GPIO12
id: 'relay'
- platform: restart
name: "sonoffs26_2 Restart"
#+end_src
*** Sonoff S26 3
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_S26_3.yaml
esphome:
name: sonoffs26_3
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Sonoff S26 3 Fallback Hotspot'
password: '<<get-password(passname="sonoff_s26/ap")>>'
status_led:
pin:
number: GPIO13
inverted: false
logger:
api:
password: '<<get-password(passname="sonoff_s26/api")>>'
ota:
password: '<<get-password(passname="sonoff_s26/ota")>>'
web_server:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff S26_3 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S26_3 Status"
sensor:
- platform: wifi_signal
name: "sonoffs26_3 WiFi Signal"
update_interval: 60s
switch:
- platform: gpio
name: "Sonoff S26_3 Relay"
pin: GPIO12
id: 'relay'
- platform: restart
name: "sonoffs26_3 Restart"
#+end_src
*** Sonoff S26 4
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_S26_4.yaml
esphome:
name: sonoffs26_4
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Sonoff S26 4 Fallback Hotspot'
password: '<<get-password(passname="sonoff_s26/ap")>>'
status_led:
pin:
number: GPIO13
inverted: false
logger:
api:
password: '<<get-password(passname="sonoff_s26/api")>>'
ota:
password: '<<get-password(passname="sonoff_s26/ota")>>'
web_server:
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff S26_4 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S26_4 Status"
sensor:
- platform: wifi_signal
name: "sonoffs26_4 WiFi Signal"
update_interval: 60s
switch:
- platform: gpio
name: "Sonoff S26_4 Relay"
pin: GPIO12
id: 'relay'
- platform: restart
name: "sonoffs26_4 Restart"
#+end_src
** Anoopsyche SB14 - E27 Smart Bulb (Cold White / Warm White)
https://www.amazon.fr/Ecologique-Compatible-T%C3%A9l%C3%A9commande-Smartphone-%C3%A9nerg%C3%A9tique/dp/B07KWPQMHH/
*** Anoopsyche CWWW 1
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/anoopsyche_cwww_1.yaml
esphome:
name: anoopsyche_cwww_1
platform: ESP8266
board: esp01_1m
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Anoopsyche CWWW 1'
password: '<<get-password(passname="anoopsyche_cwww/ap")>>'
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: '<<get-password(passname="anoopsyche_cwww/api")>>'
ota:
password: '<<get-password(passname="anoopsyche_cwww/ota")>>'
output:
- platform: esp8266_pwm
id: output_cold_white
pin: GPIO5
- platform: esp8266_pwm
id: output_warm_white
pin: GPIO13
light:
- platform: cwww
name: 'Anoopsyche CWWW 1'
default_transition_length: 1s
warm_white: output_warm_white
cold_white: output_cold_white
cold_white_color_temperature: 6000 K
warm_white_color_temperature: 2700 K
#+end_src
*** Anoopsyche CWWW 2
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/anoopsyche_cwww_2.yaml
esphome:
name: anoopsyche_cwww_2
platform: ESP8266
board: esp01_1m
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Anoopsyche CWWW 2'
password: '<<get-password(passname="anoopsyche_cwww/ap")>>'
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: '<<get-password(passname="anoopsyche_cwww/api")>>'
ota:
password: '<<get-password(passname="anoopsyche_cwww/ota")>>'
output:
- platform: esp8266_pwm
id: output_cold_white
pin: GPIO5
- platform: esp8266_pwm
id: output_warm_white
pin: GPIO13
light:
- platform: cwww
name: 'Anoopsyche CWWW 2'
default_transition_length: 1s
warm_white: output_warm_white
cold_white: output_cold_white
cold_white_color_temperature: 6000 K
warm_white_color_temperature: 2700 K
#+end_src
** Sonoff BasicR2 - DIY Smart Socket
- [[https://esphome.io/devices/sonoff_basic.html][ESPHome documentation]]
- [[https://sonoff.tech/product/diy-smart-switch/basicr2/][Sonoff Website]]
*** Sonoff Basic 1
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_basic_1.yaml
esphome:
name: sonoffbasic_1
platform: ESP8266
board: esp8285
arduino_version: 2.4.2
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
api:
password: '<<get-password(passname="sonoff_basic/api")>>'
logger:
ota:
password: '<<get-password(passname="sonoff_basic/ota")>>'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff Basic Button 1"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff Basic Relay 1"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
#+end_src
*** Sonoff Basic 2
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_basic_2.yaml
esphome:
name: sonoffbasic_2
platform: ESP8266
board: esp8285
arduino_version: 2.4.2
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
api:
password: '<<get-password(passname="sonoff_basic/api")>>'
logger:
ota:
password: '<<get-password(passname="sonoff_basic/ota")>>'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff Basic Button 2"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff Basic Relay 2"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
#+end_src
*** Sonoff Basic 3
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_basic_3.yaml
esphome:
name: sonoffbasic_3
platform: ESP8266
board: esp8285
arduino_version: 2.4.2
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
api:
password: '<<get-password(passname="sonoff_basic/api")>>'
logger:
ota:
password: '<<get-password(passname="sonoff_basic/ota")>>'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff Basic Button 3"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff Basic Relay 3"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
#+end_src
*** Sonoff Basic 4
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_basic_4.yaml
esphome:
name: sonoffbasic_4
platform: ESP8266
board: esp8285
arduino_version: 2.4.2
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
api:
password: '<<get-password(passname="sonoff_basic/api")>>'
logger:
ota:
password: '<<get-password(passname="sonoff_basic/ota")>>'
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff Basic Button 4"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff Basic Relay 4"
pin: GPIO12
id: relay
status_led:
pin:
number: GPIO13
inverted: yes
#+end_src
** Sonoff POWR2 - DIY Power Monitoring Smart Socket
- [[https://sonoff.tech/product/diy-smart-switch/powr2/][Sonoff Website]]
*** Sonoff POWR2 1
#+begin_src yaml :noweb yes :tangle ~/.local/data/esphome/config/sonoff_powr2_1.yaml
esphome:
name: sonoffpowr2_1
platform: ESP8266
board: esp01_1m
board_flash_mode: dout
wifi:
ssid: 'Freebox-11A882'
password: '<<get-password(passname="wifi/Freebox-11A882")>>'
ap:
ssid: 'Sonoff POWR2 1 Fallback Hotspot'
password: 'gmHu3rQHZHwH'
mqtt:
broker: '192.168.1.11'
logger:
api:
password: '<<get-password(passname="sonoff_powr2/api")>>'
ota:
password: '<<get-password(passname="sonoff_powr2/ota")>>'
uart:
rx_pin: RX
baud_rate: 4800
sensor:
- platform: cse7766
current:
name: "Sonoff POWR2_1 Current"
voltage:
name: "Sonoff POWR2_1 Voltage"
power:
name: "Sonoff POWR2_1 Power"
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff POWR2_1 Button"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "Sonoff POWR2_1 Relay"
pin: GPIO12
id: 'relay'
#+end_src

91
maintenance.org Normal file
View File

@ -0,0 +1,91 @@
#+TITLE:System maintenance
#+SETUPFILE: ./setup/org-setup-file.org
https://wiki.archlinux.org/title/System_maintenance
* Update
** System packages
To check packages to update:
#+begin_src bash
paru -Qu
#+end_src
And then to perform the update:
#+begin_src bash
paru
#+end_src
** NPM
First update =npm= itself
#+begin_src bash
sudo npm install npm@latest -g
#+end_src
Then, we can list outdated packages:
#+begin_src bash
npm outdated -g --depth=0
#+end_src
And finally perform the update:
#+begin_src bash
sudo npm update -g
#+end_src
** PIP
First upgrade =pip= itself:
#+begin_src bash
/usr/bin/python3 -m pip install --upgrade pip
#+end_src
Then list outdated packages:
#+begin_src bash
pip3 list --outdated
#+end_src
And update everything with:
#+begin_src bash
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
#+end_src
** Emacs and Vim
Update Doom emacs with:
#+begin_src bash
doom up
#+end_src
And Vim packages with:
#+begin_src bash
nvim -c PlugUpgrade -c PlugUpdate
#+end_src
* Check problems in the system
First check for failed services:
#+begin_src bash
systemctl --failed
#+end_src
Same for user services:
#+begin_src bash
systemctl --user --failed
#+end_src
Look for errors in the logs:
#+begin_src bash
sudo journalctl -p 3 -b
#+end_src
* Check orphan and dropped packages
Run the following to list all orphan packages:
#+begin_src bash
pacman -Qtdq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)'
#+end_src
Then, either remove the unused packages or set the package to "explicitly installed" with:
#+begin_src bash
sudo pacman -D --asexplicit package_name
#+end_src
Use the =ancient-packages= ([[https://aur.archlinux.org/packages/ancient-packages/][link]]) command to list dropped packages (packages may longer in the remote repositories, but still on the local system):
#+begin_src bash
ancient-packages
#+end_src

34
router.org Normal file
View File

@ -0,0 +1,34 @@
#+TITLE: Open-WRT Router (Netgear R7000)
#+SETUPFILE: ./setup/org-setup-file.org
* Installation
** Freebox - Bridge mode
https://blog.kulakowski.fr/post/openwrt-derriere-une-freebox-ipv6-dmz-et-bridge
** Enable SSL
How can I enable SSL for the web admin gui?
In an SSH-command line, run opkg update, then install the package opkg install luci-ssl, then restart the router. Then you can access https://192.168.1.1 or https://openwrt with your favorite web browser
** Install useful packages
#+begin_src bash
opkg update && opkg install luci-ssl-openssl luci-theme-material ipset curl diffutils speedtest-netperf kmod-ipt-nat6
#+end_src
* Update
#+begin_src bash
opkg list-upgradable | cut -f 1 -d ' ' | xargs -r opkg upgrade
#+end_src
* Configuration
https://openwrt.org/docs/guide-user/base-system/uci#common_principles
Configuration files are in =/etc/config=.
| *File* | *Description* |
|------------------------+------------------------------------------------|
| =/etc/config/dhcp= | Dnsmasq and odhcpd settings: DNS, DHCP, DHCPv6 |
| =/etc/config/dropbear= | SSH server options |
| =/etc/config/firewall= | NAT, packet filter, port forwarding, etc. |
| =/etc/config/network= | Switch, interface and route configuration: |
| =/etc/config/system= | Misc. system settings, NTP, RNG, Watchcat |
| =/etc/config/wireless= | Wireless settings and wifi network definition |