• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bcpearce / hass-motion-detection-addon / 21126887229

19 Jan 2026 05:54AM UTC coverage: 17.99% (-32.0%) from 49.971%
21126887229

Pull #26

github

web-flow
Merge c98d1d60e into 0206cb867
Pull Request #26: Additional test coverage

292 of 1865 branches covered (15.66%)

Branch coverage included in aggregate %.

8 of 22 new or added lines in 3 files covered. (36.36%)

827 existing lines in 29 files now uncovered.

347 of 1687 relevant lines covered (20.57%)

28.54 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/include/Callback/BaseHassHandler.h
1
#pragma once
2

3
#include "Detector/Detector.h"
4
#include "Util/CurlWrapper.h"
5

6
#include <span>
7
#include <string>
8
#include <vector>
9

10
#include <boost/url.hpp>
11

12
#define JSON_USE_IMPLICIT_CONVERSIONS 0
13
#include <nlohmann/json.hpp>
14

15
namespace callback {
16

17
using json = nlohmann::json;
18

19
class BaseHassHandler {
20

21
public:
22
  BaseHassHandler(const boost::url &url, const std::string &token,
23
                  const std::string &entityId);
24
  BaseHassHandler(const BaseHassHandler &) = delete;
25
  BaseHassHandler(BaseHassHandler &&) = delete;
26
  BaseHassHandler &operator=(const BaseHassHandler &) = delete;
27
  BaseHassHandler &operator=(BaseHassHandler &&) = delete;
28

UNCOV
29
  virtual ~BaseHassHandler() noexcept = default;
×
30

31
  void operator()(std::optional<detector::RegionsOfInterest> rois = {});
32

UNCOV
33
  std::chrono::duration<double> debounceTime{30.0};
×
34
  std::string friendlyName;
35
  std::string entityId;
36

37
protected:
38
  virtual void UpdateState_Impl(std::string_view state,
39
                                const json &attributes = {}) = 0;
40

41
  void UpdateStateInternal(std::string_view state, const json &attributes);
42
  void UpdateBinarySensor(std::optional<detector::RegionsOfInterest> rois);
43
  void UpdateSensor(std::optional<detector::RegionsOfInterest> rois);
44

UNCOV
45
  [[nodiscard]] bool IsStateChanging() const {
×
UNCOV
46
    return nextState_ != currentState_;
×
47
  }
48
  [[nodiscard]] bool IsStateBecomingUnknown() const;
49

50
  void PrepareGetRequest(util::CurlWrapper &wCurl, std::vector<char> &buf);
51
  void HandleGetResponse(util::CurlWrapper &wCurl, std::span<const char> buf);
52

53
  void PreparePostRequest(util::CurlWrapper &wCurl, std::vector<char> &readBuf,
54
                          std::string &payload);
55
  void HandlePostResponse(util::CurlWrapper &wCurl, std::span<const char> buf);
56

57
private:
58
  boost::url url_;
59
  std::string token_;
60

61
  json currentState_ = {};
62
  json nextState_ = {};
63
};
64

65
} // namespace callback
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc