Youless

Youless

Class representing a session with a youless device.

Constructor

new Youless(optionsopt)

Properties:
Name Type Description
timeout number

http timeout in milliseconds.

loggedIn boolean

login state.

Example
// create a youless session, login to device, fetch basic power info
const Youless = require('youless');

const youless = new Youless();

async function getPower() {
	try {
		// Leave out password if no password is set in the device
		// Leave out host if you want to autodiscover the device during login
		await youless.login({ password = 'secretPassword', host = '192.168.1.50' });
		const powerInfo = await youless.getBasicInfo();
		console.log(powerInfo);
	} catch (error) {
		console.log(error);
	}
}

getPower();
Parameters:
Name Type Attributes Description
options sessionOptions <optional>

configurable session options

Methods

(async) discover() → {Promise.<Array.<info>>}

Discovers LS120 devices in the local network, and LS110 devices if no password is set in the device. Also sets the ip address of the first discovered device as host address for this session.

Returns:

Array with info on discovered devices, including host ip address.

Type
Promise.<Array.<info>>

(async) getAdvancedStatus() → {Promise.<advancedStatus>}

Get advanced power information.

Returns:
Type
Promise.<advancedStatus>

(async) getBasicStatus() → {Promise.<basicStatus>}

Get basic power information.

Returns:
Type
Promise.<basicStatus>

(async) getGaslog(resolutionopt, periodopt) → {Promise.<gasLog>}

Get historic gas usage data. Note: Only available for LS120.

Parameters:
Name Type Attributes Default Description
resolution string <optional>
'Days'

The interval of logdata in: T(enminutes), H(ours) or D(ays)

period number <optional>
this month

The period that can be selected for historic data depends on the selected resolution:

  • Tenminutes: period 1 (this day) - 30 (30 days ago)
  • Hours: period 1 (this day) - 70 (70 days ago)
  • Days: period 1 (January) - 12 (December)
Returns:
Type
Promise.<gasLog>

(async) getInfo(hostopt) → {Promise.<info>}

Get device information. NOTE: Only works for LS120, or if logged in, or when no password is set in device

Parameters:
Name Type Attributes Description
host string <optional>

The url or ip address of the device.

Returns:
Type
Promise.<info>

(async) getP1Status() → {Promise.<P1Status>}

Get P1 version, tariff and power, voltage, current information per phase.

Returns:
Type
Promise.<P1Status>

(async) getPowerlog(resolutionopt, periodopt) → {Promise.<powerLog>}

Get historic electricity Power data.

Parameters:
Name Type Attributes Default Description
resolution string <optional>
'Days'

The interval of logdata in: M(inutes), T(enminutes), H(ours) or D(ays)

period number <optional>
this month

The period that can be selected for historic data depends on the device type and selected resolution:

  • Minutes: period 1 (this hour) - 20 (20 hours ago) (LS110: max 2 hours ago)
  • Tenminutes: period 1 (this day) - 30 (30 days ago) (LS110: max 3 days ago)
  • Hours: period 1 (this day) - 70 (70 days ago) (LS110: max 7 days ago)
  • Days: period 1 (January) - 12 (December)
Returns:
Type
Promise.<powerLog>

(async) getRawP1Status(noCheckopt) → {Promise.<rawP1Status>}

Get raw P1 information.

Parameters:
Name Type Attributes Default Description
noCheck boolean <optional>
false

When set to true corrupt or incomplete responses will not throw an error

Returns:
Type
Promise.<rawP1Status>

(async) getS0log(resolutionopt, periodopt) → {Promise.<s0Log>}

Get historic S0 Power data. Note: Only available for LS120.

Parameters:
Name Type Attributes Default Description
resolution string <optional>
'Days'

The interval of logdata in: M(inutes), T(enminutes), H(ours) or D(ays)

period number <optional>
this month

The period that can be selected for historic data depends on the selected resolution:

  • Minutes: period 1 (this hour) - 20 (20 hours ago)
  • Tenminutes: period 1 (this day) - 30 (30 days ago)
  • Hours: period 1 (this day) - 70 (70 days ago)
  • Days: period 1 (January) - 12 (December)
Returns:
Type
Promise.<s0Log>

(async) getWaterlog(resolutionopt, periodopt) → {Promise.<waterLog>}

Get historic water usage data. Note: Only available for LS120 and with Belgian meters.

Parameters:
Name Type Attributes Default Description
resolution string <optional>
'Days'

The interval of logdata in: T(enminutes), H(ours) or D(ays)

period number <optional>
this month

The period that can be selected for historic data depends on the selected resolution:

  • Tenminutes: period 1 (this day) - 30 (30 days ago)
  • Hours: period 1 (this day) - 70 (70 days ago)
  • Days: period 1 (January) - 12 (December)
Returns:
Type
Promise.<waterLog>

(async) login(optionsopt) → {Promise.<Youless.loggedIn>}

Login to the device. Passing sessionOptions will override the previous settings. If host is not set, login will try to auto discover it.

Parameters:
Name Type Attributes Description
options sessionOptions <optional>

configurable session options

Returns:

The loggedIn state.

Type
Promise.<Youless.loggedIn>

(async) reboot() → {Promise.<finished>}

Reboot the youless device. NOTE: Only works for LS120

Returns:
Type
Promise.<finished>

(async) setLuminace(value) → {Promise.<finished>}

Set the luminace of the optical sensor

Parameters:
Name Type Description
value number

0 = auto, 2 = low, 3 = high

Returns:
Type
Promise.<finished>

(async) setMeterType(value) → {Promise.<finished>}

Set meter type to D(igital) or A(nalog).

Parameters:
Name Type Description
value string

The meter type A(analog) or D(igital).

Returns:
Type
Promise.<finished>

(async) setPowerCounter(value) → {Promise.<finished>}

Set the Power counter value (in KwH) NOTE: also resets powerPulses to 1000

Parameters:
Name Type Description
value number

the Power counter value (in KwH)

Returns:
Type
Promise.<finished>

(async) setPowerPulses(value) → {Promise.<finished>}

Set the Power pulses per KwH value NOTE: must be performed AFTER setPowerCounter and setS0Pulses NOTE: will be automatically overwritten by P1 net value

Parameters:
Name Type Description
value number

the number of pules per KwH, e.g. 1000

Returns:
Type
Promise.<finished>

(async) setS0Counter(value) → {Promise.<finished>}

Set the S0 counter value.

Parameters:
Name Type Description
value number

set the S0 counter value (in KwH)

Returns:
Type
Promise.<finished>

(async) setS0Pulses(value) → {Promise.<finished>}

Set the S0 pulses per KwH value NOTE: also resets powerPulses to 1000

Parameters:
Name Type Description
value number

the number of pules per KwH, e.g. 1000

Returns:
Type
Promise.<finished>

(async) setS0Timeout(value) → {Promise.<finished>}

Set the Power pulses timeout

Parameters:
Name Type Description
value number

the timeout in minutes. 0 = 30s.

Returns:
Type
Promise.<finished>

(async) syncTime() → {Promise.<dateTime>}

Synchronize the device time with the internet

Returns:
Type
Promise.<dateTime>