Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce to set settings with an example #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ print(deviceMeter['total']) #print total information
```
other examples are available as well [examples/meter.py](examples/meter.py)


#### settings
a simple working example for the Shelly 1 to set settings.
```python
import ShellyPy

device = ShellyPy.Shelly("192.168.68.121")
device.setsettings(max_power=2500, led_status_disable=True)
```



## devices
#### supported
- Shelly1
Expand Down
36 changes: 36 additions & 0 deletions ShellyPy/gen1.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,32 @@ def settings(self, subpage = None):

return self.post(page)

def setsettings(self, *args, **kwargs):
"""
@brief Set device settings. Only max_power

@param max_power Power threshold above which an overpower condition will be triggered. Any value >2500 will be set to device maximum 2500
@param led_status_disable Disable LED status indication
"""

values = {}
max_power = kwargs.get("max_power", None)
led_status_disable = kwargs.get("led_status_disable", None)

if max_power is not None:
if max_power > 2500:
values["max_power"] = 2500
else:
values["max_power"] = max_power

if led_status_disable is not None:
if led_status_disable:
values["led_status_disable"] = True
else:
values["led_status_disable"] = False

return self.post("settings/", values)

def meter(self, index):
"""
@brief Get meter information from a relay at the given index
Expand All @@ -117,6 +143,16 @@ def meter(self, index):

return self.post("meter/{}".format(index))

def temperatur(self, index):
"""
@brief PlugS only internal device temperature in °C

@param index index of the relay
@return returns the temperatur
"""

return self.post("temperature/{}".format(index))

def relay(self, index, *args, **kwargs):
"""
@brief Interacts with a relay at the given index
Expand Down