CLI companion for AVM Fritz!Box smart home devices. Collects, stores and monitors data from smart outlets, thermostats and temperature sensors via the AHA HTTP API.
- PHP 8.5+
- SQLite (
ext-pdo_sqlite) - SimpleXML (
ext-simplexml) - A Fritz!Box with smart home devices
git clone https://github.com/teqneers/phritzbox.git
cd phritzbox/app && composer install && cd ..
cp .env .env.localEdit .env.local and set your Fritz!Box credentials and database path:
APP_API_USERNAME=your-username
APP_API_PASSWORD=your-password
APP_API_DOMAIN=http://fritz.box # or https://abcd1234.myfritz.net
DATABASE_URL="sqlite:///%kernel.project_dir%/../data/database.sqlite"Run the initial database migration:
php app/bin/console doctrine:migrations:migrateAll commands are run from the repo root:
php app/bin/console COMMAND [options]| Command | Description |
|---|---|
smart:device:list |
List all available SmartHome devices |
smart:device:stats |
Show statistics of a SmartHome device |
smart:switch:list |
List all known SmartHome outlets |
smart:switch:on <ain> |
Turn on a SmartHome outlet |
smart:switch:off <ain> |
Turn off a SmartHome outlet |
smart:switch:toggle <ain> |
Toggle power state of a SmartHome outlet |
smart:switch:power <ain> |
Read current power consumption [mW] |
smart:switch:energy <ain> |
Read energy delivered over outlet [Wh] |
smart:switch:present <ain> |
Check availability of a SmartHome outlet |
smart:switch:name <ain> |
Get name of a SmartHome outlet |
smart:temperature <ain> |
Read temperature of a SmartHome device [°C] |
smart:src:on <ain> |
Turn on a smart radiator control |
smart:src:off <ain> |
Turn off a smart radiator control |
smart:src:setpoint <ain> |
Read or set target temperature [°C] |
smart:src:comfort <ain> |
Read comfort temperature setpoint [°C] |
smart:src:saving <ain> |
Read saving temperature setpoint [°C] |
smart:template:list |
List all available SmartHome templates |
cron:smart:savestats |
Collect and persist all device data |
Device listing (smart:device:list):
Statistics (smart:device:stats):
The cron:smart:savestats command fetches all device data and stores new readings. Run it regularly via cron:
# collect smart home data twice an hour
*/30 * * * * /path-to-phritzbox/app/bin/console cron:smart:savestatsThe Fritz!Box caches device data. Temperature readings are available for up to 24 hours — if not fetched in time they are lost. Running every 30 minutes is recommended for most current data.
Run tests:
php app/vendor/bin/phpunit --configuration app/phpunit.xml.distCheck code style:
./app/vendor/bin/php-cs-fixer fix --diff --dry-run -v --config app/.php-cs-fixer.dist.phpAuto-fix code style:
./app/vendor/bin/php-cs-fixer fix --config app/.php-cs-fixer.dist.phpLint YAML config:
php app/bin/console lint:yaml app/config --parse-tagsValidate Doctrine mapping:
php app/bin/console doctrine:schema:validate --skip-syncCheck for security vulnerabilities:
cd app && composer auditcd docker && docker-compose upThe PHP container mounts app/ for code, data/ for the database, and var/ for cache and logs.





