arduino / arduino-cloud-cli

GNU Affero General Public License v3.0
16 stars 4 forks source link

Match thing variable_name with dashboard variable_id #128

Closed pennam closed 2 years ago

pennam commented 2 years ago

Motivation

When creating a dashboard variable_id is matched with name instead of variable_name

Change description

Match variable_id with variable_name

Additional Notes

Reviewer checklist

polldo commented 2 years ago

Let me understand: why do you expect a match with VariableName instead of Name ?

Where VariableName is "The sketch variable name of the property". And Name is "The friendly name of the property".

pennam commented 2 years ago

Because is my understandig that the variable_id value of a dashboard contains the VariableName value of the Thing template and not the Name.

Assuming this is your thing template

variables:
    - name: Temperature
      permission: READ_ONLY
      type: FLOAT
      update_parameter: 0
      update_strategy: ON_CHANGE
      variable_name: temperature
    - name: Led
      permission: READ_ONLY
      type: STATUS
      update_parameter: 0
      update_strategy: ON_CHANGE
      variable_name: led

and this your dashboard template

widgets:
- height: 4
  height_mobile: 4
  name: Temperature
  options:
    showThing: true
  type: Value
  variables:
  - thing_id: x-template
    variable_id: temperature
  width: 4
  width_mobile: 4
  x: 4
  x_mobile: 4
  "y": 0
  y_mobile: 0
- height: 4
  height_mobile: 4
  name: Led
  options:
    frameless: false
    mode: Color 2
    showThing: true
  type: LED
  variables:
  - thing_id: x-template
    variable_id: led
  width: 4
  width_mobile: 4
  x: 0
  x_mobile: 0
  "y": 0
  y_mobile: 0

The matching procedure will not work because is trying to mach dashboard variable_id: temperature with thing name:Temperature

polldo commented 2 years ago

Ohh ok, so when a dashboard is extracted the variable_id fields are filled with VariableName. However when they're imported to create a dashboard the field name is used instead.

Right, so to fix the inconsistency we have to decide if we want to use VariableName (as you did) or Name. I don't see problems with your proposal.

Unfortunately all the "templating" part is really confusing and needs to be redesigned.

manchoz commented 2 years ago

Tested and it works.