[APP][Pro&Cloud] Shelly

Hmmm, pretty sure I pressed the code format button. But here it goes again.

const shellies = require('shellies')

shellies.on('discover', device => {
  // a new device has been discovered
  console.log('Discovered device with ID', device.id, 'and type', device.type)

  device.on('change', (prop, newValue, oldValue) => {
    // a property on the device has changed
    console.log(prop, 'changed from', oldValue, 'to', newValue)
  })

  device.on('offline', () => {
    // the device went offline
    console.log('Device with ID', device.id, 'went offline')
  })
})

// start discovering devices and listening for status updates
shellies.start()

Any update on this or do you need some more information?

No, I need time.

Ok no rush, was just curious.
Is it possible to downgrade to a previous version so that I can read them as PM/1L and make them work again?

I wouldnt recommend it, there are too many breaking changes and I cant predict what would happen.

Ok than I’ll wait for a fix. Good luck!

I have updated the debug branch. Can you redownload, run the app and trigger and long and short push about 60 seconds after the app has started.

Here you go.
And something else: when I ran the mentioned procedure with the debug app, my flow was working and it sent me a notification a button was pressed!

2021-02-15 09:59:56 [log] [ShellyApp] Initializing Shelly App ...
2021-02-15 10:00:37 [log] [ShellyApp] Discovered device with ID 84CCA8ADAD68 and type SHSW-L on IP address 192.168.0.53
2021-02-15 10:00:37 [log] [ShellyApp] Discovered device with ID 84CCA8AC9E33 and type SHSW-L on IP address 192.168.0.52
2021-02-15 10:00:37 [log] [ShellyApp] Discovered device with ID 84CCA8AD58B0 and type SHSW-L on IP address 192.168.0.51
2021-02-15 10:00:37 [log] [ShellyApp] Discovered device with ID 84CCA8ACD848 and type SHSW-L on IP address 192.168.0.50
2021-02-15 10:00:59 [log] [ManagerDrivers] [shelly1L] [0] triggering action event for Shelly 1L Keuken and action event shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ACD848
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 1
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: longpush
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ACD848',
  name: 'Shelly 1PM / 1L [192.168.0.50]',
  ip: '192.168.0.50',
  icon: '/drivers/shelly1pm/assets/icon.svg',
  driver: 'shelly1pm',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush', 'longpush' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AD58B0
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 3
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: longpush_2
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AD58B0',
  name: 'Shelly 1L Babykamer',
  ip: '192.168.0.51',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AD58B0
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 1
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: longpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AD58B0',
  name: 'Shelly 1L Babykamer',
  ip: '192.168.0.51',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ADAD68
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 2
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: shortpush_2
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ADAD68',
  name: 'Shelly 1L Gang Plafondlamp',
  ip: '192.168.0.53',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ADAD68
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 2
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: shortpush_2
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ADAD68',
  name: 'Shelly 1L Gang Plafondlamp',
  ip: '192.168.0.53',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 3
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: longpush_2
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AC9E33',
  name: 'Shelly 1L Keuken',
  ip: '192.168.0.52',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: all
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 999
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: Bij elke actie
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'all',
  name: 'Voor elk apparaat',
  icon: '/assets/icon.svg',
  actions: [
    'shortpush_1',
    'longpush_1',
    'shortpush_2',
    'longpush_2',
    'shortpush',
    'longpush'
  ]
}
2021-02-15 10:00:59 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:00:59 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ACD848
2021-02-15 10:00:59 [log] [ShellyApp] args.action.id: 0
2021-02-15 10:00:59 [log] [ShellyApp] state.action: shortpush_1
2021-02-15 10:00:59 [log] [ShellyApp] args.action.name: shortpush
2021-02-15 10:00:59 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ACD848',
  name: 'Shelly 1PM / 1L [192.168.0.50]',
  ip: '192.168.0.50',
  icon: '/drivers/shelly1pm/assets/icon.svg',
  driver: 'shelly1pm',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush', 'longpush' ]
}
2021-02-15 10:01:07 [log] [ManagerDrivers] [shelly1L] [0] triggering action event for Shelly 1L Keuken and action event longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ACD848
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 1
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: longpush
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ACD848',
  name: 'Shelly 1PM / 1L [192.168.0.50]',
  ip: '192.168.0.50',
  icon: '/drivers/shelly1pm/assets/icon.svg',
  driver: 'shelly1pm',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush', 'longpush' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AD58B0
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 3
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: longpush_2
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AD58B0',
  name: 'Shelly 1L Babykamer',
  ip: '192.168.0.51',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AD58B0
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 1
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AD58B0',
  name: 'Shelly 1L Babykamer',
  ip: '192.168.0.51',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ADAD68
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 2
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: shortpush_2
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ADAD68',
  name: 'Shelly 1L Gang Plafondlamp',
  ip: '192.168.0.53',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ADAD68
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 2
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: shortpush_2
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ADAD68',
  name: 'Shelly 1L Gang Plafondlamp',
  ip: '192.168.0.53',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 3
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: longpush_2
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8AC9E33',
  name: 'Shelly 1L Keuken',
  ip: '192.168.0.52',
  username: 'TheFops',
  password: 'AWv4nVnc67LjPjs',
  icon: '/drivers/shelly1L/assets/icon.svg',
  driver: 'shelly1L',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush_1', 'longpush_1', 'shortpush_2', 'longpush_2' ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: all
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 999
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: Bij elke actie
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'all',
  name: 'Voor elk apparaat',
  icon: '/assets/icon.svg',
  actions: [
    'shortpush_1',
    'longpush_1',
    'shortpush_2',
    'longpush_2',
    'shortpush',
    'longpush'
  ]
}
2021-02-15 10:01:07 [log] [ShellyApp] action event triggercard called with:
2021-02-15 10:01:07 [log] [ShellyApp] state.id: shelly1l-84CCA8AC9E33
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly.id: shelly1l-84CCA8ACD848
2021-02-15 10:01:07 [log] [ShellyApp] args.action.id: 0
2021-02-15 10:01:07 [log] [ShellyApp] state.action: longpush_1
2021-02-15 10:01:07 [log] [ShellyApp] args.action.name: shortpush
2021-02-15 10:01:07 [log] [ShellyApp] args.shelly: {
  id: 'shelly1l-84CCA8ACD848',
  name: 'Shelly 1PM / 1L [192.168.0.50]',
  ip: '192.168.0.50',
  icon: '/drivers/shelly1pm/assets/icon.svg',
  driver: 'shelly1pm',
  type: 'SHSW-L',
  main_device: 'none',
  actions: [ 'shortpush', 'longpush' ]
}

