Skip to content
New issue

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

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

Already on GitHub? # to your account

Add Set NTP #84

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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": 1 if enable else 0,
"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