Skip to content

Commit

Permalink
Add Set NTP (#84)
Browse files Browse the repository at this point in the history
* Add set NTP

* chore: convert bool to int

---------

Co-authored-by: Alano Terblanche <[email protected]>
  • Loading branch information
RobertHolstein and Benehiko authored Dec 9, 2024
1 parent 71f206a commit 8cacb47
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/network_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def read_config(props_path: str) -> dict:
# Connect to camera
cam = Camera(ip, un, pw)

# Set NTP
cam.set_ntp(enable=True, interval=1440, port=123, server="time-b.nist.gov")

# Get current network settings
current_settings = cam.get_network_general()
print("Current settings:", current_settings)
Expand Down
21 changes: 21 additions & 0 deletions reolinkapi/mixins/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ def set_wifi(self, ssid: str, password: str) -> Dict:
}}}]
return self._execute_command('SetWifi', body)

def set_ntp(self, enable: bool = True, interval: int = 1440, port: int = 123, server: str = "pool.ntp.org") -> Dict:
"""
Set NTP settings.
:param enable: bool
:param interval: int
:param port: int
:param server: str
:return: Dict
"""
body = [{"cmd": "SetNtp", "action": 0, "param": {
"Ntp": {
"enable": int(enable),
"interval": interval,
"port": port,
"server": server
}}}]
response = self._execute_command('SetNtp', body)
print("Successfully Set NTP Settings")
return response

def get_net_ports(self) -> Dict:
"""
Get network ports
Expand Down

0 comments on commit 8cacb47

Please sign in to comment.