Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/swetoast/smartresolver
https://github.com/swetoast/smartresolver
automation homeassistant loopia
Last synced: 30 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/swetoast/smartresolver
- Owner: swetoast
- License: unlicense
- Created: 2024-02-22T19:52:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-22T20:01:45.000Z (10 months ago)
- Last Synced: 2024-02-23T20:59:24.618Z (10 months ago)
- Topics: automation, homeassistant, loopia
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dynamic DNS Update for Home Assistant
This project is a Flask application that updates the dynamic DNS records for a list of hostnames with Loopia as the DNS provider. It also includes a Home Assistant sensor and automation.
## Installation
1. Clone the repository:
```bash
git clone https://github.com/swetoast/smartresolver.git
```
2. Navigate to the project directory:
```bash
cd smartresolver
```
3. Install the required Python packages:
```bash
pip install flask requests configparser
```## Configuration
1. Open `dns_endpoint.conf` in a text editor.
2. Under the `[Credentials]` section, set `username` and `password` to your Loopia DNS credentials.
3. Under the `[Hostnames]` section, set `hostnames` to a comma-separated list of hostnames to update.
4. Under the `[DEFAULT]` section, set `HOST`, `PORT`, `USE_HTTPS`, `CERTIFICATE_PATH`, and `KEY_PATH` as needed.## Running the Application
1. Start the application:
```bash
python smartresolver.py
```
2. The application will now update your dynamic DNS records whenever you access `http://IP_ADDRESS:PORT/update_dyndns`.## Home Assistant Sensor
To add a sensor in Home Assistant that triggers the dynamic DNS update:
1. Add the following to your `configuration.yaml`:
```yaml
sensor:
- platform: rest
resource: http://IP_ADDRESS:PORT/update_dyndns
name: DNS Resolver
value_template: '{{ value_json[0].status }}'
json_attributes:
- 'hostname'
- 'ip_address'
scan_interval:
hours: 4
```
2. Restart Home Assistant to apply the changes.## Home Assistant Automation
To add an automation in Home Assistant that triggers the dynamic DNS update when the IP address does not match:
1. Add the following to your `automations.yaml`:
```yaml
alias: "Auto-Update: Update DNS Resolver on IP Mismatch"
description: >-
This automation updates the DNS Resolver sensor when its IP address does not
match with the external IP sensor.
trigger:
- platform: template
value_template: >-
{{ states('sensor.external_ip') != state_attr('sensor.dns_resolver',
'ip_address') }}
action:
- service: homeassistant.update_entity
target:
entity_id: sensor.dns_resolver
data: {}
mode: restart
```
2. Restart Home Assistant to apply the changes.## License
This project is unlicensed.