Skip to content

Commit

Permalink
Added method for getting dim-level
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik committed Apr 11, 2017
1 parent 116488c commit eb41812
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 3 additions & 2 deletions openikeatradfri/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ def dump_devices():
print("Example commands:")
print("> devices")
print("> light.light_control.lights")
print("> light.light_control.set_brightness(10)")
print("> light.light_control.set_brightness(254)")
print("> light.light_control.set_dimmer(10)")
print("> light.light_control.set_dimmer(254)")
print("> light.light_control.set_xy_color(254)")
print("> lights[1].light_control.set_dimmer(20)")
print("> groups")
print("> moods")
print("> dump_devices()")
Expand Down
3 changes: 2 additions & 1 deletion openikeatradfri/coap_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def api_factory(host, security_code):
"""Generate a request method."""
def request(method, path, data=None, *, parse_json=True):
"""Make a request."""

path = '/'.join(str(v) for v in path)
command_string = 'coaps://{}:5684/{}'.format(host, path)

Expand All @@ -35,7 +36,7 @@ def request(method, path, data=None, *, parse_json=True):
'timeout': 10,
'stderr': subprocess.STDOUT,
}

if data is not None:
kwargs['input'] = json.dumps(data).encode('utf-8')
command.append('-f')
Expand Down
8 changes: 8 additions & 0 deletions openikeatradfri/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ def set_dimmer(self, dimmer, *, index=0):
ATTR_LIGHT_DIMMER: dimmer,
}, index=index)

# Test by Patrik 2017-04-11
def get_dimmer(self):
"""Get dimmer value of a light.
Integer between 0..255
"""
return self.raw[0][ATTR_LIGHT_DIMMER]

def set_hex_color(self, color, *, index=0):
"""Set xy color of the light."""
self.set_values({
Expand Down

0 comments on commit eb41812

Please sign in to comment.