Skip to content
This repository has been archived by the owner on Aug 1, 2019. It is now read-only.

Commit

Permalink
Moved logic to external python package
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus committed Sep 8, 2018
1 parent 8298418 commit 5524953
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 101 deletions.
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ about: Create a report to help us improve

---

**Version of the cusom_component**
<!-- If you are not using the nevest version, download and try that before opening a issue-->
**Version of the custom_component**
<!-- If you are not using the newest version, download and try that before opening a issue-->

**Describe the bug**
A clear and concise description of what the bug is.

**log**
<!-- issues without degbug logging will be closed-->
<!-- issues without debug logging will be closed-->
```
Add your logs here.
```
5 changes: 0 additions & 5 deletions .github/release-drafter.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ repository:
allow_rebase_merge: false
labels:
- name: "Feature Request"
color: fbca04
color: 'fbca04'
- name: "Bug"
color: d73a4a
color: 'd73a4a'
- name: "Wont Fix"
color: ffffff
color: 'ffffff'
- name: "Enhancement"
color: a2eeef
color: 'a2eeef'
- name: "Documentation"
color: 008672
color: '008672'
- name: "Stale"
color: 930191
color: '930191'
65 changes: 65 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
language: python
stages:
- linting
- load
- publish

jobs:
include:
#Linting
- stage: linting
install: pip install pycodestyle
name: "Linting with pycodestyle"
python: "3.6"
script: find . -name \*.py -exec pycodestyle {} +
- stage: linting
install: pip install pydocstyle
name: "Linting with pydocstyle"
python: "3.6"
script: find . -name \*.py -exec pydocstyle {} +
- stage: linting
install: pip install pylint
name: "Linting with pylint"
python: "3.6"
script: find . -name \*.py -exec pylint --disable=F0401,W0613 {} +
- stage: linting
install: pip install pyflakes
name: "Linting with pyflakes"
python: "3.6"
script: find . -name \*.py -exec pyflakes {} +
- stage: linting
install: pip install flake8
name: "Linting with flake8"
python: "3.6"
script: find . -name \*.py -exec flake8 {} +

# Load component with Home Assistant
- stage: load
name: "Load component/platform in Home Assistant"
install: pip install homeassistant
python: "3.6"
script:
- hass -c . --daemon
- sleep 60
- cat ./home-assistant.log
- if grep -q 'ERROR' ./home-assistant.log; then echo "There was an error starting Home Assistant"; exit 1; fi

# Deploy to Github if all tests pass and change was done on master.
# git commit -m 'message'
# git push
# git tag x.x.x
# git push origin x.x.x
- stage: deploy
name: "Deploy to GitHub"
script: skip
deploy: &releases
provider: releases
overwrite: true
skip_cleanup: true
target_commitish: $TRAVIS_COMMIT
tag_name: $TRAVIS_TAG
name: $TRAVIS_TAG
body: $TRAVIS_COMMIT_MESSAGE
api_key: $GHAPI
on:
tags: true
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Custom_component for `hassbian-config`.
# Custom_component for `hassbian-config`

A custom component which allows you to controll some hassbian-config functions from Home Assistant.

To get started put the contents of`/custom_components/hassbian_config/`
here: `<config directory>/custom_components/hassbian_config/`
To get started put `/custom_components/hassbian_config.py`
here: `<config directory>/custom_components/hassbian_config.py`

**Example configuration.yaml:**

```yaml
hassbian_config:
```
For more example see the [services.yaml](https://github.com/custom-components/hassbian-config/blob/master/custom_components/hassbian_config/services.yaml) file.
10 changes: 10 additions & 0 deletions configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## this is used by travis
homeassistant:
name: Home Assistant
latitude: 0
longitude: 0
elevation: 0
unit_system: metric
time_zone: Europe/London

hassbian_config:
62 changes: 62 additions & 0 deletions custom_components/hassbian_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""
A component which allows you to controll some hassbian-config functions.
For more details about this component, please refer to the documentation at
https://github.com/ludeeus/hassbian_config
"""
import logging

__version__ = '2.0.0'

REQUIREMENTS = ['pyhassbian==0.0.3']

DOMAIN = 'hassbian_config'

_LOGGER = logging.getLogger(__name__)

def setup(hass, config):
"""Setup the component."""
import pyhassbian

def install_suite_service(call):
"""Define install service."""
suite = call.data.get('suite')
dev = call.data.get('dev')
beta = call.data.get('beta')
version = call.data.get('version')
all_suites = pyhassbian.get_suites()
if suite in all_suites:
_LOGGER.info('The suite %s is now beeing installed.', suite)
pyhassbian.manage_suite('install', suite, dev, beta, version)
_LOGGER.info('The suite %s has been installed.', suite)
else:
_LOGGER.error('The suite %s does not exist.', suite)

def upgrade_suite_service(call):
"""Define update service."""
suite = call.data.get('suite')
dev = call.data.get('dev')
beta = call.data.get('beta')
version = call.data.get('version')
if suite in pyhassbian.get_suites():
_LOGGER.info('The suite %s is now beeing upgraded.', suite)
pyhassbian.manage_suite('upgrade', suite, dev, beta, version)
_LOGGER.info('The suite %s has been upgraded.', suite)
else:
_LOGGER.error('The suite %s does not exist.', suite)

def upgrade_os_service(call):
"""Define update base OS service."""
_LOGGER.info('Upgrade of the base OS are starting.')
pyhassbian.os_upgrade()
_LOGGER.info('Upgrade of the base OS are done.')


if pyhassbian.is_installed():
_LOGGER.info('hassbian-config found, registering services.')
hass.services.register(DOMAIN, 'install_suite', install_suite_service)
hass.services.register(DOMAIN, 'upgrade_suite', upgrade_suite_service)
hass.services.register(DOMAIN, 'upgrade_os', upgrade_os_service)
else:
_LOGGER.error('hassbian-config not found...')
return True
61 changes: 0 additions & 61 deletions custom_components/hassbian_config/__init__.py

This file was deleted.

21 changes: 0 additions & 21 deletions custom_components/hassbian_config/services.yaml

This file was deleted.

0 comments on commit 5524953

Please sign in to comment.