Skip to content

Conversation

martha-johnston
Copy link
Contributor

add getreadings to movement and power sensor

@martha-johnston martha-johnston added question Further information is requested dependencies Pull requests that update a dependency file and removed question Further information is requested dependencies Pull requests that update a dependency file labels Nov 3, 2023
@martha-johnston martha-johnston marked this pull request as ready for review November 7, 2023 17:17
Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good, but MovementSensorReadings should be completely removed, and not exported by main.ts.

Copy link
Member

@purplenicole730 purplenicole730 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@martha-johnston martha-johnston merged commit 68d6e7f into viamrobotics:main Nov 8, 2023
result[key] = value.toJavaScript();
}
return readings as PowerSensorReadings;
return result;
Copy link
Member

@DTCurrie DTCurrie Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using Record<string, unknown> here instead of the PowerSensorReadings type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I thought PowerSensorReadings was a type we were using before there was an API for powersensor.GetReadings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since sensor did not have that and now sensors and power sensor are using the same api

Copy link
Member

@DTCurrie DTCurrie Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We relied on those types in the RC, so now we see these errors:

Error: Type 'unknown' is not assignable to type 'number | undefined'. (ts)
    const readings = await powerSensorClient.getReadings();
    voltageValue = readings.voltage;
    currentValue = readings.current;


/__w/rdk/rdk/web/frontend/src/components/power-sensor/index.svelte:28:5
Error: Type 'unknown' is not assignable to type 'number | undefined'. (ts)
    voltageValue = readings.voltage;
    currentValue = readings.current;
    powerValue = readings.power;


/__w/rdk/rdk/web/frontend/src/components/power-sensor/index.svelte:29:5
Error: Type 'unknown' is not assignable to type 'number | undefined'. (ts)
    currentValue = readings.current;
    powerValue = readings.power;
  } catch (error) {

With these changes we can no longer rely on the SDK to return us current, voltage, or power as a part of the readings response object. Also we no longer know if those fields exist on the response object, and since they are type to unknown we have no idea if they are numbers, strings, objects, etc...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry I had no idea, are you seeing this issue with movement sensor as well? or is it still working

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't even tested anything out, the RC is failing it's build checks right now with an SDK version bump. These changes are not passing our standard checks.

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

Successfully merging this pull request may close these issues.

3 participants