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

Add childlock support #127

Merged
merged 7 commits into from
Dec 28, 2024
Merged
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ instance/
# Sphinx documentation
docs/_build/

# Ruff cache
.ruff_cache

# Example dev
/examples/example_dev.py

# PyBuilder
.pybuilder/
target/
Expand Down
12 changes: 12 additions & 0 deletions PyTado/interface/api/hops_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,3 +324,15 @@ def set_temp_offset(self, device_id, offset=0, measure="celsius"):
request.payload = {"temperatureOffset": offset}

return self._http.request(request)

def set_child_lock(self, device_id, child_lock):
""" "
Set and toggle the child lock on the device.
"""

request = TadoXRequest()
request.command = f"roomsAndDevices/devices/{device_id}"
request.action = Action.CHANGE
request.payload = {"childLockEnabled": child_lock}

self._http.request(request)
14 changes: 14 additions & 0 deletions PyTado/interface/api/my_tado.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,20 @@ def change_presence(self, presence: Presence) -> None:

self._http.request(request)

def set_child_lock(self, device_id, child_lock) -> None:
"""
Sets the child lock on a device
"""

request = TadoRequest()
request.command = "childLock"
request.action = Action.CHANGE
request.device = device_id
request.domain = Domain.DEVICES
request.payload = {"childLockEnabled": child_lock}

self._http.request(request)

erwindouna marked this conversation as resolved.
Show resolved Hide resolved
def set_auto(self) -> None:
"""
Sets HomeState to AUTO
Expand Down
5 changes: 5 additions & 0 deletions PyTado/interface/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ def getZones(self):
"""Gets zones information. (deprecated)"""
return self.get_zones()

@deprecated("set_child_lock")
def setChildLock(self, device_id, enabled):
"""Set the child lock for a device"""
return self.set_child_lock(device_id, enabled)

wmalgadey marked this conversation as resolved.
Show resolved Hide resolved
@deprecated("get_zone_state")
def getZoneState(self, zone):
"""Gets current state of Zone as a TadoZone object. (deprecated)"""
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ cause discomfort and inconvenience to others.
>>> t = Tado('my@username.com', 'mypassword')
>>> climate = t.get_climate(zone=1)

## Usage
```python
"""Example client for PyTado"""

from PyTado.interface.interface import Tado


def main() -> None:
"""Retrieve all zones, once successfully logged in"""
tado = Tado(username="mail@email.com", password="password") # nosec
zones = tado.get_zones()
print(zones)


if __name__ == "__main__":
main()
```
Note: for developers, you can create an `example_dev.py` file in the root of the project to test your changes. This file will be ignored by the `.gitignore` file.

## Contributing

We are very open to the community's contributions - be it a quick fix of a typo, or a completely new feature!
Expand Down
1 change: 1 addition & 0 deletions examples/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Example(s) for PyTado"""
14 changes: 14 additions & 0 deletions examples/example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Example client for PyTado"""

from PyTado.interface.interface import Tado


def main() -> None:
"""Retrieve all zones, once successfully logged in"""
tado = Tado(username="mail@email.com", password="password") # nosec
zones = tado.get_zones()
print(zones)


if __name__ == "__main__":
main()
erwindouna marked this conversation as resolved.
Show resolved Hide resolved
Loading