Skip to content

Commit

Permalink
adds new values to Home Automation dashboard #81
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-Ricardo committed Dec 22, 2022
1 parent e6b1e0b commit e38dc2a
Show file tree
Hide file tree
Showing 2 changed files with 1,370 additions and 584 deletions.
20 changes: 14 additions & 6 deletions fritzinfluxdb/classes/fritzbox/service_definitions/homeauto.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def avm_temp_map(value, input_min, input_max, output_min, output_max):
if int_value in [253, 254]:
return float(int_value)
if int_value < input_min:
return float(input_min)
return float(output_min)
if int_value > input_max:
return float(input_max)
return float(output_max)

return float((int_value-input_min)/(input_max-input_min)*(output_max-output_min)+output_min)

Expand Down Expand Up @@ -140,6 +140,14 @@ def get_ha_switch_state(data):
return "0"+grab(data, "switch.state", fallback="0")


def get_ha_alert_state(data):

if in_test_mode():
return int((datetime.now().timestamp() - test_start_ts) / 600) % 2

return "0"+grab(data, "alert.state", fallback="0")


def decode_function_bitmask(bitmask: int):

return_values = list()
Expand Down Expand Up @@ -555,7 +563,7 @@ def prepare_response_data(response):
"next": {
"type": int,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: "0" + grab(data, "alert.state", fallback="0"),
"value_function": get_ha_alert_state,
"exclude_filter_function": lambda data: "alert" not in data.keys()
},
"exclude_filter_function": lambda data: "device" not in data.get("devicelist").keys()
Expand Down Expand Up @@ -584,7 +592,7 @@ def prepare_response_data(response):
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map("0" + grab(data, "hkr.tsoll", fallback="0"), 16, 56, 8, 28)
avm_temp_map("0" + grab(data, "hkr.tsoll", fallback="253"), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
Expand All @@ -598,7 +606,7 @@ def prepare_response_data(response):
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map("0" + grab(data, "hkr.komfort", fallback="0"), 16, 56, 8, 28)
avm_temp_map("0" + grab(data, "hkr.komfort", fallback="253"), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
Expand All @@ -612,7 +620,7 @@ def prepare_response_data(response):
"type": float,
"tags_function": lambda data: {"name": data.get("name")},
"value_function": lambda data: (
avm_temp_map("0" + grab(data, "hkr.absenk", fallback="0"), 16, 56, 8, 28)
avm_temp_map("0" + grab(data, "hkr.absenk", fallback="253"), 16, 56, 8, 28)
),
"exclude_filter_function": lambda data: "hkr" not in data.keys()
},
Expand Down
Loading

0 comments on commit e38dc2a

Please sign in to comment.