milesight-thermostat-api v2025.3.14-0
Milesight Thermostat Api
Description
The Milesight Thermostat API is an internal tool exclusively accessible to our backend team. It serves as a command hub for the Milesight WT201 thermostats using lorawan downlink commands. Additionally, the API allows facilitating effective control of their operational state.
Requirements
- RabbitMQ 3.9.11
- Node 20.15.0
Installation
$ npm install
Configuration
- AWS_ACCESS_KEY_ID
- AWS Access Key ID
AWS_SECRET_ACCESS_KEY
- AWS Secret Key
NODE_ENV
- Node environment
- LOG_LEVEL
- value can be debug, info, error and verbose.
MILESIGHT_THERMOSTAT_API_PORT
- configurable host port and has a default of
9059
- configurable host port and has a default of
AMQP_HOST
- rabbitmq host
- AMQP_USERNAME
- rabbitmq user
- AMQP_PASSWORD
- rabbitmq password
- AMQP_PORT
- rabbitmq port
Running the app
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Test
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
REST API
Get lorawan thermostat list
GET /thermostat/milesight
maxResult
(optional) range from 1-250 (default is 25)
nextToken
(optional) token for the succeeding page/request
Setting thermostat mode
POST thermostat/milesight/mode
Body: {
deviceEui: string;
serialNumber?: string;
mode: 'Heat' | 'EMHeat' | 'Cool' | 'Auto';
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
mode
(required) Mode of the HVAC unit
Setting thermostat hold
POST thermostat/milesight/hold
Body: {
deviceEui: string;
serialNumber?: string;
mode: 'Heat' | 'EMHeat' | 'Cool' | 'Auto';
temperatureUnit?: 'F' | 'C'
coolingSetPoint?: number;
heatingSetPoint?: number;
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
mode
(required) mode of the HVAC unit
temperatureUnit
(optional) temperature unit for the device to use
coolingSetPoint
(optional) target temperature for cooling
heatingSetPoint
(optional) target temperature for heating
Setting thermostat schedule
POST thermostat/milesight/schedule
Body: {
deviceEui: string,
serialNumber?: string,
temperatureUnit?: string,
controlMode: string,
occupiedHoursFanMode: string,
unoccupiedHoursFanMode: string,
occupiedHeatSetPoint: number;
unoccupiedHeatSetPoint: number;
occupiedCoolSetPoint: number;
unoccupiedCoolSetPoint: number;
schedule: {
monday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
tuesday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
wednesday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
thursday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
friday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
saturday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
sunday: {
planEnable: boolean;
startTime: string;
endTime: string;
},
}
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
temperatureUnit
(optional) temperature unit 'F' for fahrenheight 'C' for celsius
controlMode
(required) working mode of thermostat
schedule
(required): schedule for each day
occupiedHoursFanMode
fan mode during occupied hours ('Auto' | 'On' | 'Circulate')
unoccupiedHoursFanMode
fan mode during unoccupied hours ('Auto' | 'On' | 'Circulate')
occupiedHeatSetPoint
desired temperature during occupied hours
unoccupiedHeatSetPoint
desired temperature during unoccupied hours
occupiedCoolSetPoint
desired temperature during occupied hours
unoccupiedCoolSetPoint
desired temperature during unoccupied hours
{
monday:
{
planEnable: boolean to enable the plan for Monday
startTime: string in 24-hour format (HH) to define start time
endTime: string in 24-hour format (HH) to define end time
}
tuesday: Same structure as monday
wednesday: Same structure as monday
thursday: Same structure as monday
friday: Same structure as monday
saturday: Same structure as monday
sunday: Same structure as monday
}
Retrieving historical data
POST thermostat/milesight/retrieve
Body: {
deviceEui: string;
serialNumber?: string;
startTime: ISO8601 string;
endTime: ISO8601 string;
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
startTime
(required) start time
endTime
(required) end time
Reboot the thermostat
POST thermostat/milesight/reboot
Body: {
deviceEui: string;
serialNumber?: string;
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
Setting timezone
POST thermostat/milesight/timezone
Body: {
deviceEui: string;
serialNumber?: string;
timezoneOffset: number;
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
timezoneOffset
(required) timezone range (-12, 14)
Setting lock configuration
POST thermostat/milesight/lock
Body: {
deviceEui: string;
serialNumber?: string;
powerButton: boolean;
temperatureUpButton: boolean;
temperatureDownButton: boolean;
fanButton: boolean;
modeButton: boolean;
resetButton: boolean;
}
deviceEui
(required) device eui of the lorawan thermostat
serialNumber
(optional) serial number of the lorawan thermostat
powerButton
(required) true to lock and false to disable lock
temperatureUpButton
(required) true to lock and false to disable lock
temperatureDownButton
(required) true to lock and false to disable lock
fanButton
(required) true to lock and false to disable lock
modeButton
(required) true to lock and false to disable lock
resetButton
(required) true to lock and false to disable lock
8 months ago
6 months ago
4 months ago
3 months ago
4 months ago
4 months ago
3 months ago
6 months ago
7 months ago
3 months ago
8 months ago
8 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago