Harvia Xenio WiFi
A Node.js library for controlling Harvia Xenio WiFi sauna control systems.

Features
- Full TypeScript support with comprehensive type definitions
- Simple API for controlling your Harvia sauna from Node.js applications
- Authentication with MyHarvia service using AWS Cognito
- Device discovery and management
- Real-time state monitoring
- Control power, temperature, light, and fan settings
Installation
npm install harvia-xenio-js
Quick Start
const { HarviaClient } = require('harvia-xenio-js');
async function main() {
try {
const client = new HarviaClient();
await client.login('your-email@example.com', 'your-password');
const devices = await client.getDevices();
if (devices.length === 0) {
console.log('No saunas found');
return;
}
const sauna = devices[0];
console.log(`Using sauna: ${sauna.name}`);
const state = await client.getState(sauna.serialNumber);
console.log(`Current temperature: ${state.temperature.current}°C`);
await client.power(sauna.serialNumber, true);
await client.setTemperature(sauna.serialNumber, 70);
const subscription = client.subscribeToState(sauna.serialNumber, (newState) => {
console.log(`Temperature: ${newState.temperature.current}°C / ${newState.temperature.target}°C`);
});
setTimeout(async () => {
subscription.unsubscribe();
await client.power(sauna.serialNumber, false);
await client.logout();
}, 30000);
} catch (error) {
console.error('Error:', error.message);
}
}
main();
API Documentation
Client Options
You can configure the client with these options:
const client = new HarviaClient({
baseUrl: 'https://prod.myharvia-cloud.net',
timeout: 10000,
autoRefreshToken: true,
pollingInterval: 5000,
});
Basic Methods
Authentication
await client.login('email@example.com', 'password');
await client.refreshToken();
await client.logout();
Device Management
const devices = await client.getDevices();
const device = await client.getDevice('SERIAL123');
State Monitoring
const state = await client.getState('SERIAL123');
const subscription = client.subscribeToState('SERIAL123', (state) => {
console.log(`Current temperature: ${state.temperature.current}°C`);
});
subscription.unsubscribe();
Commands
await client.power('SERIAL123', true);
await client.power('SERIAL123', false);
await client.setTemperature('SERIAL123', 70);
await client.setLight('SERIAL123', true);
await client.setLight('SERIAL123', false);
await client.setFan('SERIAL123', true);
await client.setFan('SERIAL123', false);
Data Types
SaunaState
The getState
method and state subscription callbacks return a SaunaState
object with the following properties:
{
power: boolean;
temperature: {
current: number;
target: number;
};
humidity: number;
light: boolean;
fan: boolean;
doorOpen: boolean;
remainingTime: number;
heatUpTime?: number;
}
Examples
The library includes several example applications in the examples
directory:
basic-control.js
- A simple example showing basic control operations
monitor-state.js
- An example demonstrating state monitoring
comprehensive-client.js
- A complete example showing all API features
Configuration
To run the examples, you need to set your MyHarvia credentials. You can do this in two ways:
- Using environment variables:
HARVIA_EMAIL=your@email.com HARVIA_PASSWORD=your_password node examples/basic-control.js
Copy the .env.sample
file to .env
and edit it with your credentials:
HARVIA_EMAIL=your@email.com
HARVIA_PASSWORD=your_password
Then run the examples normally:
node examples/basic-control.js
Development
Building
npm run build
Testing
The library includes a comprehensive test suite with good coverage:
npm test
To run tests with coverage report:
npm test -- --coverage
Authentication
The MyHarvia API uses AWS Cognito for authentication. This library fully implements the required AWS Cognito authentication using the amazon-cognito-identity-js
package.
The authentication flow:
- Fetches endpoint information from the MyHarvia API
- Uses the Cognito User Pool and Client ID from the endpoint response
- Authenticates with AWS Cognito using the provided email and password
- Stores the auth tokens and uses them for subsequent API calls
- Automatically refreshes the token when it expires (if autoRefreshToken is enabled)
Credits
This library is based on reverse-engineered API endpoints from the MyHarvia mobile app. Special thanks to RubenHarms/ha-harvia-xenio-wifi for documenting the API.
License
MIT