diff --git a/README.md b/README.md index 7da719037037fe0ec3f9a32fc06cc4aad69c5a88..da24f00cc0181abde19a6a3ea96eb6520936bba8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[PACKAGE]: ../../raw/master/mkp/fritzbox_smarthome-0.8.6-20240106.mkp "fritzbox_smarthome-0.8.6-20240106.mkp" +[PACKAGE]: ../../raw/master/mkp/fritzbox_smarthome-0.8.7-20240108.mkp "fritzbox_smarthome-0.8.7-20240108.mkp" # AVM Fritz!Box Smarthome This repository contains a additional check_MK Fritz!Box Agent which can gather informations over the AVM AHA HTTP Interface about SmartHome Devices connected to an Fritz!Box. diff --git a/mkp/fritzbox_smarthome-0.8.7-20240108.mkp b/mkp/fritzbox_smarthome-0.8.7-20240108.mkp new file mode 100644 index 0000000000000000000000000000000000000000..6314480b0038cea9aa183137f6212c7a9fd8f100 Binary files /dev/null and b/mkp/fritzbox_smarthome-0.8.7-20240108.mkp differ diff --git a/source/agent_based/fritzbox_smarthome_power_meter.py b/source/agent_based/fritzbox_smarthome_power_meter.py index 89ee6be9b387cbe0ef81881c9d2a79ece766998b..a337af5f6325e628e439f6aaa774d3b808f35668 100644 --- a/source/agent_based/fritzbox_smarthome_power_meter.py +++ b/source/agent_based/fritzbox_smarthome_power_meter.py @@ -178,6 +178,7 @@ def _cost_period_x( period_name: str, current_period: int, rate_name: str, + metric_name: str, last_reading: float, precision: int, message: str, @@ -189,21 +190,22 @@ def _cost_period_x( if stored_period := value_store.get(period_name): value_store[period_name] = current_period + cost = last_reading / 1000 * cost_kwh + if current_period != stored_period: value_store[period_name] = current_period - value_store[rate_name] = 0 - value = last_reading + value_store[rate_name] = cost else: - value = value_store.get(rate_name, 0) + last_reading - value_store[rate_name] = value + cost = value_store.get(rate_name, 0) + cost + value_store[rate_name] = cost - value = round((value / 1000 * cost_kwh), precision) + cost = round(cost, precision) yield Result( state=State.OK, - notice=message.replace('__value__', f'{value:.4f}') + notice=message.replace('__value__', f'{cost:.4f}') ) - yield Metric(name=rate_name, value=value) + yield Metric(name=metric_name, value=cost) def check_fritzbox_smarthome_energy_single( @@ -272,7 +274,8 @@ def check_fritzbox_smarthome_energy_single( value_store=value_store, period_name='current_hour', current_period=loca_time.tm_hour, - rate_name='cost_per_hour', + rate_name='cost_this_hour', # don't reuse -> cost_per_hour + metric_name='cost_per_hour', last_reading=energy, precision=6, message=f'Hour_: __value__{unit_sign}', @@ -282,7 +285,8 @@ def check_fritzbox_smarthome_energy_single( value_store=value_store, period_name='current_day', current_period=loca_time.tm_mday, - rate_name='cost_per_day', + rate_name='cost_this_day', # don't reuse -> cost_per_day + metric_name='cost_per_day', last_reading=energy, precision=4, message=f'Day__: __value__{unit_sign}', @@ -292,7 +296,8 @@ def check_fritzbox_smarthome_energy_single( value_store=value_store, period_name='current_month', current_period=loca_time.tm_mon, - rate_name='cost_per_month', + rate_name='cost_this_month', # don't reuse -> cost_per_month + metric_name='cost_per_month', last_reading=energy, precision=4, message=f'Month: __value__{unit_sign}', @@ -302,7 +307,8 @@ def check_fritzbox_smarthome_energy_single( value_store=value_store, period_name='current_year', current_period=loca_time.tm_year, - rate_name='cost_per_year', + rate_name='cost_this_year', # don't reuse -> cost_per_year + metric_name='cost_per_year', last_reading=energy, precision=4, message=f'Year_: __value__{unit_sign}', diff --git a/source/packages/fritzbox_smarthome b/source/packages/fritzbox_smarthome index 45968ae4d2306c872ea56efe8953340340c72d1a..e5b06686c4dc2a3474f913e93d38ea7bf06f4cc9 100644 --- a/source/packages/fritzbox_smarthome +++ b/source/packages/fritzbox_smarthome @@ -50,7 +50,7 @@ 'plugins/views/fritzbox_smarthome.py']}, 'name': 'fritzbox_smarthome', 'title': 'Fritz!Box SmartHome', - 'version': '0.8.6-20240106', + 'version': '0.8.7-20240108', 'version.min_required': '2.2.0b1', 'version.packaged': '2.2.0p17', 'version.usable_until': None}