# Energy

## Overview

The Link supports an Energy Monitor device (LW600) which is able to output the current energy readings from the live feed it is clamped around and communicate this to the Link. The Energy Monitor is the only LightwaveRF peripheral which is able to link to the Lightwave Link and but not receive RF communication. It is a unidirectional device but in an opposite way from the lighting and power products in that it can transmit RF but is unable to receive RF.

The Energy Monitor outputs its readings every 15 seconds to the Link. The Link will output this information as a broadcast when received and contains two values. The current use, which is the average energy consumption in a watts over the previous 15 seconds, and the total use today, which is the total energy used since midnight of the Links time in watt-hours.

The current usage will average the information

Linking a heating/energy device is done differently from the linking of a lighting power device. The heating/energy devices have linking information stored in themselves, as well as the Link storing information about the devices product type and serial.

The Link is able to connect to up to 8 energy devices, though it shares the same space with heating devices, so if there many heating devices linked, this number will be fewer if over 72 heating devices have been added

To link an Energy Monitor, the Link must first enter linking mode. To send the Link into linking mode, the client should choose the appropriate slot number they want to assign to the device (1 to 80) and send the below command:

!R_F*L

where _ is the slot number chosen.

Note
Despite the command beginning with R, this is not related to lighting/power/moods or any room control. Linking a device to R1, then sending !R1Fa (Room 1 All Off) would not affect the Energy Monitor

Once the command has been sent and the Link has given the OK response, then the user would be able to place their peripheral into linking mode for it to connect to the Link. A successful link will have the Link output:

*!{
"trans":123,
"mac":"XX:XX:XX",
"time":1420070400,
"pkt":"868R",
"prod":"pwrMtr",
"serial":"ABC123",
"room":1,
"pairType":"product",
"class":"",
"msg":"success"
}

where:

Name Value(s) Description
trans 1-4294967295 Transaction number of the JSON packet. Increments every transaction
time 1420070400 Timestamp of the transaction in a local UNIX time (i.e if Link is set to UTC+2, this time will be UNIX + (3600*2)
pkt 868R This communication is a result of 868MHz radio being received)
prod pwrMtr The type of product that has been added is an Energy Monitor (pwrMtr = Power Meter)
serial ABC123 The serial number of the product which has been added
room 0-80 The slot number which the device has been added to
pairType product This link packet is referencing the addition of a new product (as opposed to a local phone/tablet/PC)
class n/a unused
msg success The linking has been successful

To remove a previously added heating/energy device, the process is similar to linking.

To unlink a device, the client should choose the appropriate slot number they want to remove from the Link (1 to 80) and send the below command:

!R_F*xU

where _ is the slot number chosen.

The peripheral does not need to be placed into linking mode for this as the Link unit will remove the pairing in itself and will no longer output any data the peripheral broadcasts out.

*!{
"trans":123,
"mac":"XX:XX:XX",
"time":1420070400,
"pkt":"868R",
"room":1,
"pairType":"product",
"class":"",
"msg":"success"
}

where:

Name Value(s) Description
trans 1-4294967295 Transaction number of the JSON packet. Increments every transaction
time 1420070400 Timestamp of the transaction in a local UNIX time (i.e if Link is set to UTC+2, this time will be UNIX + (3600*2)
pkt 868R This communication is a result of 868MHz radio being received (in this instance, this is incorrect)
room 0-80 The slot number which the device has been added to
pairType product This unlink packet is referencing a product which is being removed
class n/a unused
msg success The unlinking has been successful

## Communication

Every time the Link receives a communication from an Energy Monitor, the Link will output the following JSON:

*!{
"trans":528,
"mac":"XX:XX:XX",
"time":1480314257,
"pkt":"868R",
"fn":"meterData",
"prod":"pwrMtr",
"serial":"ABC123",
"type":"energy",
"cUse":276,
"todUse":324
}

where the first three values are the same as other packets, and the following are:

Name Value(s) Description
fn meterData This packet is a contains data from an energy meter
prod pwrMtr The product which is outputting the radio is an Energy Monitor
serial ABC123 The serial number of the device which is outputting radio
type energy The packet contains energy information
cUse 123 The current use that the Energy Monitor is detecting in Watts
todUse 1002 The Todays Usage. This is the amount of usage that has been detected all day in Watt-Hours

Additionally, it is also possible to obtain the current record for the devices stored in the Link to understand how many are currently stored, and what the IDs of them are, and what type of device is stored in each slot. This is only for heating and energy devices.

The devices are stored in an internal table of 80 rows, and you can interrogate which rows in the table have been used by sending the command @R. The Link will then respond with:

*!{
"trans":36409,
"mac":"XX:XX:XX",
"time":1420070400,
"pkt":"room",
"fn":"summary",
"stat0":7,
"stat1":0,
"stat2":0,
"stat3":0,
"stat4":0,
"stat5":0,
"stat6":0,
"stat7":0,
"stat8":0,
"stat9":0
}

where the first three values are the same, and the following are:

Name Value(s) Description
pkt room
fn summary This packet is a summary of the Room details
stat0 255 Convert this to binary to find out which slots are in use for slots 1-8
stat1 255 Convert this to binary to find out which slots are in use for slots 9-16
stat2 255 Convert this to binary to find out which slots are in use for slots 17-24
stat3 255 Convert this to binary to find out which slots are in use for slots 25-32
stat4 255 Convert this to binary to find out which slots are in use for slots 33-40
stat5 255 Convert this to binary to find out which slots are in use for slots 41-48
stat6 255 Convert this to binary to find out which slots are in use for slots 49-56
stat7 255 Convert this to binary to find out which slots are in use for slots 57-64
stat8 255 Convert this to binary to find out which slots are in use for slots 65-72
stat9 255 Convert this to binary to find out which slots are in use for slots 73-80

To identify which slots are used, you will need to turn the value in statX to a binary format, with the least significant bit (LSB) being the value at the right.

Examples:
stat0 - 00000001 would indicate that the only device slot in use between 1-8 would be in slot 1.
stat0 - 00000011 would indicate that the device slots in use between 1-8 are in slots 1 & 2.
stat0 - 00000100 would indicate that the only device slot in use between 1-8 would be in slot 3.
stat1 - 00000001 would indicate that the only device slot in use between 9-16 would be in slot 9.
stat2 - 00000011 would indicate that the device slots in use between 17-24 are in slots 17 & 18.
stat3 - 10000001 would indicate that the device slots in use between 25-32 are in slots 25 & 32.

For example, if the value is 21, then this converts to binary of 00010101, In the case of this, the slots in use are 1, 3 and 5.

With this information, it is then possible to check the information of the device in each slot by sending @?R_ where _ is the number of slot you’d like to check. @?R1, @?R2, @?R3@?R80, for example. The Link will then respond with:

*!{
"trans":160,
"mac":"XX:XX:XX",
"time":1420070400,
"pkt":"room",
"room":"1",
"serial":"123ABC",
"prod":"pwrMtr"
}

where:

Name Value(s) Description
trans 1-4294967295 Transaction number of the JSON packet. Increments every transaction
time 1420070400 Timestamp of the transaction in a local UNIX time (i.e if Link is set to UTC+2, this time will be UNIX + (3600*2)
pkt room This JSON packet output relates to heating & energy devices
prod valve, electr, tmr1ch, pwrMtr The type of product that is in this slot
If you check a slot which has no device stored in it using @?R_, then the Link will then respond with:
123,ERR,5,"Slot is empty"