Skip to content

Commit

Permalink
Add temerature sensor device
Browse files Browse the repository at this point in the history
  • Loading branch information
haimkastner committed Aug 14, 2022
1 parent 9f21af9 commit f7d7ca3
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 17 deletions.
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,11 @@ The casa remote server is built for this, [casanet-remote](https://github.com/ca
- Philips LED Ceiling Lamp. [link](https://www.gearbest.com/smart-ceiling-lights/pp_009933492211.html)
- Robot Vacuum. [link](https://www.gearbest.com/robot-vacuum/pp_440546.html)

- Tasmota
- Tasmota (Rest API)

- Switch (tested with [this](https://www.gearbest.com/robot-vacuum-accessories/pp_009661965579.html?wid=1433363) and [this](https://www.gearbest.com/alarm-systems/pp_009227681096.html?wid=1433363))
- Air-conditioning (IR Transmitter) (tested with [this](https://www.aliexpress.com/item/33004692351.html) (after [flashing to Tasmota](https://blog.castnet.club/en/blog/flashing-tasmota-on-tuya-ir-bridge))

- [MQTT](http://mqtt.org/) module. [module documentation](./backend/src/modules/mqtt/README.md).
- Toggle.
- Switch.
- Air-conditioning.
- Light
- Temperature light.
- Color light.
- Roller.

- Mock (for testing purpose)

- Toggle demo.
Expand All @@ -169,6 +160,27 @@ The casa remote server is built for this, [casanet-remote](https://github.com/ca
- Temperature light demo.
- Color light demo.
- Roller demo.
- Temperature Sensor.


- #[MQTT](http://mqtt.org/) module [MQTT drivers documentation](./backend/src/modules/mqtt/README.md).

- *Supported types:*
- Toggle.
- Switch.
- Air-conditioning.
- Light
- Temperature light.
- Color light.
- Roller.
- *Supported drivers:*
- Tasmota (MQTT API)
- Switch (tested with [this](https://www.gearbest.com/robot-vacuum-accessories/pp_009661965579.html?wid=1433363) and [this](https://www.gearbest.com/alarm-systems/pp_009227681096.html?wid=1433363))

- Shelly (MQTT API)
- Button1 - (tested with [this](https://shop.shelly.cloud/shelly-button1-wifi-smart-home-automation#438))
- Switch 1PM - (tested with [this](https://shop.shelly.cloud/shelly-1pm-wifi-smart-home-automation-1#51))
- Duo - RGBW - (tested with [this](https://shop.shelly.cloud/shelly-bulb-rgbw-e27-wifi-smart-home-automation#436))

## Connecting devices

Expand Down
1 change: 1 addition & 0 deletions backend/src/models/remote2localProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export declare interface InitializationRequest {
remoteAuthKey: string;
platform: NodeJS.Platform;
version: string;
localIp?: string;
}

/** WS message from local to remote strut */
Expand Down
11 changes: 9 additions & 2 deletions backend/src/models/sharedInterfaces.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export declare interface User {
export declare type MinionTypes =
| 'toggle'
| 'switch'
| 'temperatureSensor'
| 'roller'
| 'cleaner'
| 'airConditioning'
Expand Down Expand Up @@ -294,6 +295,11 @@ export declare interface Toggle {
*/
export declare interface Switch extends Toggle { }

export declare interface TemperatureSensor extends Toggle {
/** Temperature in celsius (X°) */
temperature: number;
}

/**
* A roller switch status.
* A roller is a switch for curtains or blinds (or for any other needs) that can drag up/down or stop.
Expand Down Expand Up @@ -477,6 +483,7 @@ export declare interface MinionStatus {
light?: Light;
temperatureLight?: TemperatureLight;
colorLight?: ColorLight;
temperatureSensor?: TemperatureSensor;
}

/**
Expand Down Expand Up @@ -565,7 +572,7 @@ export declare interface MinionSetRoomName {
/**
* Used to set minion physical device.
*/
export declare interface MinionSetDevice {
export declare interface MinionSetDevice {
/** The device mac to set. */
mac: string;
}
Expand Down Expand Up @@ -628,7 +635,7 @@ export declare interface Minion {
/**
* Last status change timestamp in UTC MS
*/
statusChangedTime?: number;
statusChangedTime?: number;
}

/**
Expand Down
26 changes: 22 additions & 4 deletions backend/src/modules/mock/mockHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,31 @@ export class MockHandler extends BrandModuleBase {
isRecordingSupported: false,
isFetchCommandsAvailable: false,
},
{
brand: this.brandName,
isTokenRequired: false,
isIdRequired: false,
minionsPerDevice: -1,
model: 'Temperature Sensor Demo',
supportedMinionType: 'temperatureSensor',
isRecordingSupported: false,
isFetchCommandsAvailable: false,
},
];
/**
* Time duratin to mock pysical device status update for switch minion.
* Time duration to mock physical device status update for switch minion.
*/
private readonly SWITCH_CHANGED_INTERVAL: Duration = moment.duration(4, 'seconds');

/**
* Time duratin to mock pysical device status update for ac minion.
* Time duration to mock physical device status update for ac minion.
*/
private readonly AC_CHANGED_INTERVAL: Duration = moment.duration(5, 'seconds');

constructor() {
super();

// for debug updattes remove 'return'
// for debug updates remove 'return'
return;
setInterval(async () => {
const minions = await this.retrieveMinions.pull();
Expand Down Expand Up @@ -180,6 +190,13 @@ export class MockHandler extends BrandModuleBase {
direction: 'up',
},
};
case 'Temperature Sensor Demo':
return {
temperatureSensor: {
status: 'on',
temperature: Math.floor(Math.random() * 1000) / 10,
},
};
}

throw {
Expand All @@ -197,7 +214,8 @@ export class MockHandler extends BrandModuleBase {
minion.device.model === 'Roller demo' ||
minion.device.model === 'Light demo' ||
minion.device.model === 'Temperature Light demo' ||
minion.device.model === 'Color Light demo'
minion.device.model === 'Color Light demo' ||
minion.device.model === 'Temperature Sensor Demo'
) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion backend/src/utilities/lanManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function LocalNetworkReader(): Promise<LocalNetworkDevice[]> {

try {
logger.info('[LocalNetworkReader] Scanning network devices...');
const networkDevices = await scanLocalNetwork({ logger, localNetwork: Configuration.scanSubnet, queryVendor: isInternetOnline });
const networkDevices = await scanLocalNetwork({ logger, localNetwork: Configuration.scanSubnet, queryVendor: false });
logger.info('[LocalNetworkReader] Scanning network devices done.');

const devices: LocalNetworkDevice[] = [];
Expand Down

0 comments on commit f7d7ca3

Please sign in to comment.