mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Add call direction sensor for Obihai (#26867)
* Add call direction sensor for obihai * Check user credentials * Review comments * Fix return
This commit is contained in:
parent
d1adb28c6b
commit
36f604f79d
@ -3,7 +3,7 @@
|
|||||||
"name": "Obihai",
|
"name": "Obihai",
|
||||||
"documentation": "https://www.home-assistant.io/components/obihai",
|
"documentation": "https://www.home-assistant.io/components/obihai",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyobihai==1.1.0"
|
"pyobihai==1.1.1"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": ["@dshokouhi"]
|
"codeowners": ["@dshokouhi"]
|
||||||
|
@ -46,16 +46,26 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||||||
|
|
||||||
pyobihai = PyObihai()
|
pyobihai = PyObihai()
|
||||||
|
|
||||||
|
login = pyobihai.check_account(host, username, password)
|
||||||
|
if not login:
|
||||||
|
_LOGGER.error("Invalid credentials")
|
||||||
|
return
|
||||||
|
|
||||||
services = pyobihai.get_state(host, username, password)
|
services = pyobihai.get_state(host, username, password)
|
||||||
|
|
||||||
line_services = pyobihai.get_line_state(host, username, password)
|
line_services = pyobihai.get_line_state(host, username, password)
|
||||||
|
|
||||||
|
call_direction = pyobihai.get_call_direction(host, username, password)
|
||||||
|
|
||||||
for key in services:
|
for key in services:
|
||||||
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))
|
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))
|
||||||
|
|
||||||
for key in line_services:
|
for key in line_services:
|
||||||
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))
|
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))
|
||||||
|
|
||||||
|
for key in call_direction:
|
||||||
|
sensors.append(ObihaiServiceSensors(pyobihai, host, username, password, key))
|
||||||
|
|
||||||
add_entities(sensors)
|
add_entities(sensors)
|
||||||
|
|
||||||
|
|
||||||
@ -102,3 +112,10 @@ class ObihaiServiceSensors(Entity):
|
|||||||
|
|
||||||
if self._service_name in services:
|
if self._service_name in services:
|
||||||
self._state = services.get(self._service_name)
|
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)
|
||||||
|
@ -1346,7 +1346,7 @@ pynx584==0.4
|
|||||||
pynzbgetapi==0.2.0
|
pynzbgetapi==0.2.0
|
||||||
|
|
||||||
# homeassistant.components.obihai
|
# homeassistant.components.obihai
|
||||||
pyobihai==1.1.0
|
pyobihai==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.ombi
|
# homeassistant.components.ombi
|
||||||
pyombi==0.1.5
|
pyombi==0.1.5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user