Skip to content

Commit 86b7fc4

Browse files
authored
Update python_api.markdown
1 parent 741c0a0 commit 86b7fc4

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

source/developers/python_api.markdown

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ sharing: true
99
footer: true
1010
---
1111

12-
In the package [`homeassistant.remote`](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/remote.py) a Python API on top of the [HTTP API](/developers/api/) can be found.
12+
See the [developer documentation][devdocs] for a full overview of the documentation. The rest of this page will contain examples on how to use it.
13+
14+
[devdocs]: https://dev-docs.home-assistant.io/en/master/api/homeassistant.html#module-homeassistant.remote
1315

14-
Note: This page is not full documentation for this API, but a collection of examples showing its use.
16+
In the package [`homeassistant.remote`](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/remote.py) a Python API on top of the [HTTP API](/developers/api/) can be found.
1517

1618
A simple way to get all current entities is to visit the "Set State" page in the "Developer Tools". For the examples below just choose one from the available entries. Here the sensor `sensor.office_temperature` and the switch `switch.livingroom_pin_2` are used.
1719

@@ -24,17 +26,6 @@ api = remote.API('127.0.0.1', 'password')
2426
print(remote.validate_api(api))
2527
```
2628

27-
Here's another way to use the `homeassistant.remote` package:
28-
29-
```python
30-
import homeassistant.remote as remote
31-
32-
api = remote.API('127.0.0.1', 'password')
33-
hass = remote.HomeAssistant(api)
34-
hass.start()
35-
living_room = hass.states.get('group.living_room')
36-
```
37-
3829
### {% linkable_title Get configuration %}
3930

4031
Get the current configuration of a Home Assistant instance:
@@ -81,7 +72,7 @@ import homeassistant.remote as remote
8172

8273
api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
8374
office_temperature = remote.get_state(api, 'sensor.office_temperature')
84-
print('{} is {} {}.'.format(office_temperature.attributes['friendly_name'],
75+
print('{} is {} {}.'.format(office_temperature.name,
8576
office_temperature.state,
8677
office_temperature.attributes['unit_of_measurement']
8778
)
@@ -101,7 +92,7 @@ import homeassistant.remote as remote
10192

10293
api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
10394
switch_livingroom = remote.get_state(api, 'switch.livingroom_pin_2')
104-
print('{} is {}.'.format(switch_livingroom.attributes['friendly_name'],
95+
print('{} is {}.'.format(switch_livingroom.name,
10596
switch_livingroom.state
10697
)
10798
)
@@ -193,5 +184,3 @@ data = {"title":"Test", "message":"A simple test message from HA."}
193184

194185
remote.call_service(api, domain, 'jabber', data)
195186
```
196-
197-
For more details, please check the source of [homeassistant.remote](https://github.com/home-assistant/home-assistant/blob/master/homeassistant/remote.py).

0 commit comments

Comments
 (0)