Skip to content
This repository has been archived by the owner on Jul 23, 2021. It is now read-only.

Commit

Permalink
Update for HA 0.6 breaking changes
Browse files Browse the repository at this point in the history
In HA 0.6 the light component was refactored, introducing a breaking
change to this custom component. This release now drops the hue hub
custom component, and for now the loading of phue.conf is handled with
hue_sensors. Not that you will need to update your config.
  • Loading branch information
robmarkcole committed Dec 18, 2017
1 parent fb2fdcb commit 85f0119
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 42 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
# Hue-sensors-HASS
Component for Hue sensors in Home-assistant.
Component for Hue sensors in Home-assistant v0.6 and above.

Place the custom_components folder in your configuration directory (or add its contents to an existing custom_components folder). Please note you are adding a hub and the sensors in the config instructions below, both are required. Additionally setup assumes have the file phue.conf in your hass config dir, which is created by the hue lights component (different author). Hopefully the sensors and lights can be unified with some more work.
Place the custom_components folder in your configuration directory (or add its contents to an existing custom_components folder). Setup assumes you have the file phue.conf in your hass config dir, which is created by the hue lights component (different author). Note that in some cases phue.conf may be named differently, for example mine was something like phue-12412523.conf so I copied and pasted this file, then renamed to phue.conf.

Hue dimmer remotes can be used for a click and long press (hold button for 2 sec and see LED blink twice).

Add to your config:

```
hue:
sensor:
- platform: hue
- platform: hue_sensor
```

To add the following group to your HA frontend, add the following to groups.yaml (obviously editing to use your sensors):
Expand Down
34 changes: 0 additions & 34 deletions custom_components/hue.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,36 @@
from datetime import timedelta

import requests
import json

from homeassistant.const import (CONF_FILENAME)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle

DOMAIN = 'hue'
DOMAIN = 'hue_sensor'
_LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=1)

PHUE_CONFIG_FILE = 'phue.conf'
REQUIREMENTS = ['hue-sensors==1.2']


def load_conf(filepath):
"""Return the URL for API requests."""
with open(filepath, 'r') as file_path:
data = json.load(file_path)
ip_add = next(data.keys().__iter__())
username = data[ip_add]['username']
url = 'http://' + ip_add + '/api/' + username
return url


def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Hue sensors."""
import hue_sensors as hs
url = hass.data[DOMAIN] + '/sensors'

filename = config.get(CONF_FILENAME, PHUE_CONFIG_FILE)
filepath = hass.config.path(filename)
url = load_conf(filepath) + '/sensors'
data = HueSensorData(url, hs.parse_hue_api_response)
data.update()
sensors = []
Expand Down

0 comments on commit 85f0119

Please sign in to comment.