feat: Expose device serial number and origin (#7)

This commit is contained in:
Pascal Bourque
2025-06-07 10:58:41 -04:00
committed by GitHub
parent 2e2e64d2d0
commit 374dae1885
5 changed files with 245 additions and 145 deletions

View File

@@ -21,12 +21,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
import { Climate, ClimateAction, DeviceConfiguration, Logger, MqttSettings, Sensor } from 'mqtt2ha';
import {
Climate,
ClimateAction,
DeviceConfiguration,
Logger,
MqttSettings,
OriginConfiguration,
Sensor
} from 'mqtt2ha';
import { DeviceBase, FirmwareDevice, MysaApiClient, MysaDeviceMode, StateChange, Status } from 'mysa-js-sdk';
import { version } from './options';
export class Thermostat {
private isStarted = false;
private readonly mqttDevice: DeviceConfiguration;
private readonly mqttOrigin: OriginConfiguration;
private readonly mqttClimate: Climate;
private readonly mqttTemperature: Sensor;
private readonly mqttHumidity: Sensor;
@@ -40,14 +50,22 @@ export class Thermostat {
public readonly mysaDevice: DeviceBase,
private readonly mqttSettings: MqttSettings,
private readonly logger: Logger,
public readonly mysaDeviceFirmware?: FirmwareDevice
public readonly mysaDeviceFirmware?: FirmwareDevice,
public readonly mysaDeviceSerialNumber?: string
) {
this.mqttDevice = {
identifiers: mysaDevice.Id,
name: mysaDevice.Name,
manufacturer: 'Mysa',
model: mysaDevice.Model,
sw_version: mysaDeviceFirmware?.InstalledVersion
sw_version: mysaDeviceFirmware?.InstalledVersion,
serial_number: mysaDeviceSerialNumber
};
this.mqttOrigin = {
name: 'mysa2mqtt',
sw_version: version,
support_url: 'https://github.com/bourquep/mysa2mqtt'
};
this.mqttClimate = new Climate(
@@ -57,6 +75,7 @@ export class Thermostat {
component: {
component: 'climate',
device: this.mqttDevice,
origin: this.mqttOrigin,
unique_id: `mysa_${mysaDevice.Id}_climate`,
name: 'Thermostat',
min_temp: mysaDevice.MinSetpoint,
@@ -112,6 +131,7 @@ export class Thermostat {
component: {
component: 'sensor',
device: this.mqttDevice,
origin: this.mqttOrigin,
unique_id: `mysa_${mysaDevice.Id}_temperature`,
name: 'Current temperature',
device_class: 'temperature',
@@ -128,6 +148,7 @@ export class Thermostat {
component: {
component: 'sensor',
device: this.mqttDevice,
origin: this.mqttOrigin,
unique_id: `mysa_${mysaDevice.Id}_humidity`,
name: 'Current humidity',
device_class: 'humidity',
@@ -144,6 +165,7 @@ export class Thermostat {
component: {
component: 'sensor',
device: this.mqttDevice,
origin: this.mqttOrigin,
unique_id: `mysa_${mysaDevice.Id}_power`,
name: 'Current power',
device_class: 'power',