[APP][Pro&Cloud] Shelly

I have uploaded a new version to Github which should at least fix the error shown in the CLI log. Could you try re-adding the Shelly2 again.

Yes, Homey should now also know which percentage the blinds are at even when it’s controlled by the Shelly app or manually.

@Phuturist

Tested new version. Can’t add device yet.

log:

2018-12-29 17:04:05 [log] [ManagerDrivers] [shelly2-rollershutter] [0] current blinds position is 0
(node:19516) UnhandledPromiseRejectionWarning: Error: invalid_capability
at Object. (/opt/homey-client/system/manager/ManagerApps/jsonfns.js:1:1103)
at JSON.parse ()
at Object.jsonToObject (/opt/homey-client/system/manager/ManagerApps/jsonfns.js:1:1001)
at function.e.apply.s.args.map.s (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1401)
at Array.map ()
at HomeyClient._onMessage (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1386)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:762:12)
at _combinedTickCallback (internal/process/next_tick.js:142:11)

I see the possition of blind in the log, and is correct, (is totally closed, now i can’t open the blinds, my wife and son are sleeping)

Just did another commit, hopefully that allows you to pair the device.

@Phuturist, update and same thing. Delete other shelly2 and the log is diferent:

2018-12-29 17:37:01 [log] [ShellyApp] Initializing Shelly App …
testConnection succes
{ type: ‘SHSW-21’,
mac: ‘827D3A5B270D’,
auth: false,
fw: ‘20181228-125308/v1.4.3@083c8385’,
num_outputs: 2,
num_meters: 1,
num_rollers: 1 }
testConnection succes
{ type: ‘SHSW-21’,
mac: ‘CE50E355A57A’,
auth: false,
fw: ‘20181228-125308/v1.4.3@083c8385’,
num_outputs: 2,
num_meters: 1,
num_rollers: 1 }

Really weird. Does not seem to be related to the code changes I have made though. I have not changed anything in pairing of the device. Could you try running it with the following command athom app run --clean. And perhaps first reboot Homey, just to make sure.

Could something be failing in the pairing template? It looks like the code doesn’t reach Homey.addDevice for some reason.

The desktop app has a option “View > Toggle Developer Tools” that shows a JS console.

According to @Eduardo_Rodriguez the developer console did not show any output as well. I’m pretty lost on what this could be. My guess is that there is somehow a duplicate device still registered with the same ID (MAC address of the device) and it therefor can’t add the device. Running it clean might fix that.

@Phuturist

I uninstall shelly app and restart homey. Fresh install and same thing when add a shelly 2 device. Same log whit “athom app run --clean”.

I have 4 shelly 1, and i can add them whitout problems.

I see the video in slow motion and the result when add the device is ok:

added

@robertklep apparently this console shows the same thing that browser console: nothing.

Do you use something like getDevice({ id }) in the driver to check if there’s already a device with that id registered?

@robertklep

I don’t know how to do this. My level of programing is 0.

But if in case there was a repeated id, why the shelly 1 let me add them without problem? Only can’t add a the shelly 2 devices.:roll_eyes:

Don’t worry, I was asking @Phuturist :slight_smile:

1 Like

No, never had to. But seeying that Eduardo sees the ‘Shelly device added succesfully’ message in the pairing wizard indicates that the Homey.addDevice({}) function has been executed succesfully and my inital guess that it might be a duplicate device id seems off anyway. Anything that happens after this function is Homey core. I really have no clue on what could cause this.

I have uploaded some changes that will output something on the browser console (F12 in Chrome) when pairing. Could you check that @Eduardo_Rodriguez .

@Phuturist

In F12 get 2 errors:

invalid_capability VM269:83
null VM269:87

Lines 83 to 87:

      console.log(error);
				$('.shelly-error').show();
				$('.shelly-error-msg').html(error.message || error.toString() );
			}
    console.log(result);
			$('.shelly-test').hide();
			$('.shelly-error').hide();
			$('.shelly-ok').show();

			Homey.done();
		})

In “athom app run” a lot of log is reported:

(node:28582) UnhandledPromiseRejectionWarning: Error: invalid_capability
at Object. (/opt/homey-client/system/manager/ManagerApps/jsonfns.js:1:1103)
at JSON.parse ()
at Object.jsonToObject (/opt/homey-client/system/manager/ManagerApps/jsonfns.js:1:1001)
at function.e.apply.s.args.map.s (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1401)
at Array.map ()
at HomeyClient._onMessage (/opt/homey-client/system/manager/ManagerApps/bootstrap/sdk/v2/lib/HomeyClient.js:1:1386)
at emitTwo (events.js:126:13)
at process.emit (events.js:214:7)
at emit (internal/child_process.js:762:12)
at _combinedTickCallback (internal/process/next_tick.js:142:11)
(node:28582) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:28582) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This code misses a Homey.done(); return; inside the if (error) block.

if (error) {
  $('.shelly-error').show();
  $('.shelly-error-msg').html(error.message || error.toString() );
}
$('.shelly-test').hide();
$('.shelly-error').hide();
$('.shelly-ok').show();

Homey.done();

If there’s an error, .shelly-error is shown, but because there’s no return, it gets hidden again and .shelly-ok is shown.

Well, then my only conclusion is that the API documentation from Athom is incorrect. I’m using a capability called windowcoverings_set which should allow you to set the postion by percentage but this error indicates that it’s not a valid capability. I’ll ask Athom about it.

Thanx, I’ll fix that.

Hi,

I’m wondering if anyone has managed to control Shelly 2 using the built in voice commands in Homey 1.x? (not using Shelly cloud.) When I ask my Shelly 2 to switch off, Homey responds saying “I didn’t find any sockets to turn off”. Is it possible to get this to work?

It would also be nice to “tag” the switch as light so it turns off, as my Fibaro dimmer 2 and Hue lights does, when I ask Homey to turn off all lights or a specific zone. Anyone who has managed to integrate a Shelly 2 relay like that?

If I build a flow with a specific voice command to turn on/off the relay it works fine. But I’m not sure if that is a good solution for a full house. If I can get Shelly to work well with Homey I plan to install this relay behind all my wall switches in the house.

Anyone with experience from Shelly 2 that has any good advice or tips?

Thanks in advance

This should be possible. If you are still on firmware 1.5.x you could try looking at the speech input and output pages to see what Homey actually hears or test the command by typing it in manually.

http://[ip]/manager/speech-input/
http://[ip]/manager/speech-output/

Not sure if it’s possible to change the device class upon pairing but I’ll have a look at it.

Yes, that’s possible (see the VD app for an example).

1 Like

I’ve tried all possible commands that I can think of by looking at the recognized speech command, but no luck. I’ve named my Shelly 2 device to “Lamp 2” in Homey. And for example I tried the command “Turn on Lamp 2” the reply I get is “I can’t find sockets to turn on”.

Has anyone else managed to get this to work?

Does the device have be classified as a “light” for the voice command to work? (I have no idea how this works so please excuse if this is a strange question.)

I think I know what is going on. The Shelly 2 has two relays and I implemented them with a custom capability. Therefor the default onoff capability is not used and the corresponding voice commands wont work either. I’m sorry to say but I have no plans of changing this as that would create other difficulties that are beyond my programming skills. Changing the device class to light probably wont fix this either. Maybe, just maybe when I have a lot of free time I’ll try and find out how to pair each relay as seperate device but dont count on it.