### Setup Virtual Environment and Install MkDocs Requirements Source: https://github.com/kizniche/mycodo/blob/master/release-checklist.md Clones the Mycodo repository, sets up its virtual environment, and installs MkDocs requirements. This is a comprehensive setup for documentation deployment. ```bash cd Mycodo && sudo mycodo/scripts/upgrade_commands.sh setup-virtualenv && sudo env/bin/python -m pip install -r docs/requirements.txt ``` -------------------------------- ### Python Example: Get All Actuators Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html This example demonstrates how to retrieve a list of all configured actuators in the Mycobee system. ```python import requests API_URL = "http://localhost:5000/api" def get_all_actuators(): response = requests.get(f"{API_URL}/actuators") response.raise_for_status() return response.json() if __name__ == "__main__": actuators = get_all_actuators() print(actuators) ``` -------------------------------- ### Python Example: Get System Settings Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html This example demonstrates how to fetch the current system-wide settings configured in Mycobee. ```python import requests API_URL = "http://localhost:5000/api" def get_system_settings(): response = requests.get(f"{API_URL}/settings") response.raise_for_status() return response.json() if __name__ == "__main__": settings = get_system_settings() print(settings) ``` -------------------------------- ### Python Example: Get All Devices Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html This example demonstrates how to retrieve a list of all connected devices recognized by the Mycobee system. ```python import requests API_URL = "http://localhost:5000/api" def get_all_devices(): response = requests.get(f"{API_URL}/devices") response.raise_for_status() return response.json() if __name__ == "__main__": devices = get_all_devices() print(devices) ``` -------------------------------- ### Python Example: Get Specific Notification Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html This example demonstrates how to fetch a single notification by its unique ID. ```python import requests API_URL = "http://localhost:5000/api" def get_notification(notification_id): response = requests.get(f"{API_URL}/notifications/{notification_id}") response.raise_for_status() return response.json() if __name__ == "__main__": notification_id = "your_notification_id" # Replace with a valid notification ID notification = get_notification(notification_id) print(notification) ``` -------------------------------- ### Basic Conditional Setup Steps Source: https://github.com/kizniche/mycodo/blob/master/docs/Functions.md A step-by-step guide on how to create a basic Conditional Function in Mycodo. ```APIDOC ## Basic Conditional Setup Steps Follow these steps to create a basic Conditional Function in Mycodo: 1. Navigate to the `Setup -> Function` page. 2. Select "Controller: Conditional" and click `Add`. 3. Under the **Conditions** section, select a condition option and click `Add Condition`. 4. Configure the Condition and click `Save`. 5. Under the **Actions** section, select an action option and click `Add Action`. 6. Configure the Action and click `Save`. 7. Note the unique ID for each Condition and Action. 8. In the `Run Python Code` section, replace the placeholder IDs with your actual Condition and Action IDs (e.g., change `self.condition("asdf1234")` and `self.run_action("qwer5678", message=message)`). 9. Adjust the Python logic as needed. You can add more Conditions or Actions. 10. Click `Save` at the top of the Conditional page. If the Conditional saves without errors, it is ready to be activated. Errors will prevent saving and require debugging of the Python code. ``` -------------------------------- ### Python GET Request Example Source: https://github.com/kizniche/mycodo/blob/master/docs/API.md Example of how to make a GET request to the Mycodo API using Python's requests library. Ensure to replace 'YOUR_API_KEY' with your actual API key. SSL verification is disabled with verify=False. ```python import json import requests ip_address = '127.0.0.1' api_key = 'YOUR_API_KEY' endpoint = 'settings/inputs' url = 'https://{ip}/api/{ep}'.format(ip=ip_address, ep=endpoint) headers = { 'Accept': 'application/vnd.mycodo.v1+json', 'X-API-KEY': api_key } response = requests.get(url, headers=headers, verify=False) print("Response Status: {}".format(response.status_code)) print("Response Headers: {}".format(response.headers)) response_dict = json.loads(response.text) print("Response Dictionary: {}".format(response_dict)) ``` -------------------------------- ### Python Example: Get All Tasks Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html This example demonstrates how to retrieve a list of all scheduled tasks within the Mycobee system. ```python import requests API_URL = "http://localhost:5000/api" def get_all_tasks(): response = requests.get(f"{API_URL}/tasks") response.raise_for_status() return response.json() if __name__ == "__main__": tasks = get_all_tasks() print(tasks) ``` -------------------------------- ### Go Language Basic Syntax Source: https://github.com/kizniche/mycodo/blob/master/mycodo/mycodo_flask/static/manual/mycodo-api.html Provides a basic example of Go language syntax, including keywords, boolean literals, and numbers. ```go package main import "fmt" func main() { var i int = 10 var f float64 = float64(i) var s string = "hello" fmt.Println(s) fmt.Println(f) } ``` -------------------------------- ### Build and Start Mycodo Docker Containers Source: https://github.com/kizniche/mycodo/blob/master/docker/README.md Navigates to the project directory and initiates the Docker build and startup process. ```shell cd Mycodo docker compose up --build -d ```