Using homebrew driver, discovered devices unusable for 20 mins

Hi all,

I’m new to Lua and writing edge drivers (although a professional developer otherwise) and have taken a stab at writing one to control a Pecron solar generator, since the official android app is pretty poor and doesn’t allow much automation.

I plan to set up automation to do peak shaving using the battery, charging off peak/solar and using during peak pricing.

I’ve got my driver mostly functional, it does LAN discovery and can read various properties (power in/out, battery%, temp etc) and control ac/dc output enable.

However the biggest issue I’ve been unable to overcome is that using the smartthings android app, when a device is discovered and the device tile appears, clicking on it just pops us a “Loading” toast message, the device details page doesn’t appear.

If I wait about 20 mins after discovery, clicking it works fine.

I assume I’m missing something in the device properties and there’s some sort of timeout period happening, but despite a lot of experimentation and googling I’ve been unable to resolve it.

It’s not the end of the world since it works fine after that startup period, but it’d be nice to fix it, especially during testing changes when I need to rediscover frequently.

Anyone got any suggestions?

Thanks,

John

Hi, @winfij
I’ve seen that before, but not constantly. And, based on your description, this happens every time you discover the device, correct?
So, after the 20 minutes you mention, you don’t get the error again even if you re-open the app, right?

Can you share your profile’s definition so I can test the same config on my side and check if I get the same error, please?

Hiya,

Yep - if I delete the device and rediscover, I get the same thing every time.

Works fine after that initial problem period.

The odd thing is that the device is working fine during that period - on the device tile I can see the correct battery charge level being displayed, I just can’t open the detail panel.

Here’s the profile’s xml file content:

name: pecron.power-station.v12
components:
  - id: main
    capabilities:
      - id: battery
        version: 1
      - id: powerMeter
        version: 1
      - id: temperatureMeasurement
        version: 1
      - id: voltageMeasurement
        version: 1
      - id: currentMeasurement
        version: 1
      - id: refresh
        version: 1
    categories:
      - name: Battery
  - id: ac_out
    capabilities:
      - id: switch
        version: 1
      - id: powerMeter
        version: 1
  - id: battery_level
    capabilities:
      - id: relativeHumidityMeasurement
        version: 1
  - id: dc_out
    capabilities:
      - id: switch
        version: 1
      - id: powerMeter
        version: 1
  - id: ac_in
    capabilities:
      - id: powerMeter
        version: 1
  - id: dc_in
    capabilities:
      - id: powerMeter
        version: 1
preferences:
  - title: LAN IP Address
    name: lanIp
    description: Pecron device LAN IPv4 address
    required: false
    preferenceType: string
    definition:
      stringType: text
      default: ''
  - title: Auth Key (Base64)
    name: authKey
    description: Device auth key in base64 (from pecron-monitor setup)
    required: false
    preferenceType: string
    definition:
      stringType: password
      default: ''
  - title: Poll Interval Seconds
    name: pollInterval
    description: Telemetry polling interval
    required: true
    preferenceType: integer
    definition:
      minimum: 5
      maximum: 300
      default: 30
  - title: Enable Debug Logging
    name: debugLogs
    description: Verbose protocol logs
    required: true
    preferenceType: boolean
    definition:
      default: false
  - title: Verify Auth Key On Save
    name: verifyAuthOnSave
    description: Attempt login handshake when preferences change
    required: true
    preferenceType: boolean
    definition:
      default: true

Hi, @winfij
Thank you for this info.
It’s weird, I could open the detail view without issues. I thought it could be related to the plugin not being able to load something in your configuration.
But unless you’re setting strange values for the capabilities, I’m not sure that’s the issue.
Since I’m not able to reproduce, please help me collect this info:

  1. Reinstall the device
  2. Start recording your screen before clicking on it. Then try to open it so we can see what the app tries to do and the final error.
  3. Then, collect the app logs:
  1. Open support access to your account