1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
| [
{
"id": "60a483fd8f0eec93",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "state_change",
"type": "server-state-changed",
"z": "60a483fd8f0eec93",
"name": "Monitor media player",
"server": "5ec26e40.5a9cb",
"version": 6,
"outputs": 1,
"exposeAsEntityConfig": "",
"entities": {
"entity": [
"media_player.bathroom"
],
"substring": [],
"regex": []
},
"outputInitially": false,
"stateType": "str",
"ifState": "",
"ifStateType": "str",
"outputOnlyOnStateChange": false,
"for": "0",
"forType": "num",
"forUnits": "seconds",
"ignorePrevStateNull": true,
"ignorePrevStateUnknown": true,
"ignorePrevStateUnavailable": true,
"ignoreCurrentStateUnknown": true,
"ignoreCurrentStateUnavailable": true,
"outputProperties": [
{
"property": "data",
"propertyType": "msg",
"value": "",
"valueType": "eventData"
}
],
"x": 380,
"y": 960,
"wires": [
[
"compare_volume_change"
]
]
},
{
"id": "compare_volume_change",
"type": "function",
"z": "60a483fd8f0eec93",
"name": "Detect Volume Change",
"func": "var oldVolume = msg.data.old_state ? msg.data.old_state.attributes.volume_level : null;\nvar newVolume = msg.data.new_state ? msg.data.new_state.attributes.volume_level : null;\n\nif (oldVolume !== null && newVolume !== null && oldVolume !== newVolume) {\n msg.payload = { \"oldVolume\": oldVolume, \"newVolume\": newVolume };\n return msg;\n} else {\n return null; // No change, don't pass message forward\n}",
"outputs": 1,
"timeout": "",
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 960,
"wires": [
[
"2dd4036e32f877cd"
]
]
},
{
"id": "2dd4036e32f877cd",
"type": "api-call-service",
"z": "60a483fd8f0eec93",
"name": "",
"server": "5ec26e40.5a9cb",
"version": 7,
"debugenabled": false,
"action": "persistent_notification.create",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [],
"labelId": [],
"data": "{\t \"message\": \"Change to \" & $string(payload.newVolume * 100) & \"%\",\t \"title\":\"Test notification\",\t \"notification_id\": \"test\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": true,
"domain": "persistent_notification",
"service": "create",
"x": 980,
"y": 960,
"wires": [
[]
]
},
{
"id": "5ec26e40.5a9cb",
"type": "server",
"name": "Home Assistant",
"addon": true
}
] |