Rheem EcoNet Integration maintained by Kris Linquist

Here's a code snippet for you:

// Stream data from Rheem hybrid water heaters.
// Run "npm install async-mqtt axios" to install dependencies
// Then execute via "node streamWaterHeaterData.js"

const axios = require('axios')
const MQTT = require("async-mqtt");

const rheem_username = '';
const rheem_password = '';

//To obtain these credentials, connect to your water heater's wifi and go to https://192.168.10.1/cred

const rheem_deviceName = '';
const rheem_activeKey = '';


const rheem_systemKey = 'e2e699cb0bb0bbb88fc8858cb5a401';
const rheem_systemSecret = 'E2E699CB0BE6C6FADDB1B0BC9A20';

(async function () {
    console.log('Getting auth token')
 
    let user = await axios.post('https://rheem.clearblade.com/api/v/1/user/auth', {
        email: rheem_username,
        password: rheem_password
    }, {
        headers: {
            'ClearBlade-SystemKey': rheem_systemKey,
            'ClearBlade-SystemSecret': rheem_systemSecret,
            'Content-Type': 'application/json'
        }
    })

    console.log('got user token, getting location')


    let location = await axios.post(`https://rheem.clearblade.com/api/v/1/code/${rheem_systemKey}/getLocation`, null, {
        headers: {
            'ClearBlade-UserToken': user.data.user_token,
            'Content-Type': 'application/json',
            'ClearBlade-SystemKey': rheem_systemKey,
            'ClearBlade-SystemSecret': rheem_systemSecret
        }
    })
    
    let mac = location.data.results.locations[0].equiptments[0].mac_address;
    let serialnumber = location.data.results.locations[0].equiptments[0].serial_number;

    let deviceTopic = `device/${mac}/${serialnumber}/4736/reported`

    console.log('got device ID from location, getting device token')

    let auth = await axios.post(`https://rheem.clearblade.com/api/v/2/devices/${rheem_systemKey}/auth`, {
        deviceName: rheem_deviceName,
        activeKey: rheem_activeKey
    })
    console.log('Using token to connect to MQTT')

    const client = await MQTT.connectAsync("mqtt://rheem.clearblade.com", {
        username: auth.data.deviceToken,
        password: 'e2e699cb0bb0bbb88fc8858cb5a401'
    })

    console.log('Conected.')
    try {
        await client.subscribe(deviceTopic)
    } catch (err) {
        console.log('Error subscribing: ' + err)
    }
    client.on('message', function (topic, message) {
        console.log(`Message topic ${topic}`)
        console.log(message.toString())
    })
    client.on('disconnect', function () {
        console.log('disconnected')
    })
})();
1 Like