Kyvis Labs API Client Module

The module stores the image on the server and provides a URL as a tag you can use:

image

Use that image directly in the image component in Perspective or Vision.

1 Like

Thanks for your previous response. I am now trying to connect to my unifi network cloud key controller. I am using unifi_network example YAML. My cloud key does not have a certificate so when I connect with Firefox I get a certificate error. I have entered my user name, password and URL into the variables. Both functions are getting the error "com.kyvislabs.api.client.common.exceptions.APIException: SessionAuth: Failed login". I also have the unified controller software running on a raspberry PI and I get the same error. I have verified my username and password by logging in to the controllers with FireFox. Am I required to have a certificate installed for your API to work?
Thanks

Not if the following is in your YAML configuration:

httpsVerification: false

Do you have that?

Yes. I am using your example from GitHub.
Thanks,
Tom

Ok, so you will need to turn on the logger for your API. Go into the status page of the Gateway and select the Logs on the left. Click on the settings button and enter in the name of your API "unifi". Turn on the top most logger to "TRACE" and try it again. Hopefully we can see the reason why it is failing from the logs.

Below is what I saw. I verified the username and password but removed from info below. I also removed my IP address but is correct.
Hope this helps
Tom

SessionAuth 02Mar2023 17:16:26
Failed authentication (401): {meta:{rc:error,msg:api.err.LoginRequired},data:}
SessionAuth 02Mar2023 17:16:26
Failed authentication (401): {meta:{rc:error,msg:api.err.LoginRequired},data:}
SessionAuth 02Mar2023 17:16:26
Unifi request [method=POST, url=https://XXX.XXX.XXX:8443/api/auth/login, headers=none, params=none, body={username=, password=**, remember=true}]
SessionAuth 02Mar2023 17:16:26
Unifi request [method=POST, url=https://xxx.xxx.xxx.xxx:8443/api/auth/login, headers=none, params=none, body={username=****, password=********, remember=true}]

It looks like authentication is failing. Maybe double check your credentials?

I opened a browser to my https://xxx.xxx.xxx.xxx:8443 which I pasted directly from the SessionAuth in the log. This brought up the Unifi Login Menu. I copied the username and password from the SessionAuth log. I was successfully logged into the CloudKey controller which is running version 7.2.92. I then used Postman to test login. I found that I had to use https://xxx.xxx.xxx.xxx:8443/api/login with body of {"username":"dummy","password":"dummy","remember":"true"} to get logged in. I don't know if Postman is different but the format but this doesn't match what was in the log file for SessionAuth. When I used /api/auth/login in Postman, I got the message.
{
"meta": {
"rc": "error",
"msg": "api.err.NoSiteContext"
},
"data":
}

I changed the yaml file to use /api/login and now get the following error.

SessionAuth 03Mar2023 16:10:48
Failed authentication (500): <!doctype html>HTTP Status 500 – Internal Server Errorbody {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}

HTTP Status 500 – Internal Server Error

Hopefully this information might help.
Thanks,
Tom

Which controller are you using? If I remember correctly, there is a difference in the paths if you are using older cloud keys vs the newer one vs the UDM stuff.

I am using an older Cloudkey(G1) and I am also running the cloud controller software on a RaspberryPI and it seems to use the same API calls as my CloudKey. I have also found I had to remove /proxy/network from both the clients and devices function in Postman to get them to work.
Tom

Hi. I had a question. I am going to attempt to integrate an OpenSprinkler system into this module and had a couple of questions.

  1. The API required a password as part of the URL and requires the password to be an MD5 hash. Is that supported?
  2. If I wanted to change that password is that supported with in the module?

This module looks very promising. Definitely going to try it out.

Im looking for a solution that could allow Ignition to authenticate 3rd party shop apps so we can control our authentication thru a single point. Could this module help with this?

I think we could share either tokens our sessions to achieve this goal. Having some trouble getting pointed in the correct direction or perhaps this just isn't feasable? Thank you

  1. Yes. There is support for Basic Auth.
  2. You can change the password the module is sending the api you are calling.

We will need some more information. Do the apps expose an API?

Yes, these are for the most part, web REST api based applications that are leveraging their own authentication system.

The applications we are wanting to integrate with Ignition are standard ASP. Net Core applications.

This module will land values from those APIs into the tag system. The webdev module is probably what you want.

Hey @kyvislabs! I'm having some troubles using action: script on our gateway (8.1.33). I've set both the project and function path (I believe it's supposed to be folder.folder.file.defName, right?). I've set the API log debug levels, and I noticed that in handleResponse (from ScriptAction.java) the logger.debug tries to use two getters, but they return Objects, rather than the Strings contained in those objects. It's possible that the reason behind the failure in the script execution might be the same, but I'm yet to learn the inner workings of the SDK to be sure.

The error I get is this:

com.kyvislabs.api.client.common.exceptions.APIException: Error handling script action
at com.kyvislabs.api.client.gateway.api.functions.actions.actions.ScriptAction.handleResponse(ScriptAction.java:70)
at com.kyvislabs.api.client.gateway.api.functions.Actions.handleResponse(Actions.java:45)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor._execute(FunctionExecutor.java:146)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.execute(FunctionExecutor.java:183)
at com.kyvislabs.api.client.gateway.api.functions.FunctionExecutor.run(FunctionExecutor.java:209)
at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ThrowableCatchingRunnable.run(BasicExecutionEngine.java:544)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File "APIScriptAction", line 1, in AttributeError: 'com.inductiveautomation.ignition.common.script.Pro' object has no attribute 'parseCameraResponse'
at org.python.core.Py.AttributeError(Py.java:178)
at org.python.core.PyObject.noAttributeError(PyObject.java:965)
at org.python.core.PyObject.__getattr__(PyObject.java:959)
at org.python.pycode._pyx3236089.f$0(APIScriptAction:1)
at org.python.pycode._pyx3236089.call_function(APIScriptAction)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1687)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:804)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runCode(ProjectScriptLifecycle.java:843)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:773)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.runCode(ProjectScriptLifecycle.java:834)
at com.kyvislabs.api.client.gateway.api.functions.actions.actions.ScriptAction.handleResponse(ScriptAction.java:68)
... 11 common frames omitted
Caused by: org.python.core.PyException: AttributeError: 'com.inductiveautomation.ignition.common.script.Pro' object has no attribute 'parseCameraResponse'
... 24 common frames omitted

On the debug log that I mentioned:

Handling script action with [project=com.kyvislabs.api.client.gateway.api.ValueString@1386131a, script=com.kyvislabs.api.client.gateway.api.ValueString@36d58cf5]

In case there is more info needed, I'll provide whatever is needed.

There is already auto-documented Api with OpenAPI/Swagger. Is it a plan to support those also?

See example below
https://editor.swagger.io/?url=https://ga4gh.github.io/task-execution-schemas/openapi.yaml

Is there any code examples for setting up or modifying the YAML files for cron or tag triggered events? Looks like most of the example configurations are all setup for timer based polling.

1 Like

Hi,

first of all really nice module, Good Job!

I have a question to setup a post API. Is it somehow possible do
use a Value of a existing Tag in the body?
something like this?

    body:
      type: json
      value: |
          {
            "test_variable" :  "{{Tag | [default]test_tag_to_transfer}}"
          }

Thank you !