Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": "a5938ab7.325b38",
- "type": "timed-counter",
- "z": "77bb0eda.e443e",
- "name": "Click counter",
- "timelimit": "500",
- "timeunit": "1",
- "withhold": true,
- "fixedtimeout": true,
- "pertopic": false,
- "x": 430,
- "y": 120,
- "wires": [
- [
- "87ad7c15.66f94"
- ]
- ]
- },
- {
- "id": "a942a51d.22b7d8",
- "type": "server-state-changed",
- "z": "77bb0eda.e443e",
- "name": "Switch guest bedroom",
- "server": "2142aba5.430414",
- "entityidfilter": "binary_sensor.shelly1_2_switch",
- "entityidfiltertype": "exact",
- "outputinitially": false,
- "state_type": "str",
- "haltifstate": "off",
- "halt_if_type": "",
- "halt_if_compare": "is",
- "outputs": 2,
- "output_only_on_state_change": true,
- "x": 140,
- "y": 180,
- "wires": [
- [
- "cd695deb.4ff56"
- ],
- [
- "a5938ab7.325b38",
- "cd695deb.4ff56"
- ]
- ]
- },
- {
- "id": "87ad7c15.66f94",
- "type": "switch",
- "z": "77bb0eda.e443e",
- "name": "How many clicks?",
- "property": "count",
- "propertyType": "msg",
- "rules": [
- {
- "t": "eq",
- "v": "1",
- "vt": "str"
- },
- {
- "t": "eq",
- "v": "2",
- "vt": "str"
- },
- {
- "t": "eq",
- "v": "3",
- "vt": "str"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 3,
- "x": 690,
- "y": 120,
- "wires": [
- [
- "1cb9a2c6.0fc7cd"
- ],
- [
- "ac449422.082998"
- ],
- [
- "ac449422.082998",
- "1cb9a2c6.0fc7cd"
- ]
- ]
- },
- {
- "id": "1cb9a2c6.0fc7cd",
- "type": "api-call-service",
- "z": "77bb0eda.e443e",
- "name": "toggle main light",
- "server": "2142aba5.430414",
- "service_domain": "switch",
- "service": "toggle",
- "data": "{\"entity_id\":\"switch.shelly1_2_relay\"}",
- "mergecontext": "",
- "output_location": "",
- "output_location_type": "none",
- "x": 1140,
- "y": 80,
- "wires": [
- []
- ]
- },
- {
- "id": "ac449422.082998",
- "type": "api-call-service",
- "z": "77bb0eda.e443e",
- "name": "toggle bed light",
- "server": "2142aba5.430414",
- "service_domain": "switch",
- "service": "toggle",
- "data": "{\"entity_id\":\"switch.sonoff_2460\"}",
- "mergecontext": "",
- "output_location": "",
- "output_location_type": "none",
- "x": 1140,
- "y": 140,
- "wires": [
- []
- ]
- },
- {
- "id": "cd695deb.4ff56",
- "type": "change",
- "z": "77bb0eda.e443e",
- "name": "Add timestamp",
- "rules": [
- {
- "t": "set",
- "p": "payload",
- "pt": "msg",
- "to": "{\t 'state': payload,\t 'timestamp': $millis()\t}",
- "tot": "jsonata"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 420,
- "y": 280,
- "wires": [
- [
- "54e2cd83.287184"
- ]
- ]
- },
- {
- "id": "54e2cd83.287184",
- "type": "join",
- "z": "77bb0eda.e443e",
- "name": "",
- "mode": "custom",
- "build": "object",
- "property": "payload",
- "propertyType": "msg",
- "key": "payload.state",
- "joiner": "\\n",
- "joinerType": "str",
- "accumulate": false,
- "timeout": "",
- "count": "2",
- "reduceRight": false,
- "reduceExp": "",
- "reduceInit": "",
- "reduceInitType": "",
- "reduceFixup": "",
- "x": 590,
- "y": 280,
- "wires": [
- [
- "54c1ed1a.7e8314"
- ]
- ]
- },
- {
- "id": "54c1ed1a.7e8314",
- "type": "change",
- "z": "77bb0eda.e443e",
- "name": "Process delta",
- "rules": [
- {
- "t": "set",
- "p": "threshold",
- "pt": "msg",
- "to": "1000",
- "tot": "num"
- },
- {
- "t": "set",
- "p": "delta",
- "pt": "msg",
- "to": "$lookup(payload, 'off').timestamp - $lookup(payload, 'on').timestamp",
- "tot": "jsonata"
- },
- {
- "t": "set",
- "p": "payload",
- "pt": "msg",
- "to": "delta < threshold ? 'short' : 'long'",
- "tot": "jsonata"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 760,
- "y": 280,
- "wires": [
- [
- "9f5e6aa6.458318"
- ]
- ]
- },
- {
- "id": "9f5e6aa6.458318",
- "type": "switch",
- "z": "77bb0eda.e443e",
- "name": "long?",
- "property": "payload",
- "propertyType": "msg",
- "rules": [
- {
- "t": "eq",
- "v": "long",
- "vt": "str"
- }
- ],
- "checkall": "true",
- "repair": false,
- "outputs": 1,
- "x": 930,
- "y": 280,
- "wires": [
- [
- "be460813.6f4aa8",
- "efac5498.afc0c8"
- ]
- ]
- },
- {
- "id": "be460813.6f4aa8",
- "type": "api-call-service",
- "z": "77bb0eda.e443e",
- "name": "Turn all lights off",
- "server": "2142aba5.430414",
- "service_domain": "switch",
- "service": "turn_off",
- "data": "{\"entity_id\":\"group.guest_room_lights\"}",
- "mergecontext": "",
- "output_location": "",
- "output_location_type": "none",
- "x": 1140,
- "y": 280,
- "wires": [
- []
- ]
- },
- {
- "id": "efac5498.afc0c8",
- "type": "change",
- "z": "77bb0eda.e443e",
- "name": "Reset counter",
- "rules": [
- {
- "t": "set",
- "p": "reset",
- "pt": "msg",
- "to": "",
- "tot": "str"
- }
- ],
- "action": "",
- "property": "",
- "from": "",
- "to": "",
- "reg": false,
- "x": 420,
- "y": 200,
- "wires": [
- [
- "a5938ab7.325b38"
- ]
- ]
- },
- {
- "id": "2142aba5.430414",
- "type": "server",
- "z": "",
- "name": "Home Assistant"
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement