diff --git a/atom.xml b/atom.xml index d40fb55026..01d831e3c3 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@
True
, the Owntracks users who are in waypoint_whitelist
can export waypoints from the device and Home Assistant will import them as zone definitions. Defaults to True
.username
portion of the Base Topic Name, (e.g. owntracks/username/iPhone). Defaults to all users who are connected to Home Assistant via Owntracks.libsodium
library to be present.A full sample configuration for the owntracks
platform is shown below:
pip3 install websocket-client
must be executed)pip3 install websocket-client
must be executed)pip3 install websocket-client
must be executed, turn on doesn’t work, turn off works fine)Currently tested but not working models:
diff --git a/developers/python_api/index.html b/developers/python_api/index.html index 2dc5e59b03..d937be1b04 100644 --- a/developers/python_api/index.html +++ b/developers/python_api/index.html @@ -94,7 +94,7 @@The output from this is similar to the output you’d find via the frontend, using the DevTools console.
+The output from this is similar to the output you’d find via the frontend, using the Developer Tools.
import homeassistant.remote as remote
api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
@@ -120,12 +120,11 @@
import homeassistant.remote as remote
api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
-office_temperature = remote.get_state(api, 'sensor.office_temperature')
-print('{} is {} {}.'.format(office_temperature.name,
- office_temperature.state,
- office_temperature.attributes['unit_of_measurement']
- )
- )
+office_temp = remote.get_state(api, 'sensor.office_temperature')
+print('{} is {} {}.'.format(
+ office_temp.name, office_temp.state,
+ office_temp.attributes['unit_of_measurement'])
+)
This outputs the details which are stored for this entity, ie:
@@ -137,10 +136,9 @@
api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
switch_livingroom = remote.get_state(api, 'switch.livingroom_pin_2')
-print('{} is {}.'.format(switch_livingroom.name,
- switch_livingroom.state
- )
- )
+print('{} is {}.'.format(
+ switch_livingroom.name, switch_livingroom.state)
+)
This section contains a couple of sample scripts.
+If you want to see, export or list all sensor states then an easy way to do it, is to get all entities and filter for the one you are looking for.
+import homeassistant.remote as remote
+
+api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
+entities = remote.get_states(api)
+for entity in entities:
+ if entity.entity_id.startswith('sensor'):
+ data = remote.get_state(api, entity.entity_id)
+ print('{}: {}'.format(data.attributes['friendly_name'], data.state))
+
+last_changed
and last_updated
The documentation about the State Objects describes the
+last_changed
and last_updated
fields. This example shows how it works in practice.
import time
+
+from prettytable import PrettyTable
+import homeassistant.remote as remote
+
+api = remote.API('127.0.0.1', 'YOUR_PASSWORD')
+
+ACTIONS = {
+ 'Create sensor': [21, 'Test'],
+ 'No new sensor value': [21, 'Test'],
+ 'New sensor value': [22, 'Test'],
+ 'Update attribute': [22, 'Test1'],
+}
+
+output = PrettyTable(['Action', 'Last changed', 'Last updated'])
+
+for key, value in ACTIONS.items():
+ remote.set_state(api, 'sensor.test', new_state=value[0],
+ attributes={'friendly_name': value[1]})
+ data = remote.get_state(api, 'sensor.test')
+ output.add_row([key, data.last_changed, data.last_updated])
+ time.sleep(2)
+
+print(output)
+
+