Skip to content

Commit

Permalink
Merge pull request #21 from Snuffy2/Implement-Config-Flow
Browse files Browse the repository at this point in the history
Overall update and Implement Config Flow
  • Loading branch information
heythisisnate authored Oct 17, 2024
2 parents df714c5 + f936ead commit 8fc50a5
Show file tree
Hide file tree
Showing 12 changed files with 983 additions and 216 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
5 changes: 5 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
changelog:
exclude:
labels:
- ignore-for-release
- dependencies
20 changes: 20 additions & 0 deletions .github/workflows/ha_and_hacs_validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: HA and HACS Validate

on:
push:
pull_request:
workflow_dispatch:

jobs:
ha_and_hacs_validation:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Hassfest validation
uses: home-assistant/actions/hassfest@master
- name: HACS validation
uses: hacs/[email protected]
with:
category: integration
ignore: brands
54 changes: 54 additions & 0 deletions .github/workflows/zip_on_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Create Zip on Release
on:
workflow_dispatch:
release:
types: [published, edited]
jobs:
create_zip:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Debug Variables
run: |
echo "github.event_name: ${{ github.event_name }}"
echo "github.ref_name: ${{ github.ref_name }}"
echo "github.event.repository.default_branch: ${{ github.event.repository.default_branch }}"
echo "github.event.release.target_commitish: ${{ github.event.release.target_commitish }}"
echo "github.event.release.prerelease: ${{ github.event.release.prerelease }}"
echo "github.event.release.draft: ${{ github.event.release.draft }}"
- name: Update Version in Manifest
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
run: |
sed -i 's/\"version\"\s*\:\s*\".*\"/\"version\"\:\"${{ github.ref_name }}\"/g' ./custom_components/noonlight/manifest.json
- name: Update Version in const.py
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
run: |
sed -i 's/VERSION \= \".*\"/VERSION \= \"${{ github.ref_name }}\"/' ./custom_components/noonlight/const.py
- name: Commit & Push Version Changes
if: ${{ github.event_name == 'release' && github.event.release.prerelease == false && github.event.release.draft == false }}
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.event.release.target_commitish }}
message: 'Updating to version ${{ github.ref_name }}'
- name: Create Zip
uses: thedoctor0/[email protected]
with:
type: 'zip'
filename: 'noonlight.zip'
directory: ./custom_components/noonlight
- name: Upload Zip to Release
if: ${{ github.event_name == 'release' }}
uses: Roang-zero1/[email protected]
with:
args: ./custom_components/noonlight/noonlight.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add Zip to Action
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: actions/[email protected]
with:
name: noonlight
path: ./custom_components/noonlight/noonlight.zip
if-no-files-found: error
78 changes: 44 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ This is the [Noonlight](https://noonlight.com) integration for HomeAssistant.

[Noonlight](https://noonlight.com) connects your smart home to local emergency services to help keep you safe in case of a break-in, fire, or medical emergency.

<p class='note info'>
Noonlight service is currently available in the United States.
</p>
### Noonlight service is currently only available in the United States

## How it Works

Noonlight connects to emergency 9-1-1 services in all 50 U.S. states. Backed by a UL-compliant alarm monitoring center and staffed 24/7 with live operators in the United States, Noonlight is standing by to send help to your home at a moment's notice.

When integrated with Home Assistant, a **Noonlight Alarm** switch will appear in your list of entities. When the Noonlight Alarm switch is turned _on_, this will send an emergency signal to Noonlight. You will be contacted by text and voice at the phone number associated with your Noonlight account. If you confirm the emergency with the Noonlight operator, or if you're unable to respond, Noonlight will dispatch local emergency services to your home using the [longitude and latitude coordinates](https://www.home-assistant.io/docs/configuration/basic/#latitude) specified in your Home Assistant configuration.
When integrated with Home Assistant, a **Noonlight Alarm** switch will appear in your list of entities. When the Noonlight Alarm switch is turned _on_, this will send an emergency signal to Noonlight. You will be contacted by text and voice at the phone number associated with your Noonlight account. If you confirm the emergency with the Noonlight operator, or if you're unable to respond, Noonlight will dispatch local emergency services to your home using the [longitude and latitude coordinates](https://www.home-assistant.io/docs/configuration/basic/#latitude) specified in your Home Assistant configuration or an address you specify in the Noonlight configuration.

Additionally, a new service will be exposed to Home Assistant: `noonlight.create_alarm`, which allows you to explicitly specify the type of emergency service required by the alarm: medical, fire, or police. By default, the switch entity assumes "police".

Expand All @@ -27,30 +25,40 @@ Setup requires a U.S. based mobile phone number.
1. Ensure that your [longitude and latitude coordinates](https://www.home-assistant.io/docs/configuration/basic/#latitude) are set accurately so that Noonlight knows where to send help.

1. Click the link below to set up a Noonlight account and authorize Home Assistant to create alarms on your behalf:

[Connect to Noonlight](https://noonlight.konnected.io/ha/auth)

3. Copy and paste the resulting YAML snippet into your configuration.yaml and restart Home Assistant
* [Connect to Noonlight](https://noonlight.konnected.io/ha/auth)

1. Save the resulting YAML snippet. You will need to enter these details into Home Assistant when adding the integration.

### Configuration

A `noonlight` section must be present in the `configuration.yaml` file to enable the Noonlight Alarm entity.
* `Noonlight ID`: A unique identifier assigned to you when you complete the [initial setup steps](#initial-set-up)

**Note:** This configuration snippet will be generated for you automatically to copy and paste when you follow the [initial setup steps](#initial-set-up)
* `Noonlight Secret`: A secret key associated with your id

```yaml
# Example configuration.yaml entry
noonlight:
id: NOONLIGHT_ID
secret: NOONLIGHT_SECRET
api_endpoint: https://api.noonlight.com/platform/v1
token_endpoint: https://noonlight.konnected.io/ha/token
```
* `Noonlight API Endpoint`: The Noonlight API endpoint used when creating an alarm

* `Token Endpoint`: The OAuth endpoint used to refresh your Noonlight auth token (hosted by [Konnected](https://konnected.io))

* `Location Mode`: Choose between Latitude/Longitude or Address

#### If Latitude/Longitude:

* `Latitude`: Will default to Latitude in Home Assistant

* `Longitude`: Will default to Longitude in Home Assistant

* `id`: A unique identifier assigned to you when you complete the [initial setup steps](#initial-set-up)
* `secret`: A secret key associated with your id
* `api_endpoint`: The Noonlight API endpoint used when creating an alarm
* `token_endpoint`: The OAuth endpoint used to refresh your Noonlight auth token (hosted by [Konnected](https://konnected.io))
#### If Address:

* `Address`: Street address

* `Address 2`: Apartment, suite, etc. (optional)

* `City`: City/town name

* `State`: Two-letter state abbreviation

* `Zip`: Zip code

## Automation Examples

Expand All @@ -63,12 +71,13 @@ automation:
- alias: 'Activate the Noonlight Alarm when the security system is triggered'
trigger:
- platform: state
entity_id: alarm_control_panel.ha_alarm
entity_id:
- alarm_control_panel.ha_alarm
to: 'triggered'
action:
- service: homeassistant.turn_on
entity_id: switch.noonlight_alarm
- service: switch.turn_on
target:
entity_id: switch.noonlight_alarm
```
### Notify Noonlight when a smoke detector detects smoke
Expand All @@ -78,21 +87,22 @@ automation:
- alias: 'Activate the Noonlight Alarm when smoke is detected'
trigger:
- platform: state
entity_id: binary_sensor.smoke_alarm
to: 'on'
entity_id:
- binary_sensor.smoke_alarm
to: 'on'
action:
- service: homeassistant.turn_on
entity_id: switch.noonlight_alarm
- service: noonlight.create_alarm
data:
service: fire
```
## Warnings & Disclaimers
<p class='note warning'>
**Requires an Internet connection!** Home Assistant must have an active internet connection for this to work!
</p>
<b>Requires an Internet connection!</b> Home Assistant must have an active internet connection for this to work!
</p>
**NO GUARANTEE**
### NO GUARANTEE
**This integration is provided as-is without warranties of any kind. Using Noonlight with Home Assistant involves multiple service providers and potential points of failure, including (but not limited to) your internet service provider, 3rd party hosting services such as Amazon Web Services, and the Home Assistant software platform.**
Please read and understand the [Noonlight terms of use](https://noonlight.com/terms), [Konnected terms of use](https://konnected.io/terms) and [Home Assistant terms of Service](https://www.home-assistant.io/tos/), each of which include important limitations of liability and indemnification provisions.
Please read and understand the [Noonlight terms of use](https://noonlight.com/terms), [Konnected terms of use](https://konnected.io/terms) and [Home Assistant terms of Service](https://www.home-assistant.io/tos/), each of which include important limitations of liability and indemnification provisions.
Loading

0 comments on commit 8fc50a5

Please sign in to comment.