Skip to content

Commit

Permalink
Merge pull request #259 from Drenso/add-vibration-sensor
Browse files Browse the repository at this point in the history
Add vibration sensor
  • Loading branch information
bobvandevijver authored Nov 12, 2024
2 parents 3a31f7f + d22666f commit 1596475
Show file tree
Hide file tree
Showing 20 changed files with 254 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .homeycompose/flow/actions/send_command_boolean.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/actions/send_command_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/actions/send_command_number.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/actions/send_command_string.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/triggers/receive_status_boolean.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/triggers/receive_status_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/triggers/receive_status_number.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
2 changes: 1 addition & 1 deletion .homeycompose/flow/triggers/receive_status_string.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down
104 changes: 96 additions & 8 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -479,7 +479,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -520,7 +520,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -561,7 +561,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -1371,7 +1371,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -1409,7 +1409,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -1447,7 +1447,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -1485,7 +1485,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|siren|socket|thermostat|window_coverings"
"driver_id": "button|camera|circuit_breaker|dehumidifier|dimmer|doorbell|fan|garage_door|heater|humidifier|irrigator|light|other|sensor_climate|sensor_co2|sensor_contact|sensor_gas|sensor_human|sensor_motion|sensor_pm2.5|sensor_smoke|sensor_vibration|siren|socket|thermostat|window_coverings"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -7327,6 +7327,94 @@
}
]
},
{
"capabilities": [
"alarm_vibration"
],
"connectivity": [
"cloud"
],
"platforms": [
"local",
"cloud"
],
"images": {
"small": "/drivers/sensor_vibration/assets/images/small.png",
"large": "/drivers/sensor_vibration/assets/images/large.png",
"xlarge": "/drivers/sensor_vibration/assets/images/xlarge.png"
},
"pair": [
{
"id": "welcome",
"navigation": {
"next": "login_oauth2"
}
},
{
"id": "login_oauth2",
"template": "login_oauth2"
},
{
"id": "list_devices",
"template": "list_devices",
"navigation": {
"next": "add_devices"
}
},
{
"id": "add_devices",
"template": "add_devices"
}
],
"repair": [
{
"id": "login_oauth2",
"template": "login_oauth2"
}
],
"class": "sensor",
"name": {
"en": "Vibration Sensor",
"nl": "Trillingssensor"
},
"id": "sensor_vibration",
"settings": [
{
"id": "use_alarm_timeout",
"type": "checkbox",
"hint": {
"en": "Turn the alarm off a set time after the start signal, even if no end signal is received."
},
"label": {
"en": "Use Alarm Timeout"
},
"value": false
},
{
"id": "alarm_timeout",
"type": "number",
"label": {
"en": "Alarm Timeout"
},
"value": 10,
"min": 1,
"units": {
"en": "seconds"
}
},
{
"id": "deviceSpecification",
"type": "label",
"label": {
"en": "Device Specification"
},
"hint": {
"en": "The Tuya specification of this device"
},
"value": "<not available>"
}
]
},
{
"capabilities": [
"onoff"
Expand Down
1 change: 1 addition & 0 deletions drivers/sensor_vibration/assets/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/sensor_vibration/assets/images/large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added drivers/sensor_vibration/assets/images/small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions drivers/sensor_vibration/device.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import TuyaOAuth2DeviceSensor from '../../lib/sensor/TuyaOAuth2DeviceSensor';
import { TuyaStatus } from '../../types/TuyaTypes';

module.exports = class TuyaOAuth2DeviceSensorVibration extends TuyaOAuth2DeviceSensor {
async onOAuth2Init(): Promise<void> {
await this.initAlarm('alarm_vibration').catch(this.error);

return super.onOAuth2Init();
}

async onTuyaStatus(status: TuyaStatus, changedStatusCodes: string[]): Promise<void> {
await super.onTuyaStatus(status, changedStatusCodes);

for (const tuyaCapability in status) {
const value = status[tuyaCapability];
if (
tuyaCapability === 'shock_state' &&
(!this.getSetting('use_alarm_timeout') || changedStatusCodes.includes(tuyaCapability))
) {
this.setAlarmCapabilityValue('alarm_vibration', value !== 'normal').catch(this.error);
}
}
}
};
Loading

0 comments on commit 1596475

Please sign in to comment.