Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmohr authored Mar 27, 2018
1 parent 715273d commit d17150f
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,35 @@ It may not contains all functionality which is implemented in the project from K
# Example
The example will load a json file with all data if it exists or connects to device and registers it, storing the json afterwards
```
stored_config = "bluray.json"
device = None
import os.path
if os.path.exists(stored_config):
with open(stored_config, 'r') as content_file:
json_data = content_file.read()
device = SonyDevice.load_from_json(json_data)
else:
host = "10.0.0.102"
device = SonyDevice(host)
device.register("SonyApiLib Python Test")
pin = input("Enter the PIN displayed at your device: ")
device.send_authentication(pin)
data = device.save_to_json()
text_file = open("bluray.json", "w")
text_file.write(data)
text_file.close()
# wake device
is_on = device.get_power_status()
if not is_on:
device.power(True)
# Play media
device.play()
from sonyapilib.device import SonyDevice
if __name__ == "__main__":
stored_config = "bluray.json"
device = None
import os.path
if os.path.exists(stored_config):
with open(stored_config, 'r') as content_file:
json_data = content_file.read()
device = SonyDevice.load_from_json(json_data)
else:
host = "10.0.0.102"
device = SonyDevice(host)
device.register("SonyApiLib Python Test")
pin = input("Enter the PIN displayed at your device: ")
device.send_authentication(pin)
data = device.save_to_json()
text_file = open("bluray.json", "w")
text_file.write(data)
text_file.close()
# wake device
is_on = device.get_power_status()
if not is_on:
device.power(True)
# Play media
device.play()
```

# Compatability List
Expand Down

0 comments on commit d17150f

Please sign in to comment.