#Lots of issues when creating viam modules

1 messages · Page 1 of 1 (latest)

pseudo orchid
#

Hello, i'm attempting to make an Artificial Intelligence assistant using my Raspberry pi 4B for my school project. And using sources online, I came across viam. I saw someone else use it, and saw it worked good. Now, i'm attempting to add my own modules to the viam platform, but I keep running into issues like:
- rdk.resource_manager.rdk:component:sensor/hcsr04   resource/graph_node.go:308   resource build error: unknown resource type: API rdk:component:sensor with model wootter:sensor:hcsr04 not registered   resource rdk:component:sensor/hcsr04  model wootter:sensor:hcsr04
- rdk.resource_manager.rdk:component:sensor/hcsr04   resource/graph_node.go:308   Message logged 18 times in past 1m0s: resource build error: unknown resource type: API rdk:component:sensor with model wootter:sensor:hcsr04 not registered   resource rdk:component:sensor/hcsr04  model wootter:sensor:hcsr04

I first started with over 8 of these errors, and slimmed it down to these 2. But after countless days and hours i'm starting to lose hope. I don't know where it's going wrong, how to localize the issue or how to fix it. After consulting with the viam AI assistant, it redirected me to here.

I'm using this github repo: https://github.com/Wootter/viam-HCSR04-module

GitHub

Contribute to Wootter/viam-HCSR04-module development by creating an account on GitHub.

tawdry acorn
pseudo orchid
tawdry acorn
#

Are you seeing this same error for your other modules as well?

pseudo orchid
#

More or less the same yeah, mainly seeing this one come back:

rdk.resource_manager.rdk:component:sensor/dht22_sensor   resource/graph_node.go:308   resource build error: unknown resource type: API rdk:component:sensor with model wootter:sensor:dht22 not registered   resource rdk:component:sensor/dht22_sensor  model wootter:sensor:dht22

tawdry acorn
#

Can you share your machine configuration JSON when you get a chance?

pseudo orchid
# tawdry acorn Can you share your machine configuration JSON when you get a chance?

{
"components": [
{
"name": "dht22_sensor",
"namespace": "rdk",
"type": "sensor",
"model": "wootter:sensor:dht22",
"attributes": {
"pin": 23
},
"depends_on": [
"module/wootter:dht22-sensor"
]
}
],
"modules": [
{
"type": "registry",
"name": "wootter_dht22",
"module_id": "wootter:dht22-sensor",
"version": "latest",
"model": "wootter:dht22"
}
]
}

tawdry acorn
#

Are there any other errors in the Logs tab for your machine or under the module card's Error Logs panel? I just tried to install the DHT22 module on a Pi and ran into some errors during setup, which can cause the module to fail to start and lead to that "unknown resource" error.

pseudo orchid
tawdry acorn
#

Yes, the fix for that should be to replace SUBTYPE with API in your code:

Registry.register_resource_creator(Sensor.API, hcsr04.MODEL, ResourceCreatorRegistration(hcsr04.new, hcsr04.validate))

I see you did something else in your code.

pseudo orchid
tawdry acorn
#

Did you generate the initial module using the Viam CLI? Or did you use some other reference?

pseudo orchid
tawdry acorn
#

Apologies for the confusion. I meant when you got started creating the module, did you use the Viam CLI (https://docs.viam.com/dev/tools/cli/) and run viam module generate to setup the initial structure of the codebase? Or did you reference something else?

Viam Documentation

Manage and control your machines from the command line.

pseudo orchid
tawdry acorn
#

Did changing SUBTYPE to API resolve the "unknown resource" error for your module?

pseudo orchid
tawdry acorn
#

In your commit, I see you made that change in only one file. It appears you have multuple files (main.py, init.py) also used to reference SUBTYPE and should use API now.

pseudo orchid
#

Did ctrl + f on each file for SUBTYPE, might've not done so correctly, i'll be sure to fix that. Thanks for finding that

#

I have to continue this another time, but I appreciate your help. It's getting me closer to a result 🙏

tawdry acorn
#

Happy to help. Best of luck on your project!

pseudo orchid
tawdry acorn
#

Yes, you can use the TypeScript SDK to get that sensor data and display it on a web site

tawdry acorn
#

@pseudo orchid would you mind if I reach out over email to get feedback on your experience with modules?