ivesdebruycker / maxcube

eQ-3 Max! Cube interface
Other
22 stars 23 forks source link

What's the rf_address #8

Open RalphPungaKronbergs opened 8 years ago

RalphPungaKronbergs commented 8 years ago

Hi,

on my way to create a homebridge package for Max! Cube I would like to use maxcube, but I can't figure where I get the 'rf_address' for each device of my Max! setup...

Would appreciate any help!

Cheers Punga

ivesdebruycker commented 8 years ago

If you run following code (change ip according to your setup), you should get a list of all connected devices, including their rf-address:

var MaxCube = require('maxcube');
var myMaxCube = new MaxCube('192.168.1.123', 62910);

myMaxCube.on('connected', function () {
  console.log('Connected');

  myMaxCube.getDeviceStatus().then(function (payload) {
    console.log(payload);
    myMaxCube.close();
  });
});

myMaxCube.on('closed', function () {
  console.log('Connection closed');
});

Output:

Connected
[ { rf_address: '0aa123',
    initialized: true,
    fromCmd: false,
    error: false,
    valid: true,
    mode: 'MANUAL',
    dst_active: true,
    gateway_known: true,
    panel_locked: false,
    link_error: false,
    battery_low: false,
    valve: 0,
    setpoint: 6,
    temp: 0 },
  { rf_address: '0bb123',
    initialized: true,
    fromCmd: false,
    error: false,
    valid: true,
    mode: 'MANUAL',
    dst_active: true,
    gateway_known: true,
    panel_locked: true,
    link_error: false,
    battery_low: false,
    valve: 100,
    setpoint: 30.5,
    temp: 0 } ]
Connection closed
RalphPungaKronbergs commented 8 years ago

Thanks for the reply!

Using your script unfortunately there is not connected state rising, although I use the correct IP and Port - both are working with a PHP script that can read MAX! configuration and when I telnet into the MAX! Cube.

Any idea?

ivesdebruycker commented 8 years ago

There can only be one connection to the MAX! Cube at the same time. If you're connected to the cube via the MAX! application or any other way (e.g. a PHP script), you should exit those and try again.

If there's already a connection, you'll get a timeout:

{ [Error: connect ETIMEDOUT 192.168.1.123:62910]
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '192.168.1.123',
  port: 62910 }
events.js:146
      throw err;
RalphPungaKronbergs commented 8 years ago

The MAX! Application is not running currently.

Got your code running (placed it somewhere else in the homebridge code), but the result is:

/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-commandparser.js:204
    default: deviceType = EQ3MAX_DEV_TYPE_UNKOWN; break;
                          ^

ReferenceError: EQ3MAX_DEV_TYPE_UNKOWN is not defined
    at Object.decodeDevice (/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-commandparser.js:204:27)
    at Object.parseCommandDeviceList (/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-commandparser.js:171:39)
    at Object.parse (/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-commandparser.js:22:37)
    at MaxCubeLowLevel.<anonymous> (/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube.js:33:46)
    at emitOne (events.js:77:13)
    at MaxCubeLowLevel.emit (events.js:169:7)
    at /Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-lowlevel.js:30:14
    at Array.forEach (native)
    at Socket.<anonymous> (/Users/punga/node_modules/homebridge-maxcube/node_modules/maxcube/maxcube-lowlevel.js:26:16)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:531:20)

Does this help to identify the issue?

Oh, it seems like there is a typo in "EQ3MAX_DEV_TYPE_UNKNOWN" on line 204. After fixing, your code works! Great!

Thanks for your help!

ivesdebruycker commented 8 years ago

Yup, that's a bug, fixed in 67c4694, thanks. Seems you have an unrecognized device, mind telling what it is?

RalphPungaKronbergs commented 8 years ago

Sure, it's a MAX! Cube but sold from ELV (www.elv.de), not EQ-3 (although it's absolutely the same). Does this help or do you need some other information?

ivesdebruycker commented 8 years ago

If you could give me the submessage length of this device, that would be helpfull. By temporary changing line 204 in maxcube-commandparser.js to this, it wil print out the length: default: deviceType = EQ3MAX_DEV_TYPE_UNKNOWN; console.log('Submessage Length: ' + payload[0]); break;

RalphPungaKronbergs commented 8 years ago

No problem, the output is: 6

RalphPungaKronbergs commented 8 years ago

Unfortunately I still get an error if trying to set the temperature for an existing device:

maxcube.js:134
  var command = MaxCubeCommandFactory.generateSetTemperatureCommand (rf_address, this.deviceCache[rf_address].room_id, 'MANUAL', degrees);
                                                                                                             ^
TypeError: Cannot read property 'room_id' of undefined

My code is:

          var MaxCubeApi = require('maxcube');   
          deviceId = '12afdd';
           temp = 19;
           var myMaxCube = new MaxCubeApi('192.168.1.31', 62910);

           myMaxCube.on('connected', function () {
          myMaxCube.setTemperature(deviceId, temp).then(function (success) {
                 if (success) {
                    console.log('Temperature set');
                 } else {
                    console.log('Error setting temperature');
                 }
                 myMaxCube.close();
              })
           });         

Do I miss something, like building the device cache first?

BTW: Is it possible to set temp to an wall mounted thermostat? Because the device list shows only { rf_address: '0ee83c' } for a wallthermostat, while the bounded thermostat itself has a more detailed result:

{ rf_address: '12afdd',
    initialized: true,
    fromCmd: false,
    error: false,
    valid: true,
    mode: 'AUTO',
    dst_active: true,
    gateway_known: true,
    panel_locked: false,
    link_error: false,
    battery_low: false,
    valve: 100,
    setpoint: 22.5,
    temp: 0 }

Thanks Ralph

ivesdebruycker commented 7 years ago

Error TypeError: Cannot read property 'room_id' of undefined should be fixed, see #12.

I don't own a wall mounted thermostat, but that should be working after ad9410871e552589ced4786f93936378098fc8c0, see #15.

tobsch commented 7 years ago

@RalphPungaKronbergs Feel free to support: https://github.com/tobsch/homebridge-platform-maxcube

I know it's dirty, just hacked my way through...