Skip to content
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

Add call direction sensor for Obihai #26867

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/obihai/manifest.json
Expand Up @@ -3,7 +3,7 @@
"name": "Obihai",
"documentation": "https://www.home-assistant.io/components/obihai",
"requirements": [
"pyobihai==1.1.0"
"pyobihai==1.1.1"
],
"dependencies": [],
"codeowners": ["@dshokouhi"]
Expand Down
17 changes: 17 additions & 0 deletions homeassistant/components/obihai/sensor.py
Expand Up @@ -46,16 +46,26 @@ def setup_platform(hass, config, add_entities, discovery_info=None):

pyobihai = PyObihai()

login = pyobihai.check_account(host, username, password)
if not login:
_LOGGER.error("Invalid credentials")
return

services = pyobihai.get_state(host, username, password)
dshokouhi marked this conversation as resolved.
Show resolved Hide resolved

line_services = pyobihai.get_line_state(host, username, password)

call_direction = pyobihai.get_call_direction(host, username, password)
dshokouhi marked this conversation as resolved.
Show resolved Hide resolved

for key in services:
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))

for key in line_services:
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))

for key in call_direction:
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))

add_entities(sensors)


Expand Down Expand Up @@ -102,3 +112,10 @@ def update(self):

if self._service_name in services:
self._state = services.get(self._service_name)

call_direction = self._pyobihai.get_call_direction(
self._host, self._username, self._password
)

if self._service_name in call_direction:
self._state = call_direction.get(self._service_name)
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -1346,7 +1346,7 @@ pynx584==0.4
pynzbgetapi==0.2.0

# homeassistant.components.obihai
pyobihai==1.1.0
pyobihai==1.1.1

# homeassistant.components.ombi
pyombi==0.1.5
Expand Down