Skip to content

amm3/homeautomation_scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Home Automation (Misc) Scripts

pihole_backup_restore

A Python script to synchronize Pi-hole configurations between two instances using the Teleporter API. Downloads a backup from one Pi-hole server and uploads it to another, useful for keeping primary and secondary Pi-hole instances in sync.

Usage

./pihole_backup_restore.py --host1 pihole1.local --host2 pihole2.local --passwd yourpassword

Arguments

Argument Description
--host1, -1 Source Pi-hole host (backup downloaded from here)
--host2, -2 Destination Pi-hole host (backup uploaded here)
--passwd, -p Password for both Pi-hole instances (must be the same)
--port Non-standard port (optional)
--ssl Connect via HTTPS (optional)
-v Verbose output
-vv Debug output

What Gets Synced

  • Configuration settings
  • DHCP leases
  • Gravity database (adlists, groups, domains, clients)

Example Cron Job

To sync configurations daily at 3 AM:

0 3 * * * /path/to/pihole_backup_restore.py -1 pihole1.local -2 pihole2.local -p yourpassword

screen_server

A python web server to control dpms (Display Power Management Signaling) via simple GET requests. Built for integration with Home Assistant, using the rest_command service.

To run from systemd, create a service file at /etc/systemd/system/screenweb.service:

[Unit]
Description=Web Service for managing screen status
After=screenweb.service

[Service]
ExecStart=/bin/sh -c "/usr/bin/python3 /home/pi/screen_server.py"
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

Home Assistant

configuration.yaml

rest_command:

  pidisplay_on:
    url: http://raspberrypi.local:8000/on
    method: GET
    content_type:  'application/json; charset=utf-8'

  pidisplay_off:
    url: http://raspberrypi.local:8000/off
    method: GET
    content_type:  'application/json; charset=utf-8'

  pidisplay_set:
    url: "{{ 'http://raspberrypi.local:8000/set/' + value|string }}"
    method: GET
    content_type:  'application/json; charset=utf-8'

In Automation

  • Turn On
  action:
  - service: rest_command.pidisplay_on
  • Turn Off
  action:
  - service: rest_command.pidisplay_off
  • Set Timeout
  action:
  - service: rest_command.pidisplay_set
    data:
      value: 3600

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages