Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device.getCapabilityOptions(capabilityId: string) fails with Invalid capability #296

Open
oh2th opened this issue Mar 22, 2023 · 5 comments

Comments

@oh2th
Copy link

oh2th commented Mar 22, 2023

With a custom capability "current_limit.json":

{
  "type": "number",
  "title": {
    "en": "Current Limit",
    "nl": "Stroom limiet",
    "de": "Stromgrenze",
    "fr": "Limite de courant"
  },
  "hint": {
    "en": "Current limit in amperes as set by the user.",
    "nl": "Stroomlimiet in ampère zoals ingesteld door de gebruiker.",
    "de": "Stromgrenze in Ampere, wie vom Benutzer eingestellt.",
    "fr": "Limite de courant en ampères comme défini par l'utilisateur."
  },
  "getable": true,
  "setable": false,
  "min": 6,
  "max": 32,
  "step": 1,
  "units": {
    "en": "A"
  },
  "icon": "./assets/ammeter.svg",
  "insights": true
}
      const currentLimitOpts = await this.getCapabilityOptions('current_limit');

fails with Invalid capability "current_limit" on Homey Pro 2023 even thou there is options in the definition json. This works fine on previous Homey Pros.

Now if I add to the driver.compose.json:

  "capabilitiesOptions": {
    "current_limit": {
      "max": 32
    }
  }

The code starts working on Homey Pro 2023 also. Is this a bug?

@WeeJeWel
Copy link

Can you share the result of Homey.devices.getDevice({ id: '...' }) where ... is your device's ID on the Web API Playground?

@oh2th
Copy link
Author

oh2th commented Mar 22, 2023

This on a Homey Pro 2023 (10.0.0-rc.62)

{
  "id": "520d681d-544e-45a8-bae7-dcdc704f0952",
  "driverId": "homey:app:com.go-e.charger:go-eCharger_V4",
  "driverUri": "homey:app:com.go-e.charger",
  "ownerUri": "homey:app:com.go-e.charger",
  "name": "go-eCharger 201397",
  "note": null,
  "zone": "b5e9e303-34ad-49d5-97d9-bc99f6b685a1",
  "data": {
    "id": "201397"
  },
  "icon": null,
  "iconOverride": null,
  "iconObj": {
    "id": "19096264e98e7ba8baeb7c4be1f266b4",
    "url": "/api/icon/b046da54-f02d-472e-b121-77d6494e11b2"
  },
  "class": "socket",
  "virtualClass": null,
  "capabilities": [
    "meter_power",
    "meter_power.session",
    "measure_power",
    "measure_current",
    "measure_voltage",
    "measure_temperature",
    "measure_temperature.charge_port",
    "cable_limit",
    "current_limit",
    "current_max",
    "status",
    "button_single_phase",
    "button_three_phase",
    "num_phases",
    "is_allowed",
    "is_charging",
    "is_connected",
    "alarm_device"
  ],
  "capabilitiesObj": {
    "alarm_device": {
      "id": "alarm_device",
      "type": "boolean",
      "iconObj": {
        "id": "8fea57c6eebd7e83e2726906ac19b9a2",
        "url": "/api/icon/ba2ae95a-8b6c-43de-9068-b716892316a7"
      },
      "title": "Device Error",
      "getable": true,
      "setable": false,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": false,
      "lastUpdated": 1679472149543
    },
    "is_connected": {
      "id": "is_connected",
      "type": "boolean",
      "iconObj": null,
      "title": "Car connected",
      "getable": true,
      "setable": false,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": false,
      "lastUpdated": 1679472149809
    },
    "is_charging": {
      "id": "is_charging",
      "type": "boolean",
      "iconObj": null,
      "title": "Car charging",
      "getable": true,
      "setable": false,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": false,
      "lastUpdated": 1679472149880
    },
    "is_allowed": {
      "id": "is_allowed",
      "type": "boolean",
      "iconObj": {
        "id": "f69ac1091c558b39d4700cf4d1ee0566",
        "url": "/api/icon/61a6fd62-90a1-40b1-82cc-d21cf9b0305f"
      },
      "title": "Charging Allowed",
      "getable": true,
      "setable": true,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": false,
      "lastUpdated": 1679472149233
    },
    "num_phases": {
      "id": "num_phases",
      "type": "enum",
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/api/icon/2bb97222-7eda-42fc-8636-5ac1f0569f48"
      },
      "title": "Charging phases",
      "getable": true,
      "setable": true,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "values": [
        {
          "id": "1",
          "title": "1 phase"
        },
        {
          "id": "3",
          "title": "3 phases"
        }
      ],
      "value": "3",
      "lastUpdated": 1679472149375
    },
    "button_three_phase": {
      "id": "button_three_phase",
      "type": "boolean",
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/api/icon/693b4870-2f5c-4267-88ad-a4947cfdb51e"
      },
      "title": "Three Phase Charging",
      "getable": true,
      "setable": true,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": true,
      "lastUpdated": 1679472149338
    },
    "button_single_phase": {
      "id": "button_single_phase",
      "type": "boolean",
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/api/icon/bea6445e-9ca5-4af1-b16b-a503b70d9d95"
      },
      "title": "Single Phase Charging",
      "getable": true,
      "setable": true,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "value": false,
      "lastUpdated": 1679472149293
    },
    "status": {
      "id": "status",
      "type": "enum",
      "iconObj": null,
      "title": "Device Status",
      "getable": true,
      "setable": false,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "values": [
        {
          "id": "station_idle",
          "title": "No car connected"
        },
        {
          "id": "car_charging",
          "title": "Charging"
        },
        {
          "id": "station_waiting",
          "title": "Waiting for authentication"
        },
        {
          "id": "car_finished",
          "title": "Charging stopped"
        }
      ],
      "value": "station_idle",
      "lastUpdated": 1679472149758
    },
    "current_max": {
      "id": "current_max",
      "type": "number",
      "iconObj": {
        "id": "cba763350ba0692423e5bcaf1742fe76",
        "url": "/api/icon/127f78fe-f3ba-4540-b428-43f5c4c41158"
      },
      "title": "Maximum Current",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "min": 6,
      "max": 32,
      "step": 1,
      "units": "A",
      "value": 16,
      "lastUpdated": 1679472149503
    },
    "current_limit": {
      "id": "current_limit",
      "type": "number",
      "iconObj": {
        "id": "cba763350ba0692423e5bcaf1742fe76",
        "url": "/api/icon/1ae6dd6b-90d4-450b-b9ef-010d0b9690c6"
      },
      "title": "Current Limit",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "min": 6,
      "max": 16,
      "step": 1,
      "units": "A",
      "value": 16,
      "lastUpdated": 1679472149462
    },
    "cable_limit": {
      "id": "cable_limit",
      "type": "number",
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/api/icon/7e963705-e219-4f6b-88d8-fd0276ce1d70"
      },
      "title": "Type-2 Cable Ampere",
      "getable": true,
      "setable": false,
      "insights": false,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "min": 0,
      "max": 32,
      "step": 1,
      "units": "A",
      "value": 20,
      "lastUpdated": 1679472149416
    },
    "measure_temperature.charge_port": {
      "id": "measure_temperature.charge_port",
      "type": "number",
      "iconObj": null,
      "title": "Port Temperature",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "min": -50,
      "max": 50,
      "units": "C",
      "decimals": 2,
      "value": 13.5,
      "lastUpdated": 1679505244513
    },
    "measure_temperature": {
      "id": "measure_temperature",
      "type": "number",
      "iconObj": null,
      "title": "Temperature",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "°C",
      "decimals": 2,
      "value": 8.5,
      "lastUpdated": 1679505319854
    },
    "measure_voltage": {
      "id": "measure_voltage",
      "type": "number",
      "iconObj": null,
      "title": "Voltage",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "V",
      "decimals": 2,
      "value": 683.86,
      "lastUpdated": 1679505447894
    },
    "measure_current": {
      "id": "measure_current",
      "type": "number",
      "iconObj": null,
      "title": "Current",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "A",
      "decimals": 2,
      "value": 0,
      "lastUpdated": 1679472148862
    },
    "measure_power": {
      "id": "measure_power",
      "type": "number",
      "iconObj": null,
      "title": "Power",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "W",
      "decimals": 2,
      "value": 0,
      "lastUpdated": 1679472148817
    },
    "meter_power.session": {
      "id": "meter_power.session",
      "type": "number",
      "iconObj": null,
      "title": "Energy Last Session",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "kWh",
      "decimals": 2,
      "value": 38.29,
      "lastUpdated": 1679472149173
    },
    "meter_power": {
      "id": "meter_power",
      "type": "number",
      "iconObj": null,
      "title": "Energy",
      "getable": true,
      "setable": false,
      "insights": true,
      "insightsTitleTrue": null,
      "insightsTitleFalse": null,
      "units": "kWh",
      "decimals": 2,
      "value": 1340.23,
      "lastUpdated": 1679472149110
    }
  },
  "settings": {
    "address": "192.168.4.16",
    "driver": "go-eCharger_V4"
  },
  "settingsObj": true,
  "insights": [
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:meter_power",
      "type": "number",
      "title": "Energy",
      "titleTrue": null,
      "titleFalse": null,
      "units": "kWh",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:meter_power.session",
      "type": "number",
      "title": "Energy Last Session",
      "titleTrue": null,
      "titleFalse": null,
      "units": "kWh",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:measure_current",
      "type": "number",
      "title": "Current",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:measure_voltage",
      "type": "number",
      "title": "Voltage",
      "titleTrue": null,
      "titleFalse": null,
      "units": "V",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:measure_temperature",
      "type": "number",
      "title": "Temperature",
      "titleTrue": null,
      "titleFalse": null,
      "units": "°C",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:measure_temperature.charge_port",
      "type": "number",
      "title": "Port Temperature",
      "titleTrue": null,
      "titleFalse": null,
      "units": "C",
      "decimals": 2
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:current_limit",
      "type": "number",
      "title": "Current Limit",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": null
    },
    {
      "uri": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952",
      "id": "homey:device:520d681d-544e-45a8-bae7-dcdc704f0952:current_max",
      "type": "number",
      "title": "Maximum Current",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": null
    }
  ],
  "flags": [],
  "energy": null,
  "energyObj": {
    "W": 0,
    "batteries": null,
    "cumulative": null,
    "generator": null,
    "approximated": null
  },
  "ui": {
    "quickAction": "is_allowed",
    "components": [
      {
        "id": "toggle",
        "capabilities": [
          "is_allowed"
        ]
      },
      {
        "id": "button",
        "capabilities": [
          "button_single_phase",
          "button_three_phase"
        ]
      },
      {
        "id": "picker",
        "capabilities": [
          "status"
        ]
      },
      {
        "id": "sensor",
        "capabilities": [
          "meter_power",
          "meter_power.session",
          "measure_power",
          "measure_current",
          "measure_voltage",
          "measure_temperature",
          "measure_temperature.charge_port",
          "current_limit",
          "current_max",
          "alarm_device"
        ]
      }
    ],
    "componentsStartAt": 1
  },
  "uiIndicator": "meter_power.session",
  "available": true,
  "unavailableMessage": null,
  "warningMessage": null,
  "ready": true,
  "repair": false,
  "unpair": false,
  "images": [],
  "color": "#0a58a9"
}

@oh2th
Copy link
Author

oh2th commented Mar 22, 2023

And the same app on a Homey Pro 2019

{
  "id": "9c085437-88ac-4245-afae-382639d58aa3",
  "name": "go-eCharger",
  "driverUri": "homey:app:com.go-e.charger",
  "driverId": "go-eCharger_V4",
  "zone": "95090093-deac-4238-afc8-eea64455df3e",
  "zoneName": "autokatos",
  "icon": null,
  "iconObj": {
    "id": "19096264e98e7ba8baeb7c4be1f266b4",
    "url": "/icon/19096264e98e7ba8baeb7c4be1f266b4/icon.svg"
  },
  "iconOverride": null,
  "settings": {
    "address": "192.168.4.16",
    "driver": "go-eCharger_V4"
  },
  "settingsObj": true,
  "class": "other",
  "energy": null,
  "energyObj": {
    "W": 0,
    "batteries": null,
    "cumulative": null,
    "generator": null
  },
  "virtualClass": null,
  "capabilities": [
    "meter_power",
    "measure_power",
    "measure_current",
    "measure_voltage",
    "measure_temperature",
    "measure_temperature.charge_port",
    "current_limit",
    "current_max",
    "status",
    "is_charging",
    "is_connected",
    "alarm_device",
    "cable_limit",
    "meter_power.session",
    "is_allowed",
    "num_phases",
    "button_three_phase",
    "button_single_phase"
  ],
  "capabilitiesObj": {
    "meter_power": {
      "value": 1340.23,
      "lastUpdated": "2023-03-18T09:41:33.661Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Total Energy",
      "desc": null,
      "units": "kWh",
      "id": "meter_power",
      "options": {}
    },
    "measure_power": {
      "value": 0,
      "lastUpdated": "2023-03-18T09:54:21.441Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Power",
      "desc": null,
      "units": "W",
      "min": 0,
      "max": 30000,
      "id": "measure_power",
      "options": {}
    },
    "measure_current": {
      "value": 0,
      "lastUpdated": "2023-03-18T09:54:46.663Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Current",
      "desc": null,
      "units": "A",
      "min": 0,
      "max": 32,
      "id": "measure_current",
      "options": {}
    },
    "measure_voltage": {
      "value": 691.3,
      "lastUpdated": "2023-03-22T15:52:29.892Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Voltage",
      "desc": null,
      "units": "V",
      "min": 0,
      "max": 750,
      "id": "measure_voltage",
      "options": {}
    },
    "measure_temperature": {
      "value": 8,
      "lastUpdated": "2023-03-22T15:51:39.729Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Temperature",
      "desc": null,
      "units": "C",
      "min": -50,
      "max": 50,
      "id": "measure_temperature",
      "options": {}
    },
    "measure_temperature.charge_port": {
      "value": 13.5,
      "lastUpdated": "2023-03-22T15:32:10.916Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Port Temperature",
      "desc": null,
      "units": "C",
      "min": -50,
      "max": 50,
      "id": "measure_temperature.charge_port",
      "options": {
        "type": "number",
        "title": {
          "en": "Port Temperature",
          "nl": "Poort Temperatuur",
          "de": "Port Temperatur",
          "fr": "Température du port"
        },
        "hint:": {
          "en": "The temperature of the charge port.",
          "nl": "De temperatuur van de oplaadpoort.",
          "de": "Die Temperatur des Ladeports.",
          "fr": "La température du port de charge."
        },
        "getable": true,
        "setable": false,
        "units": {
          "en": "C"
        },
        "min": -50,
        "max": 50,
        "insights": true
      }
    },
    "current_limit": {
      "value": 16,
      "lastUpdated": "2023-02-17T11:27:50.012Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Current Limit",
      "desc": null,
      "units": "A",
      "min": 6,
      "max": 16,
      "step": 1,
      "iconObj": {
        "id": "cba763350ba0692423e5bcaf1742fe76",
        "url": "/icon/cba763350ba0692423e5bcaf1742fe76/icon.svg"
      },
      "id": "current_limit",
      "options": {
        "max": 16
      }
    },
    "current_max": {
      "value": 16,
      "lastUpdated": "2022-12-22T07:18:55.437Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Maximum Current",
      "desc": null,
      "units": "A",
      "min": 6,
      "max": 32,
      "step": 1,
      "iconObj": {
        "id": "cba763350ba0692423e5bcaf1742fe76",
        "url": "/icon/cba763350ba0692423e5bcaf1742fe76/icon.svg"
      },
      "id": "current_max",
      "options": {}
    },
    "status": {
      "value": "station_idle",
      "lastUpdated": "2023-03-18T09:54:47.193Z",
      "type": "enum",
      "getable": true,
      "setable": false,
      "title": "Device Status",
      "desc": null,
      "units": null,
      "values": [
        {
          "id": "station_idle",
          "title": "No car connected"
        },
        {
          "id": "car_charging",
          "title": "Charging"
        },
        {
          "id": "station_waiting",
          "title": "Waiting for authentication"
        },
        {
          "id": "car_finished",
          "title": "Charging stopped"
        }
      ],
      "id": "status",
      "options": {}
    },
    "is_charging": {
      "value": false,
      "lastUpdated": "2023-03-18T09:54:47.451Z",
      "type": "boolean",
      "getable": true,
      "setable": false,
      "title": "Car charging",
      "desc": null,
      "units": null,
      "id": "is_charging",
      "options": {}
    },
    "is_connected": {
      "value": false,
      "lastUpdated": "2023-03-18T09:54:47.240Z",
      "type": "boolean",
      "getable": true,
      "setable": false,
      "title": "Car connected",
      "desc": null,
      "units": null,
      "id": "is_connected",
      "options": {}
    },
    "alarm_device": {
      "value": false,
      "lastUpdated": "2022-12-23T05:45:08.299Z",
      "type": "boolean",
      "getable": true,
      "setable": false,
      "title": "Device Error",
      "desc": null,
      "units": null,
      "iconObj": {
        "id": "8fea57c6eebd7e83e2726906ac19b9a2",
        "url": "/icon/8fea57c6eebd7e83e2726906ac19b9a2/icon.svg"
      },
      "id": "alarm_device",
      "options": {}
    },
    "cable_limit": {
      "value": 20,
      "lastUpdated": "2022-12-27T08:26:54.683Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Type-2 Cable Ampere",
      "desc": null,
      "units": "A",
      "min": 0,
      "max": 32,
      "step": 1,
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/icon/c753c6f33b16812e4534535991b5699a/icon.svg"
      },
      "id": "cable_limit",
      "options": {}
    },
    "meter_power.session": {
      "value": 38.29,
      "lastUpdated": "2023-03-18T09:41:33.707Z",
      "type": "number",
      "getable": true,
      "setable": false,
      "title": "Energy Last Session",
      "desc": null,
      "units": "kWh",
      "id": "meter_power.session",
      "options": {
        "type": "number",
        "title": {
          "en": "Energy Last Session",
          "nl": "Energie laatste sessie",
          "de": "Energie letzte Sitzung",
          "fr": "Énergie dernière session"
        },
        "hint:": {
          "en": "Energy (kWh) delivered during last session. Reset automatically when a car is connected.",
          "nl": "Energie (kWh) geleverd tijdens laatste sessie. Reset automatisch wanneer een auto is aangesloten.",
          "de": "Energie (kWh) während der letzten Sitzung geliefert. Wird automatisch zurückgesetzt, wenn ein Auto angeschlossen ist.",
          "fr": "Énergie (kWh) livrée pendant la dernière session. Réinitialisé automatiquement lorsqu'une voiture est connectée."
        },
        "getable": true,
        "setable": false,
        "units": {
          "en": "kWh"
        },
        "insights": true
      }
    },
    "is_allowed": {
      "value": false,
      "lastUpdated": "2023-03-18T09:54:46.919Z",
      "type": "boolean",
      "getable": true,
      "setable": true,
      "title": "Charging Allowed",
      "desc": null,
      "units": null,
      "iconObj": {
        "id": "f69ac1091c558b39d4700cf4d1ee0566",
        "url": "/icon/f69ac1091c558b39d4700cf4d1ee0566/icon.svg"
      },
      "id": "is_allowed",
      "options": {}
    },
    "num_phases": {
      "value": "3",
      "lastUpdated": "2023-02-17T15:47:04.211Z",
      "type": "enum",
      "getable": true,
      "setable": true,
      "title": "Charging phases",
      "desc": null,
      "units": null,
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/icon/c753c6f33b16812e4534535991b5699a/icon.svg"
      },
      "values": [
        {
          "id": "1",
          "title": "1 phase"
        },
        {
          "id": "3",
          "title": "3 phases"
        }
      ],
      "id": "num_phases",
      "options": {}
    },
    "button_three_phase": {
      "value": true,
      "lastUpdated": "2023-02-17T15:47:04.159Z",
      "type": "boolean",
      "getable": true,
      "setable": true,
      "title": "Three Phase Charging",
      "desc": null,
      "units": null,
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/icon/c753c6f33b16812e4534535991b5699a/icon.svg"
      },
      "id": "button_three_phase",
      "options": {}
    },
    "button_single_phase": {
      "value": false,
      "lastUpdated": "2023-02-17T15:47:04.143Z",
      "type": "boolean",
      "getable": true,
      "setable": true,
      "title": "Single Phase Charging",
      "desc": null,
      "units": null,
      "iconObj": {
        "id": "c753c6f33b16812e4534535991b5699a",
        "url": "/icon/c753c6f33b16812e4534535991b5699a/icon.svg"
      },
      "id": "button_single_phase",
      "options": {}
    }
  },
  "flags": [],
  "ui": {
    "quickAction": "is_allowed",
    "components": [
      {
        "id": "toggle",
        "capabilities": [
          "is_allowed"
        ]
      },
      {
        "id": "button",
        "capabilities": [
          "button_three_phase",
          "button_single_phase"
        ]
      },
      {
        "id": "picker",
        "capabilities": [
          "status"
        ]
      },
      {
        "id": "sensor",
        "capabilities": [
          "meter_power",
          "measure_power",
          "measure_current",
          "measure_voltage",
          "measure_temperature",
          "measure_temperature.charge_port",
          "current_limit",
          "current_max",
          "alarm_device",
          "meter_power.session"
        ]
      }
    ],
    "componentsStartAt": 1
  },
  "uiIndicator": "meter_power.session",
  "ready": true,
  "available": true,
  "repair": false,
  "unpair": false,
  "unavailableMessage": null,
  "images": [],
  "insights": [
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "meter_power",
      "type": "number",
      "title": "Total Energy",
      "titleTrue": null,
      "titleFalse": null,
      "units": "kWh",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "measure_power",
      "type": "number",
      "title": "Power",
      "titleTrue": null,
      "titleFalse": null,
      "units": "W",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "measure_current",
      "type": "number",
      "title": "Current",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "measure_voltage",
      "type": "number",
      "title": "Voltage",
      "titleTrue": null,
      "titleFalse": null,
      "units": "V",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "measure_temperature",
      "type": "number",
      "title": "Temperature",
      "titleTrue": null,
      "titleFalse": null,
      "units": "C",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "measure_temperature.charge_port",
      "type": "number",
      "title": "Port Temperature",
      "titleTrue": null,
      "titleFalse": null,
      "units": "C",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "current_limit",
      "type": "number",
      "title": "Current Limit",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "current_max",
      "type": "number",
      "title": "Maximum Current",
      "titleTrue": null,
      "titleFalse": null,
      "units": "A",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "meter_power.session",
      "type": "number",
      "title": "Energy Last Session",
      "titleTrue": null,
      "titleFalse": null,
      "units": "kWh",
      "decimals": null
    },
    {
      "uri": "homey:device:9c085437-88ac-4245-afae-382639d58aa3",
      "id": "energy_power",
      "type": "number",
      "title": "Power usage",
      "units": "W",
      "decimals": 2
    }
  ],
  "color": "#0a58a9",
  "data": {
    "id": "201397"
  }
}

