Add config flow to cloudflare (#14904)

This commit is contained in:
Chris Talkington 2020-10-21 09:12:27 -05:00 committed by GitHub
parent ed283402c0
commit cc61451e68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,7 +7,9 @@ ha_release: 0.74
ha_iot_class: Cloud Push ha_iot_class: Cloud Push
ha_codeowners: ha_codeowners:
- '@ludeeus' - '@ludeeus'
- '@ctalkington'
ha_domain: cloudflare ha_domain: cloudflare
ha_config_flow: true
--- ---
With the `cloudflare` integration, you can keep your Cloudflare records up to date. With the `cloudflare` integration, you can keep your Cloudflare records up to date.
@ -26,43 +28,25 @@ Due to a limitation in the Cloudflare API, you can not use this integration with
</div> </div>
## Setup ## Requirements
You can find your global API key in your Cloudflare account settings. <div class='note warning'>
On older versions of Home Assistant, this integration used the account email and Global API Key to authenticate.
As of Home Assistant 0.117, API Tokens are now used to authenticate.
</div>
Setup requires an API Token created with Zone:Zone:Read and Zone:DNS:Edit permissions for all zones in your account.
An easy way to create this is to start with the "Edit zone DNS" template then add Zone:Zone:Read to the permissions.
[Cloudflare API Tokens Guide](https://developers.cloudflare.com/api/tokens/create)
## Configuration ## Configuration
To use the integration in your installation, add the following to your `configuration.yaml` file: Go to the integrations page in your configuration and click on new integration -> Cloudflare.
```yaml
# Example configuration.yaml entry
cloudflare:
email: YOUR_EMAIL_ADDRESS
api_key: YOUR_GLOBAL_API_KEY
zone: EXAMPLE.COM
records:
- ha
- www
```
{% configuration cloudflare %}
email:
description: The email address for your Cloudflare account.
required: true
type: string
api_key:
description: The global API key for your Cloudflare account.
required: true
type: string
zone:
description: The DNS zone (domain) you want to update.
required: true
type: string
records:
description: A list of records (subdomains) you want to update.
required: true
type: list
{% endconfiguration %}
## Additional information ## Additional information
@ -70,10 +54,6 @@ records:
This platform uses the API from [ipify.org](https://www.ipify.org/) to set the public IP address. This platform uses the API from [ipify.org](https://www.ipify.org/) to set the public IP address.
### API Key
Please note that the `api_key` is the [global API key](https://support.cloudflare.com/hc/en-us/articles/200167836-Managing-API-Tokens-and-Keys#12345682) of your Cloudflare account (not the API Token).
### Home Assistant Companion App ### Home Assistant Companion App
If you would like to use [iOS App](https://companion.home-assistant.io/) via Cloudflare set **Minimum TLS version as 1.2**, in order to do that, do the following: If you would like to use [iOS App](https://companion.home-assistant.io/) via Cloudflare set **Minimum TLS version as 1.2**, in order to do that, do the following:
@ -89,20 +69,6 @@ Other settings should not cause any issues.
For SSH usage (according to [this](https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/) source), you need to connect directly to your server (bypassing Cloudflare). To do that, create a `CNAME` DNS record, e.g., `ssh.example.com`, with proxy status as "DNS only" (to do that click on orange icon, it will change color to gray) and then connect to `ssh.example.com` using your server SSH port. For SSH usage (according to [this](https://blog.cloudflare.com/cloudflare-now-supporting-more-ports/) source), you need to connect directly to your server (bypassing Cloudflare). To do that, create a `CNAME` DNS record, e.g., `ssh.example.com`, with proxy status as "DNS only" (to do that click on orange icon, it will change color to gray) and then connect to `ssh.example.com` using your server SSH port.
### Using Cloudflare domain only for Home Assistant
If you want to update just a main domain, place in the records list only your domain, e.g., `example.com`. It will update your `A` DNS record with your IP every hour.
```yaml
# Example configuration.yaml entry for one domain
cloudflare:
email: YOUR_EMAIL_ADDRESS
api_key: YOUR_GLOBAL_API_KEY
zone: EXAMPLE.COM
records:
- EXAMPLE.COM
```
#### The minimum DNS record settings (if you have set up HTTPS already) #### The minimum DNS record settings (if you have set up HTTPS already)
To redirect from your domain to the IP address of your Home Assistant server set this DNS record: To redirect from your domain to the IP address of your Home Assistant server set this DNS record: