mirror of
https://codeberg.org/icewind/taspromto.git
synced 2026-06-03 08:34:21 +02:00
flake reorg + clippy
This commit is contained in:
parent
347cfe2054
commit
8687197051
12 changed files with 160 additions and 163 deletions
54
.github/workflows/ci.yaml
vendored
54
.github/workflows/ci.yaml
vendored
|
|
@ -1,34 +1,34 @@
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
name: Continuous integration
|
name: CI
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
matrix:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
check-matrix: ${{ steps.set-matrix.outputs.check-matrix }}
|
||||||
|
cross-matrix: ${{ steps.set-matrix.outputs.cross-matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- uses: cachix/install-nix-action@v20
|
- uses: cachix/install-nix-action@v27
|
||||||
- uses: icewind1991/attic-action@v1
|
- id: set-matrix
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build
|
|
||||||
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: build
|
|
||||||
steps:
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- uses: cachix/install-nix-action@v20
|
|
||||||
- uses: icewind1991/attic-action@v1
|
|
||||||
with:
|
|
||||||
name: ci
|
|
||||||
instance: https://cache.icewind.me
|
|
||||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
|
||||||
- run: nix build .#docker
|
|
||||||
- name: Push image
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
run: |
|
run: |
|
||||||
skopeo copy --dest-creds="${{ secrets.DOCKERHUB_USERNAME }}:${{ secrets.DOCKERHUB_TOKEN }}" "docker-archive:$(nix build .#docker --print-out-paths)" "docker://icewind1991/taspromto"
|
echo "check-matrix={\"check\":$(nix eval --json '.#checks.x86_64-linux' --apply 'builtins.attrNames')}" | tee -a $GITHUB_OUTPUT
|
||||||
|
echo "cross-matrix={\"include\":$(nix eval --json '.#lib.crossMatrix')}" | tee -a $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
checks:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [matrix]
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix: ${{fromJson(needs.matrix.outputs.check-matrix)}}
|
||||||
|
name: ${{ matrix.check }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: cachix/install-nix-action@v26
|
||||||
|
- uses: icewind1991/attic-action@v1
|
||||||
|
with:
|
||||||
|
name: ci
|
||||||
|
instance: https://cache.icewind.me
|
||||||
|
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||||
|
- run: nix build .#checks.x86_64-linux.${{ matrix.check }}
|
||||||
|
|
|
||||||
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1038,6 +1038,7 @@ dependencies = [
|
||||||
"jzon",
|
"jzon",
|
||||||
"pin-utils",
|
"pin-utils",
|
||||||
"rumqttc",
|
"rumqttc",
|
||||||
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"warp",
|
"warp",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ async-stream = "0.3.5"
|
||||||
pin-utils = "0.1.0"
|
pin-utils = "0.1.0"
|
||||||
hostname = "0.4.0"
|
hostname = "0.4.0"
|
||||||
tokio-stream = "0.1.15"
|
tokio-stream = "0.1.15"
|
||||||
|
serde = { version = "1.0.200", features = ["derive"] }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
|
||||||
10
docker.nix
10
docker.nix
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{ dockerTools
|
||||||
dockerTools,
|
, taspromto
|
||||||
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" = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
93
flake.lock
generated
93
flake.lock
generated
|
|
@ -1,30 +1,69 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-utils": {
|
"crane": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1710146030,
|
"lastModified": 1727060013,
|
||||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
"narHash": "sha256-/fC5YlJy4IoAW9GhkJiwyzk0K/gQd9Qi4rRcoweyG9E=",
|
||||||
"owner": "numtide",
|
"owner": "ipetkov",
|
||||||
"repo": "flake-utils",
|
"repo": "crane",
|
||||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
"rev": "6b40cc876c929bfe1e3a24bf538ce3b5622646ba",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "numtide",
|
"owner": "ipetkov",
|
||||||
"repo": "flake-utils",
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"flakelight": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729514458,
|
||||||
|
"narHash": "sha256-e4Yf5Jo9ouojCVxTVugGfOtYk75xuA22/qrRXrxmFwI=",
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "flakelight",
|
||||||
|
"rev": "adffa2b3413adedae6ce5b685ca85c4a0c56f32f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-community",
|
||||||
|
"repo": "flakelight",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mill-scale": {
|
||||||
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
|
"flakelight": [
|
||||||
|
"flakelight"
|
||||||
|
],
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1729438560,
|
||||||
|
"narHash": "sha256-tVsGuad1QIoDJlM8aI3jJD5coG9Xgn2RYr+qgbeOzEU=",
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "mill-scale",
|
||||||
|
"rev": "25737430ec43c29beb2158f1179983824161161a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "icewind1991",
|
||||||
|
"repo": "mill-scale",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1720954236,
|
"lastModified": 1729973466,
|
||||||
"narHash": "sha256-1mEKHp4m9brvfQ0rjCca8P1WHpymK3TOr3v34ydv9bs=",
|
"narHash": "sha256-knnVBGfTCZlQgxY1SgH0vn2OyehH9ykfF8geZgS95bk=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "53e81e790209e41f0c1efa9ff26ff2fd7ab35e27",
|
"rev": "cd3e8833d70618c4eea8df06f95b364b016d4950",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -35,22 +74,30 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flakelight": "flakelight",
|
||||||
|
"mill-scale": "mill-scale",
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"systems": {
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"mill-scale",
|
||||||
|
"flakelight",
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1681028828,
|
"lastModified": 1727058553,
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
"narHash": "sha256-tY/UU3Qk5gP/J0uUM4DZ6wo4arNLGAVqLKBotILykfQ=",
|
||||||
"owner": "nix-systems",
|
"owner": "oxalica",
|
||||||
"repo": "default",
|
"repo": "rust-overlay",
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
"rev": "edc5b0f896170f07bd39ad59d6186fcc7859bbb2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nix-systems",
|
"owner": "oxalica",
|
||||||
"repo": "default",
|
"repo": "rust-overlay",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
54
flake.nix
54
flake.nix
|
|
@ -1,47 +1,31 @@
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "nixpkgs/nixos-24.05";
|
nixpkgs.url = "nixpkgs/nixos-24.05";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flakelight = {
|
||||||
|
url = "github:nix-community/flakelight";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
|
mill-scale = {
|
||||||
|
url = "github:icewind1991/mill-scale";
|
||||||
|
inputs.flakelight.follows = "flakelight";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
outputs = { mill-scale, ... }: mill-scale ./. {
|
||||||
|
packages.tasprompto = import ./package.nix;
|
||||||
|
|
||||||
outputs = {
|
nixosModules = { outputs, ... }: {
|
||||||
self,
|
default =
|
||||||
nixpkgs,
|
{ pkgs
|
||||||
flake-utils,
|
, config
|
||||||
}:
|
, lib
|
||||||
flake-utils.lib.eachDefaultSystem (
|
, ...
|
||||||
system: let
|
|
||||||
overlays = [
|
|
||||||
(import ./overlay.nix)
|
|
||||||
];
|
|
||||||
pkgs = (import nixpkgs) {
|
|
||||||
inherit system overlays;
|
|
||||||
};
|
|
||||||
in rec {
|
|
||||||
packages = rec {
|
|
||||||
taspromto = pkgs.taspromto;
|
|
||||||
docker = pkgs.callPackage ./docker.nix {};
|
|
||||||
default = taspromto;
|
|
||||||
};
|
|
||||||
|
|
||||||
devShell = pkgs.mkShell {
|
|
||||||
nativeBuildInputs = with pkgs; [rustc cargo bacon cargo-edit cargo-outdated clippy cargo-audit];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
)
|
|
||||||
// {
|
|
||||||
overlays.default = import ./overlay.nix;
|
|
||||||
nixosModules.default = {
|
|
||||||
pkgs,
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: {
|
}: {
|
||||||
imports = [./module.nix];
|
imports = [ ./module.nix ];
|
||||||
config = lib.mkIf config.services.taspromto.enable {
|
config = lib.mkIf config.services.taspromto.enable {
|
||||||
nixpkgs.overlays = [self.overlays.default];
|
nixpkgs.overlays = [ outputs.overlays.default ];
|
||||||
services.taspromto.package = lib.mkDefault pkgs.taspromto;
|
services.taspromto.package = lib.mkDefault pkgs.taspromto;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
module.nix
22
module.nix
|
|
@ -1,24 +1,24 @@
|
||||||
{
|
{ config
|
||||||
config,
|
, lib
|
||||||
lib,
|
, pkgs
|
||||||
pkgs,
|
, ...
|
||||||
...
|
|
||||||
}:
|
}:
|
||||||
with lib; let
|
with lib; let
|
||||||
cfg = config.services.taspromto;
|
cfg = config.services.taspromto;
|
||||||
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";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ in {
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
systemd.services."taspromto" = {
|
systemd.services."taspromto" = {
|
||||||
wantedBy = ["multi-user.target"];
|
wantedBy = [ "multi-user.target" ];
|
||||||
environment = {
|
environment = {
|
||||||
PORT = toString cfg.port;
|
PORT = toString cfg.port;
|
||||||
MITEMP_NAMES = concatStringsSep "," (map (k: k + "=" + cfg.mitempNames."${k}") (attrNames cfg.mitempNames));
|
MITEMP_NAMES = concatStringsSep "," (map (k: k + "=" + cfg.mitempNames."${k}") (attrNames cfg.mitempNames));
|
||||||
|
|
@ -73,9 +73,9 @@ in {
|
||||||
RestrictAddressFamilies = "AF_INET AF_INET6";
|
RestrictAddressFamilies = "AF_INET AF_INET6";
|
||||||
RestrictRealtime = true;
|
RestrictRealtime = true;
|
||||||
ProtectProc = "noaccess";
|
ProtectProc = "noaccess";
|
||||||
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
|
||||||
IPAddressDeny = "any";
|
IPAddressDeny = "any";
|
||||||
IPAddressAllow = ["localhost"];
|
IPAddressAllow = [ "localhost" ];
|
||||||
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,12 +1,13 @@
|
||||||
{
|
{ stdenv
|
||||||
stdenv,
|
, rustPlatform
|
||||||
rustPlatform,
|
, lib
|
||||||
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";
|
||||||
|
|
||||||
|
|
@ -15,4 +16,4 @@ in
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
lockFile = ./Cargo.lock;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -237,60 +237,33 @@ impl DeviceState {
|
||||||
if json["POWER"].is_string() && !json["POWER"].is_empty() {
|
if json["POWER"].is_string() && !json["POWER"].is_empty() {
|
||||||
self.state = Some(json["POWER"] == "ON");
|
self.state = Some(json["POWER"] == "ON");
|
||||||
}
|
}
|
||||||
if let Some(power) = json["ENERGY"]["Power"]
|
if let Some(power) = json["ENERGY"]["Power"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_watts = Some(power);
|
self.power_watts = Some(power);
|
||||||
}
|
}
|
||||||
if let Some(yesterday) = json["ENERGY"]["Yesterday"]
|
if let Some(yesterday) = json["ENERGY"]["Yesterday"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_yesterday = Some(yesterday);
|
self.power_yesterday = Some(yesterday);
|
||||||
}
|
}
|
||||||
if let Some(today) = json["ENERGY"]["Today"]
|
if let Some(today) = json["ENERGY"]["Today"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_today = Some(today);
|
self.power_today = Some(today);
|
||||||
}
|
}
|
||||||
if let Some(co2) = json["MHZ19B"]["CarbonDioxide"]
|
if let Some(co2) = json["MHZ19B"]["CarbonDioxide"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
if co2 > 1.0 {
|
if co2 > 1.0 {
|
||||||
self.co2 = Some(co2);
|
self.co2 = Some(co2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(power) = json["OBIS"]["Power"]
|
if let Some(power) = json["OBIS"]["Power"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_watts = Some(power);
|
self.power_watts = Some(power);
|
||||||
}
|
}
|
||||||
if let Some(total) = json["OBIS"]["Total"]
|
if let Some(total) = json["OBIS"]["Total"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_total = Some(total);
|
self.power_total = Some(total);
|
||||||
}
|
}
|
||||||
if let Some(total) = json["OBIS"]["Total_high"]
|
if let Some(total) = json["OBIS"]["Total_high"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_total_high = Some(total);
|
self.power_total_high = Some(total);
|
||||||
}
|
}
|
||||||
if let Some(total) = json["OBIS"]["Total_low"]
|
if let Some(total) = json["OBIS"]["Total_low"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.power_total_low = Some(total);
|
self.power_total_low = Some(total);
|
||||||
}
|
}
|
||||||
if let Some(gas) = json["OBIS"]["Gas_total"]
|
if let Some(gas) = json["OBIS"]["Gas_total"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.gas_total = Some(gas);
|
self.gas_total = Some(gas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -336,16 +309,10 @@ impl Default for MiTempState {
|
||||||
impl MiTempState {
|
impl MiTempState {
|
||||||
pub fn update(&mut self, json: &JsonValue) {
|
pub fn update(&mut self, json: &JsonValue) {
|
||||||
self.last_seen = Instant::now();
|
self.last_seen = Instant::now();
|
||||||
if let Some(temperature) = json["Temperature"]
|
if let Some(temperature) = json["Temperature"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.temperature = temperature;
|
self.temperature = temperature;
|
||||||
}
|
}
|
||||||
if let Some(humidity) = json["Humidity"]
|
if let Some(humidity) = json["Humidity"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.humidity = humidity;
|
self.humidity = humidity;
|
||||||
}
|
}
|
||||||
if let Some(battery) = json["Battery"]
|
if let Some(battery) = json["Battery"]
|
||||||
|
|
@ -354,10 +321,7 @@ impl MiTempState {
|
||||||
{
|
{
|
||||||
self.battery = battery;
|
self.battery = battery;
|
||||||
}
|
}
|
||||||
if let Some(dew_point) = json["DewPoint"]
|
if let Some(dew_point) = json["DewPoint"].as_number().map(f32::from) {
|
||||||
.as_number()
|
|
||||||
.and_then(|num| f32::try_from(num).ok())
|
|
||||||
{
|
|
||||||
self.dew_point = dew_point;
|
self.dew_point = dew_point;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -595,7 +559,6 @@ pub fn format_dsmr_state<W: Write>(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stores the 6 byte address used to identify Bluetooth devices.
|
/// Stores the 6 byte address used to identify Bluetooth devices.
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
#[derive(Copy, Clone, Hash, Eq, PartialEq, Default, Ord, PartialOrd)]
|
#[derive(Copy, Clone, Hash, Eq, PartialEq, Default, Ord, PartialOrd)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct BDAddr {
|
pub struct BDAddr {
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ async fn serve(device_states: Arc<Mutex<DeviceStates>>, config: Config) {
|
||||||
format_mi_temp_state(&mut response, *addr, &mi_temp_names, state).unwrap()
|
format_mi_temp_state(&mut response, *addr, &mi_temp_names, state).unwrap()
|
||||||
}
|
}
|
||||||
for (channel, state) in state.rf_temp() {
|
for (channel, state) in state.rf_temp() {
|
||||||
format_rf_temp_state(&mut response, &channel, &rf_temp_names, state).unwrap()
|
format_rf_temp_state(&mut response, channel, &rf_temp_names, state).unwrap()
|
||||||
}
|
}
|
||||||
response
|
response
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue