mirror of
https://codeberg.org/icewind/taspromto.git
synced 2026-06-03 08:34:21 +02:00
fmt
This commit is contained in:
parent
0938b09f74
commit
5c87b874e4
6 changed files with 71 additions and 66 deletions
31
README.md
31
README.md
|
|
@ -4,9 +4,8 @@ Publish tasmota (and other) state into prometheus
|
||||||
|
|
||||||
## What
|
## What
|
||||||
|
|
||||||
Taspromto listens to messages published by tasmota (and other) devices to MQTT and presents the data in a prometheus
|
Taspromto listens to messages published by tasmota (and other) devices to MQTT
|
||||||
compatible
|
and presents the data in a prometheus compatible format.
|
||||||
format.
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
@ -26,17 +25,20 @@ The following tasmota data is supported
|
||||||
- ON/OFF state
|
- ON/OFF state
|
||||||
- Current and total power consumption for power meter devices
|
- Current and total power consumption for power meter devices
|
||||||
- CO² levels for [MH-Z19 sensors](https://tasmota.github.io/docs/MH-Z19B/)
|
- CO² levels for [MH-Z19 sensors](https://tasmota.github.io/docs/MH-Z19B/)
|
||||||
- Power and Gas levels from [supported P1 smart meters](https://tasmota.github.io/docs/Smart-Meter-Interface/)
|
- Power and Gas levels from
|
||||||
|
[supported P1 smart meters](https://tasmota.github.io/docs/Smart-Meter-Interface/)
|
||||||
- Particle concentration from PMS5003 sensors
|
- Particle concentration from PMS5003 sensors
|
||||||
- 433Mhz temperature sensor readings from [`rtl_433`](https://github.com/merbanan/rtl_433)
|
- 433Mhz temperature sensor readings from
|
||||||
|
[`rtl_433`](https://github.com/merbanan/rtl_433)
|
||||||
|
|
||||||
## Xiaomi MI Temperature and Humidity Sensors
|
## Xiaomi MI Temperature and Humidity Sensors
|
||||||
|
|
||||||
Tasmota can expose temperature and humidity data from Xiaomi sensors, to expose these sensors you need to configure the
|
Tasmota can expose temperature and humidity data from Xiaomi sensors, to expose
|
||||||
names for the sensors.
|
these sensors you need to configure the names for the sensors.
|
||||||
|
|
||||||
This is done by setting the `MITEMP_NAMES` environment variable to comma separated key value pairs of the last 6 digits
|
This is done by setting the `MITEMP_NAMES` environment variable to comma
|
||||||
of the MAC address of the sensors and the desired name.
|
separated key value pairs of the last 6 digits of the MAC address of the sensors
|
||||||
|
and the desired name.
|
||||||
|
|
||||||
```dotenv
|
```dotenv
|
||||||
MITEMP_NAMES="351234=Bedroom,352468=Living Room"
|
MITEMP_NAMES="351234=Bedroom,352468=Living Room"
|
||||||
|
|
@ -44,12 +46,13 @@ MITEMP_NAMES="351234=Bedroom,352468=Living Room"
|
||||||
|
|
||||||
## 433Mhz temperature sensors
|
## 433Mhz temperature sensors
|
||||||
|
|
||||||
Taspromto can parse data 433Mhz temperature sensors send to MQTT by [`rtl_433`](https://github.com/merbanan/rtl_433).
|
Taspromto can parse data 433Mhz temperature sensors send to MQTT by
|
||||||
|
[`rtl_433`](https://github.com/merbanan/rtl_433).
|
||||||
|
|
||||||
rtl_433 needs to be configured to send it's output to the `rtl_433[/model]` topic, then sensors can be configured by
|
rtl_433 needs to be configured to send it's output to the `rtl_433[/model]`
|
||||||
setting
|
topic, then sensors can be configured by setting the `RF_TEMP_NAMES` environment
|
||||||
the `RF_TEMP_NAMES` environment variable to comma seperated key value pairs. Where the key is the sensor model, id and
|
variable to comma seperated key value pairs. Where the key is the sensor model,
|
||||||
channel.
|
id and channel.
|
||||||
|
|
||||||
```dotenv
|
```dotenv
|
||||||
RF_TEMP_NAMES="Bresser-3CH:73:1=Front Yard,Bresser-3CH:73:2=Attic"
|
RF_TEMP_NAMES="Bresser-3CH:73:1=Front Yard,Bresser-3CH:73:2=Attic"
|
||||||
|
|
|
||||||
10
docker.nix
10
docker.nix
|
|
@ -1,6 +1,6 @@
|
||||||
{ dockerTools
|
{
|
||||||
, taspromto
|
dockerTools,
|
||||||
,
|
taspromto,
|
||||||
}:
|
}:
|
||||||
dockerTools.buildLayeredImage {
|
dockerTools.buildLayeredImage {
|
||||||
name = "icewind1991/taspromto";
|
name = "icewind1991/taspromto";
|
||||||
|
|
@ -11,9 +11,9 @@ dockerTools.buildLayeredImage {
|
||||||
dockerTools.caCertificates
|
dockerTools.caCertificates
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
Cmd = [ "taspromto" ];
|
Cmd = ["taspromto"];
|
||||||
ExposedPorts = {
|
ExposedPorts = {
|
||||||
"80/tcp" = { };
|
"80/tcp" = {};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
19
flake.nix
19
flake.nix
|
|
@ -10,19 +10,20 @@
|
||||||
inputs.flakelight.follows = "flakelight";
|
inputs.flakelight.follows = "flakelight";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = { mill-scale, ... }: mill-scale ./. {
|
outputs = {mill-scale, ...}:
|
||||||
|
mill-scale ./. {
|
||||||
packages.tasprompto = import ./package.nix;
|
packages.tasprompto = import ./package.nix;
|
||||||
|
|
||||||
nixosModules = { outputs, ... }: {
|
nixosModules = {outputs, ...}: {
|
||||||
default =
|
default = {
|
||||||
{ pkgs
|
pkgs,
|
||||||
, config
|
config,
|
||||||
, lib
|
lib,
|
||||||
, ...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [ ./module.nix ];
|
imports = [./module.nix];
|
||||||
config = lib.mkIf config.services.taspromto.enable {
|
config = lib.mkIf config.services.taspromto.enable {
|
||||||
nixpkgs.overlays = [ outputs.overlays.default ];
|
nixpkgs.overlays = [outputs.overlays.default];
|
||||||
services.taspromto.package = lib.mkDefault pkgs.taspromto;
|
services.taspromto.package = lib.mkDefault pkgs.taspromto;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
32
module.nix
32
module.nix
|
|
@ -1,11 +1,12 @@
|
||||||
{ config
|
{
|
||||||
, lib
|
config,
|
||||||
, pkgs
|
lib,
|
||||||
, ...
|
pkgs,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.taspromto;
|
cfg = config.services.taspromto;
|
||||||
format = pkgs.formats.toml { };
|
format = pkgs.formats.toml {};
|
||||||
configFile = format.generate "taspromto-config.toml" {
|
configFile = format.generate "taspromto-config.toml" {
|
||||||
listen = {
|
listen = {
|
||||||
inherit (cfg) port;
|
inherit (cfg) port;
|
||||||
|
|
@ -14,29 +15,30 @@ with lib; let
|
||||||
mitemp = cfg.mitempNames;
|
mitemp = cfg.mitempNames;
|
||||||
rftemp = cfg.rfChannelNames;
|
rftemp = cfg.rfChannelNames;
|
||||||
};
|
};
|
||||||
mqtt = {
|
mqtt =
|
||||||
|
{
|
||||||
inherit (cfg.mqtt) hostname port;
|
inherit (cfg.mqtt) hostname port;
|
||||||
} // (
|
}
|
||||||
|
// (
|
||||||
optionalAttrs (cfg.mqtt.passwordFile != null) {
|
optionalAttrs (cfg.mqtt.passwordFile != null) {
|
||||||
inherit (cfg.mqtt) username;
|
inherit (cfg.mqtt) username;
|
||||||
password_file = "$CREDENTIALS_DIRECTORY/mqtt_password";
|
password_file = "$CREDENTIALS_DIRECTORY/mqtt_password";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
in
|
in {
|
||||||
{
|
|
||||||
options.services.taspromto = {
|
options.services.taspromto = {
|
||||||
enable = mkEnableOption "taspromto";
|
enable = mkEnableOption "taspromto";
|
||||||
|
|
||||||
mitempNames = mkOption {
|
mitempNames = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = { };
|
default = {};
|
||||||
description = "Names for mitemp sensors";
|
description = "Names for mitemp sensors";
|
||||||
};
|
};
|
||||||
|
|
||||||
rfChannelNames = mkOption {
|
rfChannelNames = mkOption {
|
||||||
type = types.attrs;
|
type = types.attrs;
|
||||||
default = { };
|
default = {};
|
||||||
description = "Names for 433mhz temperature sensors";
|
description = "Names for 433mhz temperature sensors";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -81,7 +83,7 @@ in
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services."taspromto" = {
|
systemd.services."taspromto" = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = ["multi-user.target"];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
LoadCredential = optional (cfg.mqtt.passwordFile != null) [
|
LoadCredential = optional (cfg.mqtt.passwordFile != null) [
|
||||||
|
|
@ -108,13 +110,13 @@ in
|
||||||
ProtectHostname = true;
|
ProtectHostname = true;
|
||||||
LockPersonality = true;
|
LockPersonality = true;
|
||||||
ProtectKernelTunables = true;
|
ProtectKernelTunables = true;
|
||||||
RestrictAddressFamilies = [ "AF_INET" "AF_INET6" "AF_UNIX" ];
|
RestrictAddressFamilies = ["AF_INET" "AF_INET6" "AF_UNIX"];
|
||||||
RuntimeDirectory = "taspromto";
|
RuntimeDirectory = "taspromto";
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
ProtectProc = "noaccess";
|
ProtectProc = "noaccess";
|
||||||
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
|
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||||
IPAddressDeny = "any";
|
IPAddressDeny = "any";
|
||||||
IPAddressAllow = [ "localhost" cfg.mqtt.hostname ];
|
IPAddressAllow = ["localhost" cfg.mqtt.hostname];
|
||||||
PrivateUsers = true;
|
PrivateUsers = true;
|
||||||
ProcSubset = "pid";
|
ProcSubset = "pid";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
final: prev: {
|
final: prev: {
|
||||||
taspromto = final.callPackage ./package.nix { };
|
taspromto = final.callPackage ./package.nix {};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
17
package.nix
17
package.nix
|
|
@ -1,13 +1,12 @@
|
||||||
{ stdenv
|
{
|
||||||
, rustPlatform
|
stdenv,
|
||||||
, lib
|
rustPlatform,
|
||||||
,
|
lib,
|
||||||
}:
|
}: let
|
||||||
let
|
|
||||||
inherit (lib.sources) sourceByRegex;
|
inherit (lib.sources) sourceByRegex;
|
||||||
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
|
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "taspromto";
|
pname = "taspromto";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
|
|
@ -16,4 +15,4 @@ rustPlatform.buildRustPackage rec {
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue