Giter Site home page Giter Site logo

deadbeef3137 / ha-cloudflare-tunnel-monitor Goto Github PK

View Code? Open in Web Editor NEW
11.0 2.0 6.0 157 KB

Integration (custom_component) for Home Assistant that monitors the status of your Cloudflare tunnels.

License: MIT License

Python 100.00%
cloudflare cloudflare-tunnel homeassistant homeassistant-custom-component homeassistant-integration

ha-cloudflare-tunnel-monitor's Introduction

Cloudflare Tunnel Monitor Home Assistant Integration

License: MIT Cloudflare Tunnel Monitor|128

Description

This custom integration for Home Assistant allows users to monitor the status of their Cloudflare Tunnels directly from their Home Assistant instance. The integration fetches the status of Cloudflare Tunnels and presents it as sensor entities in Home Assistant.

Installation

Via HACS (Home Assistant Community Store)

  1. Navigate to the HACS page on your Home Assistant instance.
  2. Go to the "Integrations" tab and click the "Explore & Add Repositories" button.
  3. Search for "Cloudflare Tunnel Monitor" and select it.
  4. Click on "Install this repository in HACS".
  5. Restart your Home Assistant instance.

Manual Installation

  1. Clone this repository or download the zip file.
  2. Copy the cloudflare_tunnel_monitor directory from the custom_components directory in this repository to the custom_components directory on your Home Assistant instance.
  3. Restart your Home Assistant instance.

Configuration

Cloudflare Setup

1. Copy your Account ID.

Account ID

2. Create an API Token.

API Token

Via UI

  1. Navigate to "Configuration" -> "Integrations" -> "+".
  2. Search for "Cloudflare Tunnel Monitor" and select it.
  3. Fill in the required information and click "Submit".

Configuration Variables

  • api_key: Your Cloudflare API Token with Account:Cloudflare Tunnel:Read permissions
  • account_id: Your Cloudflare Account ID.

Usage

Upon successful configuration, the integration will create sensor entities for each Cloudflare Tunnel. These sensors will reflect the current status of each tunnel.

Support

If you encounter any issues or require further assistance, please raise an issue on this GitHub repository.

License

This integration is released under the MIT License.

Disclaimer

This project is not affiliated with or endorsed by Cloudflare.

ha-cloudflare-tunnel-monitor's People

Contributors

deadbeef3137 avatar jorgwolski avatar mukaschultze avatar syphernl avatar viper5000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ha-cloudflare-tunnel-monitor's Issues

v2.0.0 - Email field missing

The new version 2.0.0 doesn't have the email field anymore. I removed the integration to get rid of the old (not used) tunnels.
After I want setup the integration this email filed was gone.

Cleared cache, restart safari didn't help as well

v2.0.0 - Errors logs

Since v2.0.0 I see errors logs. This was not happen with version before.

2024-01-17 17:52:58.398 ERROR (MainThread) [custom_components.cloudflare_tunnel_monitor.sensor] Error fetching sensor data: Update failed: 
2024-01-17 18:05:58.596 ERROR (MainThread) [custom_components.cloudflare_tunnel_monitor.sensor] Error fetching sensor data: Update failed: 
2024-01-17 18:06:22.943 ERROR (MainThread) [custom_components.cloudflare_tunnel_monitor.sensor] Error fetching Cloudflare tunnels: 504
2024-01-17 18:06:22.947 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.cloudflare_tunnel_zerotrust_status fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 898, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1216, in async_device_update
    await self.async_update()
  File "/config/custom_components/cloudflare_tunnel_monitor/sensor.py", line 115, in async_update
    self._tunnel = next((tunnel for tunnel in self.coordinator.data if tunnel['id'] == self._tunnel['id']), self._tunnel)

2024-01-18 06:07:28.705 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.cloudflare_tunnel_zerotrust_status fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 898, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1216, in async_device_update
    await self.async_update()
  File "/config/custom_components/cloudflare_tunnel_monitor/sensor.py", line 115, in async_update
    self._tunnel = next((tunnel for tunnel in self.coordinator.data if tunnel['id'] == self._tunnel['id']), self._tunnel)

too many tunnels

I've configured the plugin on my HA and it seems to work well, event too much!
I have entities that are not present in my tunnels. I've also controlled in the DNS records, and they arenot present too.
Where do they come from?
tnx for the help

(no issue) Remove old tunnels

Hi There,

Great integration. In past I was testing a lot how tunnels working etc. Used RPI, my iMac etc... Now I'm settled and my tunnel is running perfect on my NAS.

After the integration has been done I see lots of old inactive tunnels. On the Portal of Cloudflare I can't find them.

Do you know maybe how I can remove those old tunnels with all kind of names: test, rpi4test, cf-test etc etc...

Greets

Request - Tunnel version

Hi. Am not sure if this possible.

Is there away to get the version of a tunnel software being used or if there is new version in to HA? So I get a notification to upgrade to latest version

Cloudflare gives 404:

This error originated from a custom integration.

Logger: custom_components.cloudflare_tunnel_monitor.sensor
Source: custom_components/cloudflare_tunnel_monitor/sensor.py:70
Integration: Cloudflare Tunnel Monitor (documentation, issues)
First occurred: 10:42:13 (8 occurrences)
Last logged: 11:19:40

Error fetching Cloudflare tunnels: 404

Error fetching data

I've been receiving this alert for a few months, what could be happening?

2024-04-14 12:12:31.917 ERROR (MainThread) [custom_components.cloudflare_tunnel_monitor.sensor] Error fetching data: 
2024-04-14 12:12:51.917 WARNING (MainThread) [homeassistant.components.sensor] Updating cloudflare_tunnel_monitor sensor took longer than the scheduled update interval 0:00:30
2024-04-14 13:59:32.092 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.cloudflare_tunnel_homeassistant is taking over 10 seconds
2024-04-14 13:59:32.094 ERROR (MainThread) [custom_components.cloudflare_tunnel_monitor.sensor] Error fetching data: 
2024-04-14 13:59:52.091 WARNING (MainThread) [homeassistant.components.sensor] Updating cloudflare_tunnel_monitor sensor took longer than the scheduled update interval 0:00:30

Use of Non Global API

Hello,

Awesome work on this integration by the way!

However is there any chance that we don't need to use the Global API key? Not to happy security wise to be using the Global API.

Aydan

Tunnel unavailable

I have three tunnels that I want to monitor, but integration are loosing the status "connection to cloudflare" of tunnels and they stay as "Unavailable"
I have reconfigured it again and only have one device.
If I reload the integration they are going back to healthy.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.