@ricott
Copy link

ricott commented Mar 22, 2023

Interesting finding regarding capabilitiesOptions, works as a fix for me as well. Otherwise, I have the same issue with my custom capabilities in the Easee app. Just setting max in the custom capability json doesn't work. Trying to read the max value (getCapabilityOptions('target_circuit_current').max) fails with a capability not found error. Assigning a value to the capability works fine though.

@oh2th
Copy link
Author

oh2th commented Mar 23, 2023

Some more information on this. Strangely this happens only on a new device, if the capabilityOptions for max value is not predefined in driver.compose.json.

Exact error is:

2023-03-23T04:29:38.835Z [log] [ManagerDrivers] [Driver:go-eCharger_V3] [Device:a0219942-2779-4924-bf03-3f790ea9ef59] Error: Invalid Capability: current_limit
    at goeChargerDevice.getCapabilityOptions (/node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:592:25)
    at goeChargerDevice.setCapabilityValues (/app/drivers/main-device.js:219:43)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async goeChargerDevice.onInit (/app/drivers/main-device.js:25:5)
    at async goeChargerDevice._onInit (/node_modules/@athombv/homey-apps-sdk-v3/lib/Device.js:148:7)

After adding:

    "current_limit": {
      "max": 32
    },

to the current_limit capability the error goes away and the device works fine.
With the code in place and adding a new device, there is no issues.

And finally, with the device already configured and removing the code from device.compose.json, the device continues to work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants