Thingsboard Gateway REST connector fails to initialize - thingsboard

I'm trying to set up the REST connector for Thingsboard IoT Gateway and getting some errors on initialization. My rest.json config is:
{
"host": "127.0.0.1",
"port": "5000",
"SSL": false,
"mapping": [
{
"endpoint": "/sizerdata",
"HTTPMethods": [
"POST"
],
"security": {
"type": "anonymous"
},
"converter": {
"type": "json",
"deviceNameExpression": "Sizer ${name}",
"deviceTypeExpression": "default",
"attributes": [
{
"type": "string",
"key": "serialNumber",
"value": "${serialNumber}"
}
],
"timeseries": [
{
"type": "integer",
"key": "cupfill",
"value": "${cupfill}"
},
{
"type": "integer",
"key": "packsPerHour",
"value": "${packsPerHour}"
},
{
"type": "integer",
"key": "totalFruitPerMinute",
"value": "${totalFruitPerMinute}"
}
]
}
}
]
}
When I start the thingsboard-gateway service I get the following errors in the logs:
""2021-12-29 13:09:07" - |ERROR| - [rest_connector.py] - rest_connector - run - 152 - web.Application instance initialized with different loop"
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/thingsboard_gateway/connectors/rest/rest_connector.py", line 150, in run
self.__run_server()
File "/usr/lib/python3/dist-packages/thingsboard_gateway/connectors/rest/rest_connector.py", line 143, in __run_server
web.run_app(self._app, host=self.__config['host'], port=self.__config['port'], handle_signals=False,
File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/aiohttp/web.py", line 514, in run_app
loop.run_until_complete(main_task)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/aiohttp/web.py", line 321, in _run_app
await runner.setup()
File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/aiohttp/web_runner.py", line 279, in setup
self._server = await self._make_server()
File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/aiohttp/web_runner.py", line 373, in _make_server
self._app._set_loop(loop)
File "/var/lib/thingsboard_gateway/.local/lib/python3.8/site-packages/aiohttp/web_app.py", line 223, in _set_loop
raise RuntimeError(
RuntimeError: web.Application instance initialized with different loop
I have tried this on an Ubuntu install and a Docker container and I get the same result. Any ideas on why this doesn't work?

It is an issue with aiohttp, it is already fixed in the master branch.
You can use the version from the master branch of the gateway repository or wait for the next release.

Related

How do I configure multiple pattern matchers for a VS Code Task?

I'm trying to setup a Visual Studio Code CMake / Ninja project using GNU_ARM_10_2020-q4-major. With the base problem matcher set to "$gcc" it misses a lot messages and I can't figure out multiple patterns.
The following extract from the build output has two messages (saved to test.txt):
C:/Repos/ProjectN/ProjectN/Dave/Generated/ETH_LWIP/lwip/port/sys_arch.c: In function 'sys_sem_signal':
C:/Repos/ProjectN/ProjectN/Dave/Generated/ETH_LWIP/lwip/port/sys_arch.c:550:14: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
550 | osStatus_t ret;
| ^~~
c:/gnu_arm_10_2020-q4-major/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: c:\repos\ProjectN\gfx-src\include/gfx_drawing.hpp:3203: undefined reference to `gfx::font::operator[](int) const'
The problem matcher (for testing) is set to:
{
"label": "build",
"type": "shell",
"command": "cmd /C type test.txt",
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": {
"fileLocation": "absolute",
"severity": "error",
"pattern": [
{
"regexp": "(.*):(\\d+):(\\d+): (.*): (.*)",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
},
{
"regexp": "(.*ld\\.exe): (.*):(\\d+): (.*)",
"file": 2,
"line": 3,
"message": 4
}
]
},
"group": {
"kind": "build",
"isDefault": true
}
}
The above does not match any lines.
If I remove the first pattern, the seconds works and I see an item in the Problems view. If I remove the second pattern, the first works and again I see an item in the Problems view.
Does anyone know what I'm doing wrong here?

Post HTTP Requests cURL with EmailOctopus

As a marketer, I'm going through the EmailOctopus (email service provider) API docs (https://emailoctopus.com/api-documentation) and have trouble combining multiple requests in one.
Goal: Get all campaign reports for all campaigns exported to a CSV.
Step 1: Get all campaign IDs. This works.
curl GET https://emailoctopus.com/api/1.5/campaigns?api_key={APIKEY}
Step 2: Get the report for a single campaign. This works too.
curl GET https://emailoctopus.com/api/1.5/campaigns/{CAMPAIGNID}/reports/summary?api_key={APIKEY}
Step 3: Combine step 1 and 2 and export to a CSV. No idea how to proceed here.
Output step 1:
{
"data": [
{
"id": "00000000-0000-0000-0000-000000000000",
"status": "SENT",
"name": "Foo",
"subject": "Bar",
"to": [
"00000000-0000-0000-0000-000000000001",
"00000000-0000-0000-0000-000000000002"
],
"from": {
"name": "John Doe",
"email_address": "john.doe#gmail.com"
},
"content": {
"html": "<html>Foo Bar<html>",
"plain_text": "Foo Bar"
},
"created_at": "2019-10-30T13:46:46+00:00",
"sent_at": "2019-10-31T13:46:46+00:00"
},
{
"id": "00000000-0000-0000-0000-000000000003",
"status": "SENT",
"name": "Bar",
"subject": "Foo",
"to": [
"00000000-0000-0000-0000-000000000004",
"00000000-0000-0000-0000-000000000005"
],
"from": {
"name": "Jane Doe",
"email_address": "jane.doe#gmail.com"
},
"content": {
"html": "<html>Bar Foo<html>",
"plain_text": "Bar Foo"
},
"created_at": "2019-11-01T13:46:46+00:00",
"sent_at": "2019-11-02T13:46:46+00:00"
}
],
"paging": {
"next": null,
"previous": null
}
}
Output step 2:
{
"id": "00000000-0000-0000-0000-000000000000",
"sent": 200,
"bounced": {
"soft": 10,
"hard": 5
},
"opened": {
"total": 110,
"unique": 85
},
"clicked": {
"total": 70,
"unique": 65
},
"complained": 50,
"unsubscribed": 25
}
How can I get all campaign reports in one go and exported to a CSV?
May be this URLs be helpful
Merging two json in PHP
How to export to csv file a PHP Array with a button?
https://www.kodingmadesimple.com/2016/12/convert-json-to-csv-php.html

Getting error object field starting or ending with a [.]

While inserting the below document in an Elasticsearch index:
{
"id": "122223334444",
"name": "Mei",
"url": "mei-2019-tamil",
"alternate_urls": [
"mei-2019-tamil",
"sa-baskaran-aishwarya-rajesh-untitled"
],
"type": "Movie",
"poster": "ed3e439b-1ac1-45fe-a915-a5dae60257df",
"poster_url": "//assets.appserver.com/ed3e439b-1ac1-45fe-a915-a5dae60257df",
"alternate_names": [
"Mei",
"SA Baskaran - Aishwarya Rajesh Untitled"
],
"popularity": 0.2,
"info": {
"running_time": 0,
"cpl_types": [
"teaser",
"feature"
],
"has_cpls": true,
"genres": [
"Drama",
"Thriller"
],
"international_release_date": null,
"country_specific_release_dates": {},
"international_film_status": "CS",
"country_specific_film_statuses": {
"IN": "CS",
"CN": "CS",
"": "CS",
"SG": "CS"
},
"country_specific_certifications": {},
"language": "Tamil",
"synopsis": "A thriller film directed by SA Baskaran, starring Aishwarya Rajesh in the lead role.",
"schedules": {
"cities": [],
"countries": []
},
"featured": 0,
"movie_rating": 0,
"cast": [
{
"id": "05ffe715-db60-4947-a45a-99722537571c",
"name": "Aishwarya Rajesh",
"url": "aishwarya-rajesh",
"role": "Actress",
"poster": "65ab15b6-d54a-4965-95d5-38a839cee17d",
"poster_url": "//assets.appserver.com/65ab15b6-d54a-4965-95d5-38a839cee17d",
"type": "Person"
}
],
"crew": [
{
"id": "d9354648-5f48-4bf0-9a00-3de8c4d7a8d0",
"name": "SA Baskaran",
"url": "sa-baskaran",
"role": "Director",
"poster": null,
"poster_url": null,
"type": "Person"
}
]
},
"published": true
}
I'm getting the following Message:
Error: object field starting or ending with a [.] makes object
resolution ambiguous:
However, there is no value that is starting with .
I am clueless as regards which key is causing this issue.
Please help me identify and fix this issue.
ElasticSearch Version: 5.6.14
I am trying to index ES from a rails app using chewy gem.
Values of the JSON could be empty. But if the keys are empty then ES throws an error while indexing. Remove "":{} from the JSON and index again.
Reference: https://discuss.elastic.co/t/object-field-starting-or-ending-with-a-makes-object-resolution-ambiguous/123351

How to directly mount external NFS share/volume in kubernetes(1.10.3)

I am using kubernetes : v1.10.3 , i have one external NFS server which i am able to mount anywhere ( any physical machines). I want to mount this NFS directly to pod/container . I tried but every time i am getting error. don't want to use privileges, kindly help me to fix.
ERROR: MountVolume.SetUp failed for volume "nfs" : mount failed: exit
status 32 Mounting command: systemd-run Mounting arguments:
--description=Kubernetes transient mount for /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs
--scope -- mount -t nfs 10.225.241.137:/stagingfs/alt/ /var/lib/kubelet/pods/d65eb963-68be-11e8-8181-00163eeb9788/volumes/kubernetes.io~nfs/nfs
Output: Running scope as unit run-43393.scope. mount: wrong fs type,
bad option, bad superblock on 10.225.241.137:/stagingfs/alt/, missing
codepage or helper program, or other error (for several filesystems
(e.g. nfs, cifs) you might need a /sbin/mount. helper program)
In some cases useful info is found in syslog - try dmesg | tail or so.
NFS server : mount -t nfs 10.X.X.137:/stagingfs/alt /alt
I added two things for volume here but getting error every time.
first :
"volumeMounts": [
{
"name": "nfs",
"mountPath": "/alt"
}
],
Second :
"volumes": [
{
"name": "nfs",
"nfs": {
"server": "10.X.X.137",
"path": "/stagingfs/alt/"
}
}
],
---------------------complete yaml --------------------------------
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "jboss",
"namespace": "staging",
"selfLink": "/apis/extensions/v1beta1/namespaces/staging/deployments/jboss",
"uid": "6a85e235-68b4-11e8-8181-00163eeb9788",
"resourceVersion": "609891",
"generation": 2,
"creationTimestamp": "2018-06-05T11:34:32Z",
"labels": {
"k8s-app": "jboss"
},
"annotations": {
"deployment.kubernetes.io/revision": "2"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"k8s-app": "jboss"
}
},
"template": {
"metadata": {
"name": "jboss",
"creationTimestamp": null,
"labels": {
"k8s-app": "jboss"
}
},
"spec": {
"volumes": [
{
"name": "nfs",
"nfs": {
"server": "10.X.X.137",
"path": "/stagingfs/alt/"
}
}
],
"containers": [
{
"name": "jboss",
"image": "my.abc.com/alt:7.1_1.1",
"resources": {},
"volumeMounts": [
{
"name": "nfs",
"mountPath": "/alt"
}
],
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent",
"securityContext": {
"privileged": true
}
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": "25%",
"maxSurge": "25%"
}
},
"revisionHistoryLimit": 10,
"progressDeadlineSeconds": 600
},
"status": {
"observedGeneration": 2,
"replicas": 1,
"updatedReplicas": 1,
"readyReplicas": 1,
"availableReplicas": 1,
"conditions": [
{
"type": "Available",
"status": "True",
"lastUpdateTime": "2018-06-05T11:35:45Z",
"lastTransitionTime": "2018-06-05T11:35:45Z",
"reason": "MinimumReplicasAvailable",
"message": "Deployment has minimum availability."
},
{
"type": "Progressing",
"status": "True",
"lastUpdateTime": "2018-06-05T11:35:46Z",
"lastTransitionTime": "2018-06-05T11:34:32Z",
"reason": "NewReplicaSetAvailable",
"message": "ReplicaSet \"jboss-8674444985\" has successfully progressed."
}
]
}
}
Regards
Anupam Narayan
As stated in the error log:
for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount. helper program
According to this question, you might be missing the nfs-commons package which you can install using sudo apt install nfs-common

How can I set the units in an Xively datastream via MQTT

I'm publishing the following MQTT request to the topic /v2/feeds/XXX.json, where XXX is the name of my feed.
{
"version": "1.0.0",
"datastreams": [
{
"id": "test",
"current_value": 25,
"unit": "Celsius",
"unit_symbol": "°C"
}
]
}
When I look at the develop page on the Xively website, I see a new channel called test has been created with the value 25, but it has no associated units.
How can I set the units for a datastream using MQTT?
The proper json request is:
{
"version": "1.0.0",
"datastreams": [
{
"id": "test",
"current_value": 25,
"unit": {
"symbol": "°C",
"label": "Celsius"
}
}
]
}

Resources