Cannot get ui_guage to display each message after specified delay time - user-interface

My experiment is to change the ui_guage according to the numbers from a csv file. Each number is delayed for 5 sec.(code at end)
Input to csv file is a multi-line msg.payload with three values per line.i.e,
name1, numerical1,numerical11
name2 numerical2,numerical22, etc
problem: i get no delay of 5sec per message on the gauge...it directly shows the final value present in the last column (i have used a delay node also but still...)
example: display column 3 numericals as indicator with 5 sec delay on gauge.
gauge output: numerical22 (the indicator sets to this position at once)
So, the required per message delay (5 sec) is absent.
I require the delay.
I'am working on IBM cloud lite plan, node red v1.0.6
please review the following code
any help is welcome
if similar is answered before please re-direct me the solution.
To run following code:
open Node-RED
Click the three lines (top right)
import
Copy & paste the following flow json code and click "import" button
know more : Importing and Exporting Flows in Node-RED
The code:
[
{
"id": "c9b43c3a.da2e4",
"type": "ui_gauge",
"z": "ac0d0d22.69ebb",
"name": "",
"group": "c604d450.9712c8",
"order": 13,
"width": "5",
"height": "5",
"gtype": "gage",
"title": "<img height=\"50\" width=\"50\" src=\"https://upload.wikimedia.org/wikipedia/commons/b/bf/Pressure_gauge.svg\"/>",
"label": "units",
"format": " {{msg.payload.col3}}",
"min": 0,
"max": 10,
"colors": [
"#00b500",
"#e6e600",
"#ca3838"
],
"seg1": "",
"seg2": "",
"x": 840,
"y": 320,
"wires": []
},
{
"id": "c604d450.9712c8",
"type": "ui_group",
"z": "",
"name": "tab1",
"tab": "c733c61c.6e4828",
"order": 1,
"disp": true,
"width": "12",
"collapse": false
},
{
"id": "c733c61c.6e4828",
"type": "ui_tab",
"z": "",
"name": "Home1",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]

Related

NiFi: ReplaceText alternatives to modify JSON

My NiFi application receives two kinda different types of JSON's.
First of them looks like:
[
{
"campaign": {
"resourceName": "customers/8952771329/campaigns/11381694617",
"status": "ENABLED",
"name": "Saint_Spring_Active Minerals_oct-nov_2020_trueview_skip_5766500views",
"id": "11381694617"
},
"metrics": {
"interactionEventTypes": [
"VIDEO_VIEW"
],
"clicks": "6",
"videoQuartileP100Rate": 0.44493171079034244,
"videoQuartileP25Rate": 0.9747718298919024,
"videoQuartileP50Rate": 0.7339309987701469,
"videoQuartileP75Rate": 0.5337562301767105,
"videoViewRate": 0.4471109114825628,
"videoViews": "27872",
"viewThroughConversions": "0",
"contentBudgetLostImpressionShare": 0.0000013066088274492382,
"contentImpressionShare": 0.0999,
"contentRankLostImpressionShare": 0.9001,
"conversionsValue": 0,
"conversions": 0,
"costMicros": "9338700950",
"ctr": 0.00009624947864865732,
"currentModelAttributedConversions": 0,
"currentModelAttributedConversionsValue": 0,
"engagementRate": 0,
"engagements": "0",
},
"segments": {
"device": "CONNECTED_TV",
"date": "2020-12-20"
}
}
]
And second:
[
{
"adGroup": {
"resourceName": "customers/5404177717/adGroups/110501283582",
"campaign": "customers/5404177717/campaigns/11628802542"
},
"metrics": {
"interactionEventTypes": [
"CLICK"
],
"clicks": "1",
"averageCpm": 95497428.02172929,
"gmailForwards": "0",
"gmailSaves": "0",
"gmailSecondaryClicks": "0",
"impressions": "4418",
"interactionRate": 0.00022634676324128565,
"interactions": "1"
},
"adGroupAd": {
"resourceName": "customers/5404177717/adGroupAds/110501283582~480227690139",
"status": "ENABLED",
"ad": {
"resourceName": "customers/5404177717/ads/480227690139",
"id": "480227690139",
"name": "20 sec perek"
},
"adGroup": "customers/5404177717/adGroups/110501283582"
},
"segments": {
"device": "DESKTOP",
"date": "2020-11-21"
}
}
]
I already have 2 tables in my database to save this data. I have an attribute table.name just to not create same block where's only table name is different.
My next block is FlattenJson. After this i'm using ReplaceText with search value (replacement value is empty string): (customers\\\/${client.customer.id}\\\/campaigns\\\/|customers\\\/${client.customer.id}\\\/adGroups\\\/).
Why this? From this line: "adGroup": "customers/5404177717/adGroups/110501283582" i only need last value 110501283582 as ad_group_id. And from this line: "campaign": "customers/5404177717/campaigns/11628802542" i only need 11628802542. ${client.customer.id} can be different, so i'm using EL features.
Also i need to change json value name adGroup to ad.group.id, for this i'm also using ReplaceText.
Can i do it faster without two ReplaceText processors?
Look at the following processors...I think using them can be an alternative:
JoltTransformJSON:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.JoltTransformJSON/
UpdateRecord:
https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.UpdateRecord/index.html

xpath: how can I get if the category is Type then get the Villa

Get the type of the house that is Villa:
<div class="property__feature">
<h3 class="property__feature-title property__feature-title--b-spacing">Property Details</h3>
<ul class="property__details-list">
<li class="property__details-item">
Here is where I need to get the info:
<span class="property__details-item--cat">Type:</span>
Villa
// ***
They are using client-side template rendering, so there is no xpath selector you can use to extract that element using Scrapy because Scrapy only deals with HTML, not JavaScript
That said, the data you are looking for is sent down inside the page, and thus can be extracted with a little massaging:
def parse(self, response):
import json
model_json = ''.join(response.xpath(
'.//script[#type="text/javascript" and contains(text(), "var model")]/text()'
).re(r'var model = (\{.+\});'))
model_data = json.loads(model_json)
property_data = model_data['Property']
"""
{
"Property": {
"Id": 80765,
"Type": 32,
"Status": 1,
"Area": {
"Id": 32,
"Name": "Geri",
"District": {
"Id": 1,
"Name": "Nicosia"
}
},
"IsForRent": false,
"RentPrice": 0,
"IsForSale": true,
"SalePrice": 125000,
"PriceIsPublic": true,
"SaleVAT": 0,
"SaleVATType": 1,
"Description": "<p class=\"MsoNormal\" style=\"text-align: justify;\"><span style=\"mso-fareast-language: EN-GB;\">We are pleased to present the new project of under division residential plots in one of the most sought after areas of Geri. It is located in a quiet residential area, 3 km away from the General Hospital of Nicosia, 3.5 km from the Mall of Cyprus, 2.5 km from the University of Cyprus and with easy access to the motorway. The under division plot has an area of 565 sqm and it falls into residential planning zone Κα8 with 60% building density, 35% coverage, 2 floors and a maximum height of 10m.</span></p>\r\n<p class=\"MsoNormal\" style=\"text-align: justify;\">Subject to VAT.</p>",
"EnergyEfficiencyRating": {
"Type": 1,
"CurrentRating": 0,
"PotentialRating": 0,
"Key": null
},
"EnvironmentalImpactRating": {
"Type": 2,
"CurrentRating": 0,
"PotentialRating": 0,
"Key": null
},
"ShowOnMap": true,
"Coordinates": {
"Latitude": 35.119343,
"Longitude": 33.407802
},
If you want to convert those "Type": 32 into "Type": "Building Plot", you'll have to go the extra step of also extracting their .init data from the other script text
json.loads(''.join(response.xpath(
'.//script[#type="text/javascript" and contains(text(), ".init(")]/text()'
).re(r'\.init\((\{.+\})\)')))
"""{
"Resources": {
"PropertyTypes": {
"1": "Apartment",
"2": "House",
"8": "Commercial",
"32": "Building Plot",
"64": "Land",
"128": "Industrial",
"256": "Investments",
"512": "Villa",
"1024": "Mansion"
},
"PropertyStatuses": {
"1": "Resale",
"2": "Rented",
"3": "Sold",
In the future, if you don't see the information you are looking for when you use the "View Source" of your browser (or in the output of response.body_as_unicode() from inside Scrapy), then it is being loaded dynamically and thus needs some special handling. Most of the time, that information is loaded via XHR and you're actually in luck because reproducing that in Scrapy is usually painless and gets you out of the HTML scraping game entirely. This is one of those unfortunate situations where the data is being loaded dynamically, but from within the page, and thus the preceeding silliness is required.

Sending values between cards with BotFramework Composer

Good morning!
I am starting with BotFramework Composer tool using the template RespondingWithCardsSample and I am having problems testing the send of value from one card to another.
On the one hand, I have edited the AdaptivecardJson card with the following basic code.
#adaptivecardjson
- ```
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"width": "stretch",
"items": [
{
"type": "Input.ChoiceSet",
"placeholder": "Adults",
"choices": [
{
"title": "1",
"value": "1"
},
{
"title": "2",
"value": "2"
},
{
"title": "3",
"value": "3"
},
{
"title": "4",
"value": "4"
}
],
"id": "InputAdultos"
}
]
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Send"
}
]
}
This card simply contains an input text indicating the number of adults, the send button and inflates the following card:
#AdaptiveCard
[Activity
Attachments = #{json(adaptivecardjson())}
]
Finally, I created another card which simply writes the number of adults received:
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is #{InputAdults}
]
But I just didn't understand how it works and it gives me the following error:
common.lg: Error occurs when evaluating expression bfdactivity-028800 (): Error occurs when evaluating expression HeroCardAdults (): Specified argument was out of the range of valid values.
Parameter name: ‘inputadults’ does not match memory scopes: user, conversation, turn, settings, dialog, class, this
Has it happened to someone else?
Thanks!
Change your template to
# HeroCardAdults(InputAdults)
[HeroCard
text = The number of adults is {InputAdults}
]
or if you want to use memory scopes, set your value to dialog.InputAdults and use this template
# HeroCardAdults
[HeroCard
text = The number of adults is {dialog.InputAdults}
]

Rasa nlu tutorial doesn't work

Rasa NLU version (0.11.3):
Used backend / pipeline (spacy_sklearn):
Operating system (osx):
Issue: I tried to follow the tutorial: https://rasahq.github.io/rasa_nlu/tutorial.html?highlight=project#,
Installed spaCy + sklearn
Created config_spacy.json
Downloaded sample file and train
I've test greeting and goodbye intent and they are work
but when I test with command:
curl -X POST localhost:5000/parse -d '{"q":"I am looking for Mexican food"}' | python -m json.tool
it returns:
{
"intent": {
"name": "None",
"confidence": 1.0
},
"entities": [],
"text": "yes"
}
Content of configuration file (if used & relevant):
{
"project": null,
"fixed_model_name": null,
"config": "config.json",
"data": null,
"emulate": null,
"language": "en",
"log_file": null,
"log_level": "INFO",
"mitie_file": "data/total_word_feature_extractor.dat",
"spacy_model_name": null,
"num_threads": 1,
"max_training_processes": 1,
"path": "/rasa_nlu/projects",
"port": 5000,
"token": null,
"cors_origins": [],
"max_number_of_ngrams": 7,
"pipeline": [],
"response_log": "/rasa_nlu/logs",
"storage": null,
"aws_endpoint_url": null,
"duckling_dimensions": null,
"duckling_http_url": null,
"ner_crf": {
"BILOU_flag": true,
"features": [
[
"low",
"title",
"upper",
"pos",
"pos2"
],
[
"bias",
"low",
"word3",
"word2",
"upper",
"title",
"digit",
"pos",
"pos2",
"pattern"
],
[
"low",
"title",
"upper",
"pos",
"pos2"
]
],
"max_iterations": 50,
"L1_c": 1,
"L2_c": 0.001
},
"intent_classifier_sklearn": {
"C": [
1,
2,
5,
10,
20,
100
],
"kernel": "linear"
}
}
Status:
{
"available_projects": {
"default": {
"status": "ready",
"available_models": [
"fallback"
]
}
}
}
In your config file the pipeline is set to [] but needs to be configured properly. The documentation for the pipeline configuration option can be found here. The available options are discussed here.
The pipeline can either be a pre-configured pipeline like: mitie, spacy_sklearn, or keyword. It can also be a custom pipeline like: ["nlp_spacy", "ner_crf", "ner_synonyms"]. I would recommend setting your pipeline to:
pipeline: "space_sklearn"
Update your configuration file and restart the server. If the server is still running in a console window press Ctrl + c to stop it. Then re-enter the command you used to start it.

AM charts - duration split up in y axis

In am Charts, i have users list as category and duration (hh:mm:ss) in value axis graph. I had set grid count to 24 but, its not working as expected (1 hr * 24 steps). Its being set as 2000 secs steps. I tried changing a lot of parameter.
My sample data : https://live.amcharts.com/iMWNh/
Here, the duration split up is not working as expected in 1 hr split ups of 24 grids. My input data is in seconds.
Any advice ?
This helped me ! Hope someone finds it useful.
Hi,
Unfortunately, what you require would be impossible to implement using
Live Editor, due to some of its limitation.
However, it's possible using amCharts.
I have made necessary changes here:
https://codepen.io/team/amcharts/pen/55fe695a57e33657e9d5feb33423d481?editors=0010
AmCharts.useUTC = true;
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"categoryField": "category",
"rotate": true,
"startDuration": 1,
"backgroundAlpha": 0.8,
"categoryAxis": {
"gridPosition": "start"
},
"trendLines": [],
"graphs": [
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-1",
"title": "Online(secs)",
"type": "column",
"valueField": "Online(sec)"
},
{
"balloonText": "[[title]] of [[category]]:[[value]]",
"fillAlphas": 1,
"id": "AmGraph-2",
"title": "Offline(secs)",
"type": "column",
"valueField": "Offline(sec)"
}
],
"guides": [],
"valueAxes": [
{
"id": "ValueAxis-1",
"maximum": 86400000,
"stackType": "regular",
"strictMinMax": true,
"autoGridCount": false,
"autoRotateCount": 0,
"gridCount": 24,
"labelRotation": 50.4,
"title": "",
"titleRotation": 0,
"type": "date",
"minPeriod": "hh",
"boldPeriodBeginning": false,
"markPeriodChange": false
}
],
"allLabels": [],
"balloon": {},
"legend": {
"enabled": true,
"useGraphSettings": true
},
"titles": [
{
"id": "Title-1",
"size": 15,
"text": "Chart Title"
}
],
"dataProvider": [
{
"category": "Diana",
"Online(sec)": 7200000,
"Offline(sec)": 79200000
},
{
"category": "Clarke",
"Online(sec)": 18000000,
"Offline(sec)": 68400000
},
{
"category": "Bruce",
"Online(sec)": 3600000,
"Offline(sec)": 7200000
}
]
});
There were quite a few changes:
1) Remove the duration from value axis, and set its type: "date;
2) Make values in data non-string (remove quotes around them) and convert
to milliseconds, since JavaScript deals in milliseconds;
3) Similarly convert maximum in valueAxis to milliseconds as well;
4) Set the following two settings for valueAxis: (so that it does not try to
format the first hour differently)
"boldPeriodBeginning": false, "markPeriodChange": false
5) Finally, set AmCharts.useUTC = false before chart code. (this ensures that
timestamps are not being recalculated to local time zone)
I hope you find this useful.
Yours sincerely,
Martynas Majeris
amCharts

Resources