Repository navigation
feat(home-assistant): eero status from DHCP renewals, and the eeros at their reservations #1232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| --- | ||
| # The eero units' status, for monitoring only (#1228). | ||
| # | ||
| # There is no local eero API, and ADR-0019 declined the cloud integration. | ||
| # But every eero takes its address from Kea on morpheus and renews it about | ||
| # hourly, and Kea's lease lines are already in Loki. A unit that has renewed | ||
| # in the last two hours is on the network. One that has not is down, or off | ||
| # its segment. | ||
| # | ||
| # Each unit has a Kea reservation below its segment's pool, so the address | ||
| # is the unit and no MAC is written here. The rows in network.md name which | ||
| # unit holds which address. | ||
| # | ||
| # One query covers all eight: lease renewals in the last two hours, summed by | ||
| # address. Lines from other devices fail the pattern and are dropped by the | ||
| # `ip != ""` filter. An address missing from the result has not renewed. Loki is | ||
| # reached the way homelab_rack.yaml reaches Prometheus: the ingest proxy on | ||
| # 10.0.99.20, with the reader token and the estate CA. | ||
|
|
||
| rest: | ||
| - resource: https://10.0.99.20:3100/loki/api/v1/query | ||
| headers: | ||
| Authorization: !env_var HA_PROMETHEUS_AUTHORIZATION | ||
| params: | ||
| query: >- | ||
| sum by (ip) (count_over_time({app="kea-dhcp4"} | ||
| |= "DHCP4_LEASE_ALLOC" | ||
| | regexp `lease (?P<ip>10\.0\.(10|20|50)\.1[1-3]) has been allocated` | ||
| | ip != "" [2h])) | ||
| scan_interval: 300 | ||
| timeout: 15 | ||
| # Every sensor below is unavailable, not "off", when Loki has no answer, | ||
| # so a monitoring outage is not reported as eight eeros down. | ||
| binary_sensor: | ||
| - name: eero Hicks 11 | ||
| unique_id: eero_hicks_11 | ||
| device_class: connectivity | ||
| availability: &loki_ok "{{ value_json is defined and value_json.status == 'success' }}" | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.50.11') | list | count > 0 }}" | ||
| - name: eero Hicks 12 | ||
| unique_id: eero_hicks_12 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.50.12') | list | count > 0 }}" | ||
| - name: eero Hicks 13 | ||
| unique_id: eero_hicks_13 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.50.13') | list | count > 0 }}" | ||
| - name: eero Skids 11 | ||
| unique_id: eero_skids_11 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.20.11') | list | count > 0 }}" | ||
| - name: eero Skids 12 | ||
| unique_id: eero_skids_12 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.20.12') | list | count > 0 }}" | ||
| - name: eero Skids 13 | ||
| unique_id: eero_skids_13 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.20.13') | list | count > 0 }}" | ||
| - name: eero Degens 11 | ||
| unique_id: eero_degens_11 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.10.11') | list | count > 0 }}" | ||
| - name: eero Degens 12 | ||
| unique_id: eero_degens_12 | ||
| device_class: connectivity | ||
| availability: *loki_ok | ||
| value_template: "{{ value_json.data.result | selectattr('metric.ip', 'eq', '10.0.10.12') | list | count > 0 }}" | ||
|
|
||
| automation: | ||
| # No `from:`, so a unit already down when Home Assistant starts is | ||
| # reported once the first poll comes back. Through script.household_alert | ||
| # in thermostat.yaml, which sends to the phones labelled `household_phones` | ||
| # and to Home Assistant's notifications. | ||
| - id: eero_offline | ||
| alias: eero offline | ||
| description: Alerts when an eero unit has not renewed its DHCP lease in two hours. | ||
| mode: queued | ||
| triggers: | ||
| - trigger: state | ||
| entity_id: | ||
| - binary_sensor.eero_hicks_11 | ||
| - binary_sensor.eero_hicks_12 | ||
| - binary_sensor.eero_hicks_13 | ||
| - binary_sensor.eero_skids_11 | ||
| - binary_sensor.eero_skids_12 | ||
| - binary_sensor.eero_skids_13 | ||
| - binary_sensor.eero_degens_11 | ||
| - binary_sensor.eero_degens_12 | ||
| to: "off" | ||
| actions: | ||
| - action: script.household_alert | ||
| data: | ||
| title: "{{ state_attr(trigger.entity_id, 'friendly_name') }} offline" | ||
| message: >- | ||
| {{ state_attr(trigger.entity_id, 'friendly_name') }} has not | ||
| renewed its network lease in two hours. Check its power, and the | ||
| eero app. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.