kopia lustrzana https://github.com/weetmuts/wmbusmeters
Added --pollinterval=10m
rodzic
21f1fc113b
commit
7b586e9d8a
10
CHANGES
10
CHANGES
|
@ -1,4 +1,14 @@
|
|||
|
||||
Using :mbus as suffix to the meter driver now works to poll a meter of mbus instead of
|
||||
listening to wmbus telegrams.
|
||||
|
||||
wmbusmeters --pollinterval=1h --format=json MAIN=/dev/ttyUSB0:mbus MyTemp piigth:MAIN:2400:mbus 12301234 NOKEY
|
||||
|
||||
Added --pollinterval=<time> to set the poll interval for all meters to 10 minutes.
|
||||
As <time> you can say 5s 10m 11h etc.
|
||||
|
||||
Added --ppjson to pretty print json, ie add newlines and indentation.
|
||||
|
||||
Alexander Streit added support for the Zenner Zelsius C5 ISF heat meter. Thanks Alexander!
|
||||
|
||||
Version 1.7.0: 2022-03-28
|
||||
|
|
|
@ -283,7 +283,7 @@ As {options} you can use:
|
|||
--normal for normal logging
|
||||
--oneshot wait for an update from each meter, then quit
|
||||
--ppjson pretty print the json
|
||||
--pollevery=<time> time between polling of meters, default is 10m
|
||||
--pollinterval=<time> time between polling of meters, default is 10m
|
||||
--resetafter=<time> reset the wmbus dongle regularly, default is 23h
|
||||
--selectfields=id,timestamp,total_m3 select only these fields to be printed (--listfields=<meter> to list available fields)
|
||||
--separator=<c> change field separator to c
|
||||
|
|
|
@ -526,10 +526,10 @@ static shared_ptr<Configuration> parseNormalCommandLine(Configuration *c, int ar
|
|||
i++;
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(argv[i], "--pollevery=", 12) && strlen(argv[i]) > 12) {
|
||||
c->pollevery = parseTime(argv[i]+12);
|
||||
if (c->pollevery <= 0) {
|
||||
error("Not a valid time to regularly poll meters. \"%s\"\n", argv[i]+12);
|
||||
if (!strncmp(argv[i], "--pollinterval=", 15) && strlen(argv[i]) > 15) {
|
||||
c->pollinterval = parseTime(argv[i]+15);
|
||||
if (c->pollinterval <= 0) {
|
||||
error("Not a valid time to regularly poll meters. \"%s\"\n", argv[i]+15);
|
||||
}
|
||||
i++;
|
||||
continue;
|
||||
|
@ -625,6 +625,7 @@ static shared_ptr<Configuration> parseNormalCommandLine(Configuration *c, int ar
|
|||
|
||||
MeterInfo mi;
|
||||
mi.parse(name, driver, id, key);
|
||||
mi.poll_interval = c->pollinterval;
|
||||
|
||||
if (mi.driver == MeterDriver::UNKNOWN &&
|
||||
mi.driver_name.str() == "")
|
||||
|
|
|
@ -96,7 +96,7 @@ struct Configuration
|
|||
std::string logfile;
|
||||
bool json {};
|
||||
bool pretty_print_json {};
|
||||
int pollevery {}; // Time between polling.
|
||||
int pollinterval = 60*10; // Time between polling, default 10 minutes.
|
||||
bool fields {};
|
||||
char separator { ';' };
|
||||
std::vector<std::string> telegram_shells;
|
||||
|
|
|
@ -695,6 +695,7 @@ MeterCommonImplementation::MeterCommonImplementation(MeterInfo &mi,
|
|||
ids_ = mi.ids;
|
||||
idsc_ = toIdsCommaSeparated(ids_);
|
||||
link_modes_ = mi.link_modes;
|
||||
poll_interval_= mi.poll_interval;
|
||||
|
||||
if (mi.key.length() > 0)
|
||||
{
|
||||
|
@ -1016,6 +1017,14 @@ void MeterCommonImplementation::poll(shared_ptr<BusManager> bus_manager)
|
|||
{
|
||||
if (link_modes_.has(LinkMode::MBUS))
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
time_t next_poll_time = timestampLastUpdate()+pollInterval();
|
||||
if (now < next_poll_time)
|
||||
{
|
||||
// Not yet time to poll this meter.
|
||||
return;
|
||||
}
|
||||
|
||||
WMBus *bus_device = bus_manager->findBus(bus());
|
||||
|
||||
if (!bus_device)
|
||||
|
@ -1170,6 +1179,21 @@ string MeterCommonImplementation::unixTimestampOfUpdate()
|
|||
return string(ut);
|
||||
}
|
||||
|
||||
time_t MeterCommonImplementation::timestampLastUpdate()
|
||||
{
|
||||
return datetime_of_update_;
|
||||
}
|
||||
|
||||
void MeterCommonImplementation::setPollInterval(time_t interval)
|
||||
{
|
||||
poll_interval_ = interval;
|
||||
}
|
||||
|
||||
time_t MeterCommonImplementation::pollInterval()
|
||||
{
|
||||
return poll_interval_;
|
||||
}
|
||||
|
||||
bool needsPolling(MeterDriver d, DriverName& dn)
|
||||
{
|
||||
if (d != MeterDriver::UNKNOWN && d != MeterDriver::AUTO)
|
||||
|
|
|
@ -187,9 +187,7 @@ struct MeterInfo
|
|||
vector<Unit> conversions; // Additional units desired in json.
|
||||
|
||||
// If this is a meter that needs to be polled.
|
||||
int poll_seconds; // Poll every x seconds.
|
||||
int poll_hour_offset; // Instead of
|
||||
string poll_time_period; // Poll only during these hours.
|
||||
int poll_interval; // Poll every x seconds.
|
||||
|
||||
MeterInfo()
|
||||
{
|
||||
|
@ -432,6 +430,9 @@ struct Meter
|
|||
virtual string datetimeOfUpdateHumanReadable() = 0;
|
||||
virtual string datetimeOfUpdateRobot() = 0;
|
||||
virtual string unixTimestampOfUpdate() = 0;
|
||||
virtual time_t timestampLastUpdate() = 0;
|
||||
virtual void setPollInterval(time_t interval) = 0;
|
||||
virtual time_t pollInterval() = 0;
|
||||
|
||||
virtual void setNumericValue(FieldInfo *fi, Unit u, double v) = 0;
|
||||
virtual double getNumericValue(FieldInfo *fi, Unit u) = 0;
|
||||
|
|
|
@ -62,6 +62,10 @@ struct MeterCommonImplementation : public virtual Meter
|
|||
string datetimeOfUpdateHumanReadable();
|
||||
string datetimeOfUpdateRobot();
|
||||
string unixTimestampOfUpdate();
|
||||
time_t timestampLastUpdate();
|
||||
void setPollInterval(time_t interval);
|
||||
time_t pollInterval();
|
||||
|
||||
|
||||
void onUpdate(function<void(Telegram*,Meter*)> cb);
|
||||
int numUpdates();
|
||||
|
@ -236,6 +240,7 @@ private:
|
|||
LinkModeSet link_modes_ {};
|
||||
vector<string> shell_cmdlines_;
|
||||
vector<string> extra_constant_fields_;
|
||||
time_t poll_interval_ {};
|
||||
|
||||
protected:
|
||||
vector<Unit> conversions_;
|
||||
|
|
Ładowanie…
Reference in New Issue