Skip to main content

Netatmo's missing true temperature API - set real room temps programmatically

Project description

py-netatmo-truetemp

PyPI version PyPI - Downloads CI Python 3.13+ License: MIT codecov Code style: ruff Type checked: mypy Security: bandit

Netatmo's missing true temperature API - set real room temps programmatically via the undocumented truetemperature endpoint.

⚠️ Disclaimer

Unofficial Project: This is an independent, community-developed library and is not affiliated with, endorsed by, or supported by Netatmo or Legrand.

Why This Exists: The official Netatmo OAuth API does not currently support programmatic temperature adjustments via the truetemperature endpoint. This library fills that gap using reverse-engineered API endpoints.

Archival Policy: This repository will be archived or removed if:

  • Netatmo officially adds temperature control support to their OAuth API
  • Netatmo requests takedown of this project

Use at Your Own Risk: This library relies on undocumented endpoints that may change without notice. Functionality could break if Netatmo modifies their internal API.

Features

  • TrueTemperature API: Set room temperatures via Netatmo's undocumented endpoint
  • Room Management: List and lookup rooms by name (case-insensitive) or ID
  • Smart Updates: Skips API call if temperature already at target (0.1°C tolerance)
  • Automatic Authentication: Cookie-based session management with secure storage (0o600)
  • Auto-Retry: Automatically recovers from authentication failures and API errors
  • Type-Safe: Full type hints with TypedDict definitions for API responses (Python 3.13+)
  • Thread-Safe: Safe to use in multi-threaded applications
  • Simple API: Easy-to-use facade with sensible defaults
  • Extensible: Modular components for advanced customization
  • Production-Ready: Comprehensive error handling and logging

Installation

From PyPI

pip install py-netatmo-truetemp

Or with uv:

uv add py-netatmo-truetemp

From Source

# Clone the repository
git clone https://github.com/py-netatmo-unofficial/py-netatmo-truetemp.git
cd py-netatmo-truetemp

# Create virtual environment and install
uv venv
uv sync

As a Dependency

From PyPI (recommended):

uv add py-netatmo-truetemp

From GitHub (development version):

uv add "py-netatmo-truetemp @ git+https://github.com/py-netatmo-unofficial/py-netatmo-truetemp.git"

Environment Variables

Set these required environment variables:

export NETATMO_USERNAME="your_username"
export NETATMO_PASSWORD="your_password"

Optional:

export NETATMO_HOME_ID="your_home_id"  # Auto-detected if not set

Quick Start

import os
from py_netatmo_truetemp import NetatmoAPI

# Initialize the API (uses cookie-based authentication)
api = NetatmoAPI(
    username=os.environ['NETATMO_USERNAME'],
    password=os.environ['NETATMO_PASSWORD']
)

# Get homes data
homes = api.homesdata()

# Get home status
status = api.homestatus(home_id="your-home-id")

# List rooms with thermostats
rooms = api.list_thermostat_rooms()
# Returns: [{'id': '1234567890', 'name': 'Living Room'}, ...]

# Set room temperature (smart update with 0.1°C tolerance)
api.set_truetemperature(
    room_id="1234567890",
    corrected_temperature=20.5
)

Usage Examples

Command-Line Interface

For a complete CLI application built with this library, see:

The CLI demonstrates:

  • Environment-based configuration
  • Error handling patterns
  • Room lookup by name
  • Formatted terminal output

More Examples

Want to add your project here? Submit a PR or open an issue!

Common Use Cases

Set Temperature by Room Name

from py_netatmo_truetemp import NetatmoAPI
import os

api = NetatmoAPI(
    username=os.environ['NETATMO_USERNAME'],
    password=os.environ['NETATMO_PASSWORD']
)

# Get all rooms
rooms = api.list_thermostat_rooms()
living_room = next(r for r in rooms if r['name'].lower() == 'living room')

# Set temperature
api.set_truetemperature(
    room_id=living_room['id'],
    corrected_temperature=20.5
)

Monitor All Room Temperatures

status = api.homestatus()
for room in status['body']['home']['rooms']:
    temp = room.get('therm_measured_temperature')
    if temp:
        print(f"Room {room['id']}: {temp}°C")

Custom Cookie Location

api = NetatmoAPI(
    username=os.environ['NETATMO_USERNAME'],
    password=os.environ['NETATMO_PASSWORD'],
    cookies_file="/secure/path/cookies.json"
)

