An open API service indexing awesome lists of open source software.

https://github.com/timo-reymann/fritzbox-based-presence

Show who is home based on devices connected to FritzBox that are currently online.
https://github.com/timo-reymann/fritzbox-based-presence

container docker fritzbox go hackfridays home-automation

Last synced: over 1 year ago
JSON representation

Show who is home based on devices connected to FritzBox that are currently online.

Awesome Lists containing this project

README

          

fritzbox-based-presence
===
[![LICENSE](https://img.shields.io/github/license/timo-reymann/fritzbox-based-presence)](https://github.com/timo-reymann/fritzbox-based-presence/blob/main/LICENSE)
[![DockerHub Pulls](https://img.shields.io/docker/pulls/timoreymann/fritzbox-based-presence)](https://hub.docker.com/r/timoreymann/fritzbox-based-presence)
[![Go Report Card](https://goreportcard.com/badge/github.com/timo-reymann/fritzbox-based-presence)](https://goreportcard.com/report/github.com/timo-reymann/fritzbox-based-presence)
[![codecov](https://codecov.io/gh/timo-reymann/fritzbox-based-presence/graph/badge.svg?token=rsQYV5lODS)](https://codecov.io/gh/timo-reymann/fritzbox-based-presence)
[![CircleCI](https://circleci.com/gh/timo-reymann/fritzbox-based-presence.svg?style=shield)](https://app.circleci.com/pipelines/github/timo-reymann/fritzbox-based-presence)
[![GitHub Release](https://img.shields.io/github/v/tag/timo-reymann/fritzbox-based-presence?label=version)](https://github.com/timo-reymann/fritzbox-based-presence/releases)
[![Renovate](https://img.shields.io/badge/renovate-enabled-green?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNjkgMzY5Ij48Y2lyY2xlIGN4PSIxODkuOSIgY3k9IjE5MC4yIiByPSIxODQuNSIgZmlsbD0iI2ZmZTQyZSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTUgLTYpIi8+PHBhdGggZmlsbD0iIzhiYjViNSIgZD0iTTI1MSAyNTZsLTM4LTM4YTE3IDE3IDAgMDEwLTI0bDU2LTU2YzItMiAyLTYgMC03bC0yMC0yMWE1IDUgMCAwMC03IDBsLTEzIDEyLT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bDgtOGM0LTQgNC0xMSAwLTE1eiIvPjxwYXRoIGZpbGw9IiNlYjZlMmQiIGQ9Ik0yNjAgMjMzbC00LTRjLTYtNi0xNy02LTIzIDAtNyA3LTcgMTcgMCAyNGw0IDRjLTQtNS00LTExIDAtMTZsOC04YzQtNCAxMS00IDE1IDB6Ii8+PHBhdGggZmlsbD0iIzEzYWNiZCIgZD0iTTEzNCAyNDhjLTQgMC04LTItMTEtNWwtMjMtMjNhMTYgMTYgMCAwMTAtMjNMMjAxIDk2YTE2IDE2IDAgMDEyMiAwbDI0IDI0YzYgNiA2IDE2IDAgMjJMMTQ2IDI0M2MtMyAzLTcgNS0xMiA1em03OC0xNDdsLTQgMi0xMDEgMTAxYTYgNiAwIDAwMCA5bDIzIDIzYTYgNiAwIDAwOSAwbDEwMS0xMDFhNiA2IDAgMDAwLTlsLTI0LTIzLTQtMnoiLz48cGF0aCBmaWxsPSIjYmY0NDA0IiBkPSJNMjg0IDMwNGMtNCAwLTgtMS0xMS00bC00Ny00N2MtNi02LTYtMTYgMC0yMmw4LThjNi02IDE2LTYgMjIgMGw0NyA0NmM2IDcgNiAxNyAwIDIzbC04IDhjLTMgMy03IDQtMTEgNHptLTM5LTc2Yy0xIDAtMyAwLTQgMmwtOCA3Yy0yIDMtMiA3IDAgOWw0NyA0N2E2IDYgMCAwMDkgMGw3LThjMy0yIDMtNiAwLTlsLTQ2LTQ2Yy0yLTItMy0yLTUtMnoiLz48L3N2Zz4=)](https://renovatebot.com)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=timo-reymann_fritzbox-based-presence&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=timo-reymann_fritzbox-based-presence)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=timo-reymann_fritzbox-based-presence&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=timo-reymann_fritzbox-based-presence)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=timo-reymann_fritzbox-based-presence&metric=bugs)](https://sonarcloud.io/summary/new_code?id=timo-reymann_fritzbox-based-presence)





Show who is home based on devices connected to FritzBox that are currently online.

## Features

- show who is currently connected to your home network and online
- single go binary
- docker images for all popular platforms
- Telegram bot support

## Requirements

- Fritz!OS 7.57+ (they changed the data format inbetween)

## Installation

- Download [latest release](https://github.com/timo-reymann/fritzbox-based-presence/releases/latest) and spin up the
binary as systemd service, screen etc.
- OR use the prebuilt docker images (see [Usage](#usage) for an full example)

## Usage

### Fritz!Box User

- Create a dedicated Fritz!Box user
- Navigate to [fritz.box](http://fritz.box) in your browser
- Login
- Create a user under `System > Fritz!Box Users`
![Create user](https://raw.githubusercontent.com/timo-reymann/fritzbox-based-presence/main/.github/images/create-user.png)
- Create a docker-compose file with the following contents:

```yaml
version: "3.5"
services:
fritzbox-presence:
image: timoreymann/fritzbox-based-presence:latest # check for version to use if you would like to pin it
restart: always
ports:
- :8090
environment:
FB_PRESENCE__SHOW_GUESTS: "true"
FB_PRESENCE__FRITZ_BOX_URL: http://192.168.178.1
FB_PRESENCE__FRITZ_BOX_USERNAME:
FB_PRESENCE__FRITZ_BOX_PASSWORD:
FB_PRESENCE__DEVICE_NAME_MAPPING: Name=device1,device2|Name2=device1
FB_PRESENCE__AUTH_PASSWORD: <>
```

### Start service with docker-compose

- Run `docker compose up -d`
- Open your browser at `:`
- Optionally add to your DynDNS, cloudflared tunnel etc. to make it available

> For all available options just run the binary without any required variable set to get an overview, or if you are
> familiar with go code check the [config sources](./pkg/config/main.go)

### Setup telegram bot

If you want to use the telegram functionality, follow this guide.

1. Create your bot with [@BotFather](https://telegram.me/botfather)
1. `/newbot`
2. Enter the desired name to be displayed in chats e.g. `My Home Stalker`
3. Give it a username ending in `bot` e.g. `my_home_stalker_bot
4. Copy the token you get, you will need it later
2. Set up some sugar
1. `/setcommands`
2. `@your_bot_name`
3.
```text
start - Establish SkyNet
home - See who is home
online - See who is currently connected to your home
```
5. `/setuserpic`
6. Send the bot the profile picture you want to see
3. Configure the service
1. Set the env var `FB_PRESENCE__TELEGRAM_BOT_TOKEN` to the token you received
2. Set `FB_PRESENCE__TELEGRAM_BOT_ALLOWED_USERS` to a comma seperated list of users that should be allowed to use
the bot

### Setup discord bot

1. Create the application & bot for discord
1. Make sure you’re logged on to the Discord website.
2. Navigate to the [application page](https://discord.com/developers/applications)
3. Click on the “New Application” button.
4. Give the application a name and click “Create”.
5. Navigate to the “Bot” tab to configure it.
6. Make sure that Public Bot is unticked.
7. You should also make sure that Require OAuth2 Code Grant is unchecked
8. Copy the token using the “Copy” button.
2. Configure the service
1. Set the env var `FB_PRESENCE__DISCORD_BOT_TOKEN` to the token you received
2. Set `FB_PRESENCE__DISCROD_BOT_ALLOWED_USERS` to a comma seperated list of users that should be allowed to use
the bot

## Motivation

Living together can be hard. And knowing who will be home is a nice thing to have.

Manual maintenance with signs or something analog or the good old message is boring, so lets use something a bit more
reliable.

## Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the configuration
- Submitting a fix
- Proposing new features
- Becoming a maintainer

To get started please read the [Contribution Guidelines](./CONTRIBUTING.md).

## Development

### Requirements

- [GNU make](https://www.gnu.org/software/make/)
- [Docker](https://docs.docker.com/get-docker/)
- [pre-commit](https://pre-commit.com/)
- Go 1.21

### Test

```shell
make test
```

### Build

```shell
make build
```

### Alternatives

- writing messages
- analog signs
- talking to other people (scary)