Skip to content

Commit

Permalink
Merge pull request #189 from Drenso/add-climate-sensors
Browse files Browse the repository at this point in the history
Add climate sensors
  • Loading branch information
bobvandevijver authored Aug 30, 2024
2 parents 521eab5 + e8f3254 commit 5a5db11
Show file tree
Hide file tree
Showing 21 changed files with 552 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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"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": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down
216 changes: 208 additions & 8 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -441,7 +441,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -482,7 +482,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -523,7 +523,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -920,7 +920,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -958,7 +958,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -996,7 +996,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -1034,7 +1034,7 @@
"name": "device",
"type": "device",
"filter": {
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
"driver_id": "camera|dimmer|doorbell|fan|heater|light|other|sensor_climate|sensor_contact|sensor_motion|sensor_smoke|siren|socket"
},
"title": {
"en": "Device"
Expand Down Expand Up @@ -2924,6 +2924,206 @@
}
]
},
{
"capabilities": [
"measure_temperature",
"measure_humidity"
],
"connectivity": [
"cloud"
],
"platforms": [
"local",
"cloud"
],
"images": {
"small": "/drivers/sensor_climate/assets/images/small.png",
"large": "/drivers/sensor_climate/assets/images/large.png",
"xlarge": "/drivers/sensor_climate/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": "Climate Sensor",
"nl": "Klimaatsensor"
},
"id": "sensor_climate",
"settings": [
{
"id": "va_temperature_scaling",
"type": "dropdown",
"label": {
"en": "Measured Temperature Scale"
},
"hint": {
"en": "By how much the temperature measured by the device is scaled."
},
"value": "1",
"values": [
{
"id": "0",
"label": {
"en": "1"
}
},
{
"id": "1",
"label": {
"en": "1/10"
}
},
{
"id": "2",
"label": {
"en": "1/100"
}
},
{
"id": "3",
"label": {
"en": "1/1000"
}
}
]
},
{
"id": "va_humidity_scaling",
"type": "dropdown",
"label": {
"en": "Measured Humidity Scale"
},
"hint": {
"en": "By how much the humidity measured by the device is scaled."
},
"value": "1",
"values": [
{
"id": "0",
"label": {
"en": "1"
}
},
{
"id": "1",
"label": {
"en": "1/10"
}
},
{
"id": "2",
"label": {
"en": "1/100"
}
},
{
"id": "3",
"label": {
"en": "1/1000"
}
}
]
},
{
"id": "bright_value_scaling",
"type": "dropdown",
"label": {
"en": "Measured Brightness Scale"
},
"hint": {
"en": "By how much the brightness measured by the device is scaled."
},
"value": "0",
"values": [
{
"id": "0",
"label": {
"en": "1"
}
},
{
"id": "1",
"label": {
"en": "1/10"
}
},
{
"id": "2",
"label": {
"en": "1/100"
}
},
{
"id": "3",
"label": {
"en": "1/1000"
}
}
]
},
{
"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": [
"alarm_contact"
Expand Down
30 changes: 30 additions & 0 deletions drivers/sensor_climate/TuyaClimateSensorConstants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/** capabilities that map one to one to a Homey capability */
export const CLIMATE_SENSOR_CAPABILITIES = {
read_write: ['switch'],
read_only: ['temper_alarm'],
read_only_scaled: ['va_temperature', 'va_humidity', 'bright_value'],
setting: [],
} as const;

export const CLIMATE_CAPABILITY_MAPPING = {
switch: 'onoff',
va_temperature: 'measure_temperature',
va_humidity: 'measure_humidity',
bright_value: 'measure_luminance',
battery_value: 'measure_battery',
va_battery: 'measure_battery',
} as const;

export const CLIMATE_SENSOR_SETTING_LABELS = {
va_temperature_scaling: 'Measured Temperature Scale',
va_humidity_scaling: 'Measured Humidity Scale',
bright_value_scaling: 'Measured Brightness Scale',
} as const;

export type HomeyClimateSensorSettings = {
va_temperature_scaling: '0' | '1' | '2' | '3';
va_humidity_scaling: '0' | '1' | '2' | '3';
bright_value_scaling: '0' | '1' | '2' | '3';
};

export type TuyaClimateSensorSettings = Record<string, never>;
10 changes: 10 additions & 0 deletions drivers/sensor_climate/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_climate/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_climate/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.
Binary file added drivers/sensor_climate/assets/images/xlarge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5a5db11

Please sign in to comment.