Skip to content

Commit 2d161ee

Browse files
authored
Merge pull request #104 from mdeweerd/dev
routes_and_neigbours: add nwk, less files. Examples: danfoss.
2 parents bbe3fbd + d8ffe75 commit 2d161ee

File tree

7 files changed

+193
-17
lines changed

7 files changed

+193
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ data:
613613

614614
Get the bindings from the device.\
615615
Listen to the event, or enable debug and
616-
check the log to get the information.\\
616+
check the log to get the information.
617617

618618
```yaml
619619
service: zha_toolkit.binds_get

STATS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Badges showing number of downloads per version
22

33
- ![badge latest](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/latest/total.svg)
4+
- ![badge v0.8.22](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/v0.8.22/total.svg)
5+
- ![badge v0.8.21](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/v0.8.21/total.svg)
46
- ![badge v0.8.20](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/v0.8.20/total.svg)
57
- ![badge v0.8.19](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/v0.8.19/total.svg)
68
- ![badge v0.8.18](https://img.shields.io/github/downloads/mdeweerd/zha-toolkit/v0.8.18/total.svg)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
blueprint:
3+
domain: automation
4+
name: Ally Temp Update
5+
description: 'Update Danfoss Ally TRV external temperature with min/max refresh
6+
rate Original source: https://community.home-assistant.io/t/danfoss-ally-trv-working-with-remote-temp-sensor/276686/149'
7+
source_url: https://github.com/mdeweerd/zha-toolkit/blob/master/blueprints/danfoss_ally_remote_temperature.yaml
8+
input:
9+
ally_device:
10+
name: Ally TRV Device
11+
description: Temperature reading will be sent to this device
12+
selector:
13+
device:
14+
manufacturer: Danfoss
15+
entity:
16+
domain: climate
17+
temp_sensor_id:
18+
name: Temperature Sensor
19+
description: External sensor from which the temperature will be read. Expects
20+
data format 12.3 (corresponding to °C)
21+
selector:
22+
entity:
23+
domain: sensor
24+
device_class: temperature
25+
min_update_minutes:
26+
name: Minimum update interval
27+
description: >
28+
Updates will not be sent if time from last update is less than minimum interval.
29+
Normally 30 min for uncovered, 5 min for covered.
30+
default: 5
31+
selector:
32+
number:
33+
max: 360
34+
min: 1
35+
unit_of_measurement: minutes
36+
mode: box
37+
max_update_minutes:
38+
name: Maximum update interval
39+
description: >
40+
Updates must be sent at least every 30 minutes for covered radiators,
41+
and 3 hours for uncovered radiators.
42+
Set to 30 min or 150 min.
43+
default: 150
44+
selector:
45+
number:
46+
max: 180
47+
min: 1
48+
unit_of_measurement: minutes
49+
mode: box
50+
variables:
51+
device: !input ally_device
52+
ieee: "{{(device_attr(device, 'identifiers')|list)[0][1]}}"
53+
min_update_minutes: !input min_update_minutes
54+
temp_sensor_id: !input temp_sensor_id
55+
trigger:
56+
- platform: state
57+
entity_id:
58+
- !input temp_sensor_id
59+
- platform: homeassistant
60+
event: start
61+
condition:
62+
- condition: template
63+
value_template: >
64+
{{ as_timestamp(now()) - as_timestamp(state_attr(this.entity_id,'last_triggered'),0)|int
65+
>= (60 * min_update_minutes) }}
66+
action:
67+
- alias: Repeat until restarted to report temperature, or expired max_update delay
68+
repeat:
69+
while: "{{ 1 == 1 }}"
70+
sequence:
71+
- alias: Write remote temperature to Danfoss Ally
72+
service: zha_toolkit.attr_write
73+
data:
74+
ieee: '{{ ieee }}'
75+
cluster: 0x0201
76+
attribute: 0x4015
77+
attr_val: '{{ (states(temp_sensor_id) | float * 100) | round(0)}}'
78+
- alias: Wait until the maximum update delay expires (automation restarts
79+
when temperature changes before)
80+
delay:
81+
minutes: !input max_update_minutes
82+
mode: restart
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
blueprint:
3+
domain: script
4+
name: Zigbee Thermometer Configure Reporting
5+
description: A script that configures the reporting of a zigbee thermometer.
6+
source_url: https://github.com/mdeweerd/zha-toolkit/blob/master/blueprints/script_Thermometer_setReporting.yaml
7+
input:
8+
entity_name:
9+
name: entity_name
10+
description: A Zigbee Entity (all entities of the device resolve to the same
11+
address)
12+
selector:
13+
entity:
14+
integration: zha
15+
sequence:
16+
- service: zha_toolkit.conf_report
17+
data:
18+
ieee: '{{ entity_name }}'
19+
cluster: 1026
20+
attribute: 0
21+
tries: 100
22+
event_done: zha_done
23+
reportable_change: 20
24+
max_interval: 300
25+
min_interval: 19
26+
- service: zha_toolkit.conf_report_read
27+
data:
28+
ieee: '{{ entity_name }}'
29+
cluster: 1026
30+
attribute: 0
31+
tries: 100
32+
event_done: zha_done
33+
mode: restart
34+
icon: mdi:thermometer-check
35+
description: >-
36+
This script configures the selected Zigbee Thermometer to report its
37+
temperature at least every 5 minutes or every 0.2°C whichever occurs first.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
blueprint:
3+
domain: script
4+
name: Danfoss Ally TRV configuration
5+
description: A script that configures the reporting of a Danfoss Ally TRV. zigbee
6+
thermometer. You can listen on the 'zha_done' event to see some of the configuration
7+
results. Sets report configuration and enables window open function.
8+
source_url: https://github.com/mdeweerd/zha-toolkit/blob/master/blueprints/script_danfoss_ally_configure.yaml
9+
input:
10+
device_ref:
11+
name: Ally TRV Device
12+
description: A Danfoss Ally Thermostatic Regulation Valve (TRV) to configure
13+
selector:
14+
device:
15+
manufacturer: Danfoss
16+
entity:
17+
domain: climate
18+
integration: zha
19+
variables:
20+
device: !input device_ref
21+
ieee: "{{(device_attr(device, 'identifiers')|list)[0][1]}}"
22+
sequence:
23+
- alias: Configure reporting of local_temperature in Thermostat cluster
24+
service: zha_toolkit.conf_report
25+
data:
26+
ieee: '{{ ieee }}'
27+
cluster: 0x0201
28+
attribute: 0
29+
tries: 100
30+
event_done: zha_done
31+
reportable_change: 20
32+
max_interval: 300
33+
min_interval: 19
34+
- alias: Read back reporting configuration, for debugging
35+
service: zha_toolkit.conf_report_read
36+
data:
37+
ieee: '{{ ieee }}'
38+
cluster: 0x0201
39+
attribute: 0
40+
tries: 100
41+
event_done: zha_done
42+
- alias: Enable close window functionality
43+
service: zha_toolkit.attr_write
44+
data:
45+
ieee: '{{ ieee }}'
46+
cluster: 513
47+
attribute: 16387
48+
attr_val: 0
49+
manf: 4678
50+
mode: restart
51+
icon: mdi:thermometer-check
52+
description: >-
53+
This script configures the selected Danfoss Ally TRV.
54+
Report temperature at least every 5 minutes or every 0.2°C whichever occurs first.
55+
Enable the window open detection setting.

custom_components/zha_toolkit/binds.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,10 @@ async def bind_ieee(
215215
raise ValueError("'ieee' and 'data' required")
216216

217217
src_dev = app.get_device(ieee=ieee)
218+
if data in [0, False]:
219+
# when command_data is set to 0 or false, bind to coordinator
220+
data = app.ieee
221+
218222
dst_dev = await u.get_device(app, listener, data)
219223

220224
zdo = src_dev.zdo

custom_components/zha_toolkit/neighbours.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ async def routes_and_neighbours(
3232
device = app.get_device(ieee=ieee)
3333
event_data["result"] = await _routes_and_neighbours(device, listener)
3434

35+
ieee_tail = "".join([f"{o:02X}" for o in device.ieee])
36+
37+
fname = os.path.join(
38+
listener._hass.config.config_dir,
39+
"scans",
40+
f"routes_and_neighbours_{ieee_tail}.json",
41+
)
42+
save_json(fname, event_data["result"])
43+
44+
LOGGER.debug("Wrote scan results to '%s'", fname)
45+
3546

3647
async def _routes_and_neighbours(device, listener):
3748
try:
@@ -44,22 +55,6 @@ async def _routes_and_neighbours(device, listener):
4455
except asyncio.TimeoutError:
4556
nbns = []
4657

47-
ieee_tail = "".join([f"{o:02x}" for o in device.ieee])
48-
file_suffix = f"_{ieee_tail}.txt"
49-
50-
routes_name = os.path.join(
51-
listener._hass.config.config_dir, "scans", "routes" + file_suffix
52-
)
53-
save_json(routes_name, routes)
54-
55-
neighbours_name = os.path.join(
56-
listener._hass.config.config_dir, "scans", "neighbours" + file_suffix
57-
)
58-
save_json(neighbours_name, nbns)
59-
60-
LOGGER.debug(
61-
"Wrote scan results to '%s' and '%s'", routes_name, neighbours_name
62-
)
6358
return {"routes": routes, "neighbours": nbns}
6459

6560

@@ -104,6 +99,7 @@ def _process_neighbour(nbg):
10499
res = {}
105100
res["pan_id"] = str(nbg.extended_pan_id)
106101
res["ieee"] = str(nbg.ieee)
102+
res["nwk"] = str(nbg.nwk)
107103
res["device_type"] = nbg.device_type.name
108104
res["rx_on_when_idle"] = nbg.rx_on_when_idle.name
109105
res["relationship"] = nbg.relationship.name

0 commit comments

Comments
 (0)