Ok, I found the issue and will fix it in the test version.

v3.0.14 - 2021-xx-xx

  • Fixed an issue with the action events for the Shelly 1L

For more information on installing version 3.x see [APP] Shelly - #1097 by Phuturist

1 Like

Thanks, now it’s working. Nice that you fixed it that fast!

I Try again:

C:\shelly>node shellies.js
internal/modules/cjs/loader.js:589
throw err;
^

Error: Cannot find module ‘shellies’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:587:15)
at Function.Module._load (internal/modules/cjs/loader.js:513:25)
at Module.require (internal/modules/cjs/loader.js:643:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\shelly\shellies.js:1:80)
at Module._compile (internal/modules/cjs/loader.js:707:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:718:10)
at Module.load (internal/modules/cjs/loader.js:605:32)
at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
at Function.Module._load (internal/modules/cjs/loader.js:536:3)

Shellies package is intalled:

C:\shelly>npm install -g shellies
C:\Users\edy00\AppData\Roaming\npm\shellies → C:\Users\edy00\AppData\Roaming\npm\node_modules\shellies\bin\shellies

  • shellies@1.3.0
    updated 1 package in 7.138s

I using Node.js 11.1.0 (x64) and npm. What can be wrong?

Perhaps install it locally by doing npm install shellies from the folder where shellies.js is located.

Yeah! Now works!

I have a lot of trafic, i have about 35 shellies. Resuming…

power0 changed from 2292.65 to 2341.93
power0 changed from 169.67 to 169.83
power0 changed from 2341.93 to 2343.03
power0 changed from 169.83 to 169.42
power1 changed from 20.66 to 20.68
relay0 changed from true to false
externalInput0 changed from 1 to 0
externalInput0 changed from 0 to 1

The power0 are Shelly EM and Plug S power meters, and externalinput are the addon reed switch.

I have installed the debug version again, but I keep getting the same errors:

2021-02-16 11:02:58 [log] [ManagerDrivers] [shellyem] [0] TypeError: Cannot read property ‘0’ of undefined
at ShellyEmDevice.initialStateUpdate (/drivers/shellyem/device.js:84:40)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-02-16 11:02:58 [log] [ManagerDrivers] [shellyem] [1] TypeError: Cannot read property ‘1’ of undefined
at ShellyEmDevice.initialStateUpdate (/drivers/shellyem/device.js:84:40)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-02-16 11:02:59 [log] [ManagerDrivers] [shellydw] [0] Shelly Door Window Sensor is probably asleep and disconnectedFetchError: request to http://192.168.1.205/status failed, reason: connect EHOSTUNREACH 192.168.1.205:80

Ok, than it’s not a CoAP thing. I have fixed that Shelly EM error on the debug branch as well now and added more debug logging. Could you try it again.

this is the log:

2021-02-16 13:44:29 [log] [ShellyApp] Initializing Shelly App …
2021-02-16 13:45:20 [log] [ShellyApp] updating the temporary shelly collection
2021-02-16 13:45:20 [log] [ShellyApp] starting CoAP listener, messages should be coming in at this moment for the following devices
2021-02-16 13:45:20 [log] [ShellyApp]
2021-02-16 13:45:47 [log] [ManagerDrivers] [shellydw] [0] Shelly Door Window Sensor is probably asleep and disconnectedFetchError: request to http://192.168.1.205/status failed, reason: connect EHOSTUNREACH 192.168.1.205:80

the shelly em now is online,but only refresh value the firs time. No message when trigger a device.

I really have no clue.

Just to make sure, Homey is on the same LAN as the computer where you tested CoAP through NodeJS?

The only thing I can think of is the number of Shelly devices is slowing down the startup process of the app and the coap listener is started before other stuff has finished. But I would still expect the see some devices discovered eventually. I have added a longer timeout before the coap listener starts in the debug version. Could you test it and leave the app running on the command line for 5 minutes or so.

Yes, homey, all shellies and the computer are in the same lan. Later i will try.

Edit:

test result:

get a lot of detected shellies, like that:

id: 'shelly1-48XXXXX6C',
name: 'Shelly1 [192.168.1.137]',
ip: '192.168.1.137',
username: XXXX
password: XXXX
icon: '/drivers/shelly1/assets/icon.svg',
driver: 'shelly1',
type: 'SHSW-1',
main_device: 'none',
actions: [ 'shortpush', 'longpush' ]

},

And:

getting device shellyem-BXXX4D-channel-0
getting device shellyem-BXXX4D-channel-1

every 5 minutes I receive the message:

[ShellyApp] going to update the shelly collection
getting shellies

Nothing appears when I activate any shelly. If I activate some shelly from homey it updates its status, but if I do it from the physical button this does not happen.

Please show me the entire log.

I send the log by PM

Thanks for your effort!