Skip to content

Commit

Permalink
Added trigger for Left open
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed Sep 11, 2021
1 parent 0b3867f commit c5d5d0d
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .homeycompose/flow/triggers/left_open.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"title": {
"en": "Left open",
"no": "Stått åpen"
},
"hint": {
"en": "Triggered when garage door has been left open for the specified duration set in 'Notify if left open' setting in the Remootio app",
"no": "Utløses når garasjeporten har stått åpen i den angitte varigheten satt i 'Notify if left open' innstillingen i Remootio appen"
},
"tokens": [
{
"type": "string",
"name": "name",
"title": {
"en": "Device name",
"no": "Enhetsnavn"
}
},
{
"type": "number",
"name": "duration",
"title": {
"en": "Duration",
"no": "Varighet"
}
}
]
}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ If you have flipped the logic (in the Remootio app) used on the sensor connected

## Backlog

- Trigger for garage door left open
- Trigger for whom/what opened/closed the gate/garage door

## Changelog

- 1.1.0
- Support for multiple Remootio devices
- Trigger card `Left open`
- 1.0.0
- Initial release

Expand Down
33 changes: 33 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@
"url": "https://github.com/runely/remootio-homey/issues"
},
"source": "https://github.com/runely/remootio-homey",
"flow": {
"triggers": [
{
"title": {
"en": "Left open",
"no": "Stått åpen"
},
"hint": {
"en": "Triggered when garage door has been left open for the specified duration set in 'Notify if left open' setting in the Remootio app",
"no": "Utløses når garasjeporten har stått åpen i den angitte varigheten satt i 'Notify if left open' innstillingen i Remootio appen"
},
"tokens": [
{
"type": "string",
"name": "name",
"title": {
"en": "Device name",
"no": "Enhetsnavn"
}
},
{
"type": "number",
"name": "duration",
"title": {
"en": "Duration",
"no": "Varighet"
}
}
],
"id": "left_open"
}
]
},
"drivers": [
{
"name": {
Expand Down
13 changes: 12 additions & 1 deletion lib/device/remootio.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class RemootioDevice extends Device {
}

if (decryptedPayload.event !== undefined) { // it's a event frame containing a log entry from Remootio
this.log(`${this.getName()} -- event -- ${decryptedPayload.response.type} -- Incomming message : ${JSON.stringify(decryptedPayload, null, 2)}`)
this.log(`${this.getName()} -- event -- ${decryptedPayload.event.type} -- Incomming message : ${JSON.stringify(decryptedPayload, null, 2)}`)
if (decryptedPayload.event.type === 'StateChange') {
// this event is sent by Remootio when the status of the garage door has changed
this.log(`${this.getName()} -- event -- ${decryptedPayload.event.type} -- State changed to ${getReadableState(logicFlipped, decryptedPayload.event.state)}`)
Expand All @@ -130,6 +130,17 @@ class RemootioDevice extends Device {
// this event is sent by Remootio when the sensor logic has been flipped or unflipped. There is no way to tell which it is, so this should be set manually by the user in settings
this.log(`${this.getName()} -- event -- ${decryptedPayload.event.type} -- Sensor flipped. Update manually in settings`)
}
if (decryptedPayload.event.type === 'LeftOpen') {
// this event is sent by Remootio when the garage door has been left open for the set time duration
const duration = decryptedPayload.event.data.timeOpen100ms / 10
this.log(`${this.getName()} -- event -- ${decryptedPayload.event.type} -- Left open for ${duration} seconds`)

const tokens = {
duration,
name: this.getName()
}
this.homey.flow.getTriggerCard('left_open').trigger(tokens)
}
}
}

Expand Down

0 comments on commit c5d5d0d

Please sign in to comment.