How It Works

The library provides a simple NetatmoAPI facade that handles all the complexity:

  • Automatic Authentication: Cookie-based session management with secure storage (0o600 permissions)
  • Smart API Calls: Auto-retry on authentication failures, skips redundant temperature updates
  • Type-Safe Responses: Fully typed API responses for better IDE support and error prevention
  • Thread-Safe Operations: Safe to use in multi-threaded applications with session locking

For advanced usage, you can access individual components directly (see Advanced Usage below).

For complete architectural details and SOLID design principles, see CLAUDE.md.

Advanced Usage

For advanced use cases, you can use individual components:

from py_netatmo_truetemp import (
    CookieStore,
    AuthenticationManager,
    NetatmoApiClient,
    HomeService,
    ThermostatService
)

# Create custom cookie store
cookie_store = CookieStore("/custom/path/cookies.json")

# Inject custom session
import requests
session = requests.Session()
# Configure session as needed...

# Use components directly
auth_manager = AuthenticationManager(
    username="...",
    password="...",
    cookie_store=cookie_store,
    session=session
)

Security

  • Credentials should be provided via environment variables
  • Session cookies are cached with secure permissions (0o600)
  • All API communications use HTTPS
  • No unsafe pickle serialization

Development

Library Development

# Syntax check library modules
python -m py_compile src/py_netatmo_truetemp/*.py

Release Automation

This project uses semantic-release for fully automated releases. All versioning, changelog generation, and publishing happens automatically in CI when you push to the main branch.

Quick workflow:

# 1. Make changes with conventional commits
git commit -m "feat: add new feature"
git commit -m "fix: resolve bug"

# 2. Push to main - automatic release happens
git push origin main

# GitHub Actions automatically:
# - Analyzes conventional commits
# - Determines version bump (major/minor/patch)
# - Updates version in pyproject.toml and __init__.py
# - Generates and updates CHANGELOG.md
# - Creates git tag with verified signature
# - Creates GitHub Release
# - Publishes to PyPI

All commits must follow Conventional Commits format:

  • feat: - New features (minor version bump: 0.1.0 → 0.2.0)
  • fix: - Bug fixes (patch version bump: 0.1.0 → 0.1.1)
  • feat!: or BREAKING CHANGE: - Breaking changes (major version bump: 0.1.0 → 1.0.0)

Pre-commit hooks enforce commit message validation. For complete release workflow documentation, see RELEASE_WORKFLOW_GUIDE.md.

Documentation

Contributing

Contributions are welcome! Please read our Contributing Guide for details on:

  • Code of conduct
  • Development setup
  • Running tests
  • Code style guidelines
  • Conventional commit message format (required)
  • Submitting pull requests

All commits must follow the Conventional Commits format. Pre-commit hooks will validate your commit messages automatically.

See also:

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Uses modern Python 3.13+ features and comprehensive type hints
  • Built with clean architecture patterns for maintainability (see CLAUDE.md)
  • Inspired by the need for programmatic Netatmo thermostat control

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_netatmo_truetemp-0.3.1.tar.gz (82.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_netatmo_truetemp-0.3.1-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

Details for the file py_netatmo_truetemp-0.3.1.tar.gz.

File metadata

  • Download URL: py_netatmo_truetemp-0.3.1.tar.gz
  • Upload date:
  • Size: 82.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_netatmo_truetemp-0.3.1.tar.gz
Algorithm Hash digest
SHA256 2e1fda8f5cce6f8b77246f953170317911bdfc3c7802ca0856326b179edb3ccd
MD5 66a835cc943c4812ee96f8b346460ef3
BLAKE2b-256 17d66edf558ff5389b30157cfaa0b53299057c500c68c46719cd9c58b11077be

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_netatmo_truetemp-0.3.1.tar.gz:

Publisher: publish.yml on py-netatmo-unofficial/py-netatmo-truetemp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_netatmo_truetemp-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for py_netatmo_truetemp-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7debbb741269eebabff92af789ea799f9ed417cf449b7689c3492477988c1cb6
MD5 c2bd20e3029727d4a59be82a771385b2
BLAKE2b-256 8a37803b6f965152730ff0d9636763ada058f2036d3ce61250536c04d979408d

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_netatmo_truetemp-0.3.1-py3-none-any.whl:

Publisher: publish.yml on py-netatmo-unofficial/py-netatmo-truetemp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page