Skip to content

Commit

Permalink
Removed automatic query update
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed Feb 4, 2024
1 parent 7e281e8 commit ca40d19
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 111 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ If you are or want to use Websocket API, go to Websocket API instead

The Device API is hosted on Remootio's servers, so your Remootio device must have internet access and be reachable by the Device API

:exclamation: The Device API is limited to 300 requests per 20 days (this is Remootio's limits!). This means you should be able to open and close your gate/garage door around 6 times a day.<br />If you exceed this limit you will not be able to send requests to the Device API for a while (not sure about the time frame)!

:exclamation: Given the low limit on the Device API, the Remootio app will only query the Device API for its status after it has been toggled. This to make sure the Remootio app has the same status as the Remootio device.

:exclamation: If the gate/garage door is operated outside the Remootio app, the status in the Remootio app will NOT reflect this until it's been toggled in the Remootio app in Homey.

To allow the Device API to control your Remootio device you must setup an App-Free key through the Remootio app on your phone:
- Go to shared keys
- Click `Share a new key` and choose `Share unique key (recommended)`
Expand All @@ -139,22 +145,22 @@ When adding a Remootio device to your Homey, copy in the `token` value found in

###### Settings

**Device status update interval**
**Seconds for status change**

Number of minutes between each time a query is sent to the Device API to check device status.
Number of seconds before the gate/garage door has changed status after being operated.<br />A query is sent to the device api after this amount of seconds to set the correct device status. This is done to make sure the device status has the same status as the Remootio device.

###### Troubleshooting

- `Device doesn't change status when gate/garage door is opened/closed externally (by button or Remootio app etc.)`
1. You might have set the setting **Device status update interval** to a too high interval
1. Keep in mind that when changing the gate/garage door status externally, the Remootio app in Homey wont know this until it queries the Device API and receives the new status.
1. This is by design. The device API is limited to 300 requests per 20 days, so in order not to go beyond the limit, the device status is not updated automatically but only when the device status changes from the Remootio app in Homey
- `Device not found in pairing`
1. Make sure your Remootio device is successfully setup
1. Make sure you have enabled Wi-Fi on your Remootio device
1. Make sure you have successfully created an App-Free key, and that key's `token` value is actually used in the Remootio app in Homey
1. Make sure you have successfully created an App-Free key, and that key's `token` value is actually used in the Remootio app in Homey (Repair)
1. Make sure your Remootio device isn't already added as a device in Homey (serialnumber on the device is used as an identifier, and will only be allowed to be added once)
- `Device unavailable with error`: <b><u>Device API not reachable : ...</u></b>
1. Make sure your Remootio device has WiFi enabled and has internet access
1. If the error is `429 - Too Many Requests`, you have exceeded the Device API of 300 requests and must wait until Remootio lets you back in!
- `Device unavailable with error`: <b><u>Device API query failed : ...</u></b>
1. Make sure the `token` value you have added is working. You can test the token by visiting this Remootio site and use the token. If you can connect to your device, the token is valid: https://device.remootio.com/

Expand Down
12 changes: 10 additions & 2 deletions README.no.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ Device API

Device API'et er hostet på Remootio's servere, så din Remootio enhet må ha tilgang til internett og kunne nås av Device API'et

VIKTIG: Device API'et er begrenset til 300 forespørsler per 20 dager (dette er Remootios grenser!). Dette betyr at du bør kunne åpne og lukke porten/garasjedøren din rundt 6 ganger om dagen.
Hvis du overskrider denne grensen vil du ikke kunne sende forespørsler til Device API'et på en stund (usikker på tidsrammen)!

VIKTIG: Gitt den lave grensen på Device API'et, vil Remootio-appen bare spørre Device API'et for status etter at den har blitt endret i Remootio-appen. Dette for å sikre at Remootio-appen har samme status som Remootio-enheten.

VIKTIG: Hvis porten/garasjeporten betjenes utenfor Remootio-appen, vil statusen i Remootio-appen IKKE gjenspeile dette før den er endret i Remootio-appen i Homey.

For å tillate at Device API'et kan kontrollere din Remootio enhet, må du sette opp en App-Free key gjennom Remootio app'en på din telefon:
- Gå til shared keys
- Klikk på 'Share a new key' og velg 'Share unique key (recommended)'
Expand All @@ -78,8 +85,9 @@ Når du legger til Remootio enheten til din Homey, kopier inn 'token'-verdien fu

Innstillinger

Intervall for oppdatering av enhetsstatus
Sekunder for statusendring

Antall minutter mellom hver gang en spørring sendes til Device API'et for å sjekke enhetsstatus.
Antall sekunder før porten/garasjeporten har endret status etter betjening
En forespørsel sendes til device api'et etter dette antallet sekunder for å angi riktig enhetsstatus. Dette gjøres for å sikre at enhetsstatusen har samme status som Remootio-enheten.

For ytterligere dokumentasjon eller feilsøking, sjekk ut GitHub-siden
12 changes: 10 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ Device API

The Device API is hosted on Remootio's servers, so your Remootio device must have internet access and be reachable by the Device API

IMPORTANT: The Device API is limited to 300 requests per 20 days (this is Remootio's limits!). This means you should be able to open and close your gate/garage door around 6 times a day.
If you exceed this limit you will not be able to send requests to the Device API for a while (not sure about the time frame)!

IMPORTANT: Given the low limit on the Device API, the Remootio app will only query the Device API for its status after it has been toggled. This to make sure the Remootio app has the same status as the Remootio device.

IMPORTANT: If the gate/garage door is operated outside the Remootio app, the status in the Remootio app will NOT reflect this until it's been toggled in the Remootio app in Homey.

To allow the Device API to control your Remootio device you must setup an App-Free key through the Remootio app on your phone:
- Go to shared keys
- Click 'Share a new key' and choose 'Share unique key (recommended)'
Expand All @@ -78,8 +85,9 @@ When adding the Remootio device to your Homey, copy in the 'token' value found i

Settings

Device status update interval
Seconds for status change

Number of minutes between each time a query is sent to the Device API to check device status.
Number of seconds before the gate/garage door has changed status after being operated.
A query is sent to the device api after this amount of seconds to set the correct device status. This is done to make sure the device status has the same status as the Remootio device.

For additional documentation or troubleshooting, check out the GitHub page
55 changes: 30 additions & 25 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,28 @@
{
"type": "group",
"label": {
"en": "API settings",
"no": "API-innstillinger"
"en": "Settings",
"no": "Innstillinger"
},
"children": [
{
"id": "queryInterval",
"id": "secondsToChangeStatus",
"type": "number",
"label": {
"en": "Device status update interval",
"no": "Intervall for oppdatering av enhetsstatus"
"en": "Seconds for status change",
"no": "Sekunder for statusendring"
},
"min": 5,
"max": 60,
"step": 1,
"value": 5,
"units": {
"en": "seconds",
"no": "sekunder"
},
"min": 1,
"max": 1440,
"value": 15,
"hint": {
"en": "Number of minutes between each time a query will be sent to the Device API to check device status",
"no": "Antall minutter mellom hver gang en spørring sendes til Device API'et for å sjekke enhetsstatus"
"en": "Number of seconds before the gate/garage door has changed status after being operated.\n\nA query is sent to the device api after this amount of seconds to set the correct device status. This is done to make sure the device status has the same status as the Remootio device.",
"no": "Antall sekunder før porten/garasjeporten har endret status etter betjening\n\nEn forespørsel sendes til device api'et etter dette antallet sekunder for å angi riktig enhetsstatus. Dette gjøres for å sikre at enhetsstatusen har samme status som Remootio-enheten."
}
}
]
Expand All @@ -272,62 +277,62 @@
"children": [
{
"id": "deviceName",
"type": "text",
"type": "label",
"label": {
"en": "Device name",
"no": "Enhetsnavn"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "outputConfig",
"type": "text",
"type": "label",
"label": {
"en": "Output configuration",
"no": "Utgangskonfigurasjon"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "serialNumber",
"type": "text",
"type": "label",
"label": {
"en": "Serial number",
"no": "Serienummer"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will not change",
"no": "Lagt til under parring, og vil ikke endre seg"
}
},
{
"id": "keyNumber",
"type": "number",
"type": "label",
"label": {
"en": "App-Free key index used",
"no": "App-Free nøkkelindeks i bruk"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "remootioType",
"type": "text",
"type": "label",
"label": {
"en": "Remootio version",
"no": "Remootio versjon"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will not change",
"no": "Lagt til under parring, og vil ikke endre seg"
}
}
]
Expand Down
24 changes: 12 additions & 12 deletions drivers/remootio-device-api/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ class RemootioDeviceAPIDriver extends Driver {
let secretKey = ''
let deviceName = ''
let serialNumber = ''
let keyNum = 0
let deviceType = ''
let outputConf = ''
let keyNumber = '0'
let remootioType = ''
let outputConfig = ''

session.setHandler('login-secret-key-post', async data => {
secretKey = data.secretKey
Expand All @@ -35,12 +35,12 @@ class RemootioDeviceAPIDriver extends Driver {
throw new Error(`Invalid token:\r\n${deviceData.status} : ${deviceData.statusText}`)
}

const { deviceState: { outputConfig, gateName, serialNo, keyNumber, type } } = deviceData.data
outputConf = outputConfig
deviceName = gateName
serialNumber = serialNo
keyNum = keyNumber
deviceType = type
const { deviceState } = deviceData.data
outputConfig = deviceState.outputConfig
deviceName = deviceState.gateName
serialNumber = deviceState.serialNo
keyNumber = deviceState.keyNumber.toString()
remootioType = deviceState.type
this.log(`driver_onPair -> login-secret-key-post -> device-api communication success : I will add device with name '${deviceName}' and serialNo '${serialNumber}'`)
await session.showView('list_devices')
})
Expand All @@ -55,11 +55,11 @@ class RemootioDeviceAPIDriver extends Driver {
id: serialNumber
},
settings: {
outputConfig: outputConf,
outputConfig,
deviceName,
serialNumber,
keyNumber: keyNum,
remootioType: deviceType
keyNumber,
remootioType
},
store: {
token: secretKey
Expand Down
55 changes: 30 additions & 25 deletions drivers/remootio-device-api/driver.settings.compose.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,28 @@
{
"type": "group",
"label": {
"en": "API settings",
"no": "API-innstillinger"
"en": "Settings",
"no": "Innstillinger"
},
"children": [
{
"id": "queryInterval",
"id": "secondsToChangeStatus",
"type": "number",
"label": {
"en": "Device status update interval",
"no": "Intervall for oppdatering av enhetsstatus"
"en": "Seconds for status change",
"no": "Sekunder for statusendring"
},
"min": 5,
"max": 60,
"step": 1,
"value": 5,
"units": {
"en": "seconds",
"no": "sekunder"
},
"min": 1,
"max": 1440,
"value": 15,
"hint": {
"en": "Number of minutes between each time a query will be sent to the Device API to check device status",
"no": "Antall minutter mellom hver gang en spørring sendes til Device API'et for å sjekke enhetsstatus"
"en": "Number of seconds before the gate/garage door has changed status after being operated.\n\nA query is sent to the device api after this amount of seconds to set the correct device status. This is done to make sure the device status has the same status as the Remootio device.",
"no": "Antall sekunder før porten/garasjeporten har endret status etter betjening\n\nEn forespørsel sendes til device api'et etter dette antallet sekunder for å angi riktig enhetsstatus. Dette gjøres for å sikre at enhetsstatusen har samme status som Remootio-enheten."
}
}
]
Expand All @@ -32,62 +37,62 @@
"children": [
{
"id": "deviceName",
"type": "text",
"type": "label",
"label": {
"en": "Device name",
"no": "Enhetsnavn"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "outputConfig",
"type": "text",
"type": "label",
"label": {
"en": "Output configuration",
"no": "Utgangskonfigurasjon"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "serialNumber",
"type": "text",
"type": "label",
"label": {
"en": "Serial number",
"no": "Serienummer"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will not change",
"no": "Lagt til under parring, og vil ikke endre seg"
}
},
{
"id": "keyNumber",
"type": "number",
"type": "label",
"label": {
"en": "App-Free key index used",
"no": "App-Free nøkkelindeks i bruk"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will be updated automatically",
"no": "Lagt til under parring, og vil bli oppdatert automatisk"
}
},
{
"id": "remootioType",
"type": "text",
"type": "label",
"label": {
"en": "Remootio version",
"no": "Remootio versjon"
},
"hint": {
"en": "added on pair, and will be updated on each query interval",
"no": "lagt til under parring, og vil bli oppdatert ved hver oppdateringsintervall"
"en": "Added on pair, and will not change",
"no": "Lagt til under parring, og vil ikke endre seg"
}
}
]
Expand Down
5 changes: 4 additions & 1 deletion drivers/remootio-device-api/pair/login-secret-key.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,17 @@
return hasError
}

document.getElementById('connect').addEventListener('click', () => {
const connectBtn = document.getElementById('connect')
connectBtn.addEventListener('click', () => {
if (isFormInvalid()) {
Homey.alert(Homey.__('driver.pair.formError'))
return
} else {
connectBtn.setAttribute('disabled', 'disabled')
Homey.emit('login-secret-key-post', {
secretKey: document.getElementById('secretkey').value
}).catch(function (err) {
connectBtn.removeAttribute('disabled')
Homey.alert(err)
})
}
Expand Down
Loading

0 comments on commit ca40d19

Please sign in to comment.