<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Enhance Reports by adding device vs. individual point selection]]></title><description><![CDATA[<p dir="auto">When creating a report it would be nice to have the option to choose a "Device" (datasource) and have all points added to the report vs. having to add each one individually. Sometimes its quicker to include all points and delete the few you don't want then adding them individually. Maybe choose a device from the drop-down which displays available points with check boxes similar to adding points when using BACnet discovery by device instance? This report could then become a template that could be applied to other like devices.</p>
]]></description><link>https://forum.mango-os.com/topic/3284/enhance-reports-by-adding-device-vs-individual-point-selection</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 03:41:00 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/3284.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Feb 2018 14:48:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Enhance Reports by adding device vs. individual point selection on Fri, 16 Feb 2018 19:53:54 GMT]]></title><description><![CDATA[<p dir="auto">A better script, a tastier beer?</p>
<pre><code>import requests
import json
from StringIO import StringIO
import copy

#Script information, CONFIGURE
reportXid = "Your Report XID" #Report XID to add points to
removeExistingPoints = False #Remove the points that are already on the report
addDataSources = ["DS_1234"] #list of data source xids to add
additionalRQL = "limit(-1)" #use a high limit if not H2, or whatever limit is desired

#Server information, CONFIGURE
host = "192.168.1.111"
port = "80"
login = {"username": "admin", "password": "admin"}

#Begin script....
hostPort = host + ":" + port

s = requests.Session()
s.headers.update({'Cookie':'MANGO'+port+'=initial; XSRF-TOKEN=init','X-Xsrf-Token':'init','Accept': 'application/json', 'Accept-Encoding': 'gzip', 'Content-Type': 'application/json;charset=UTF-8'});

r = s.post('http://' + hostPort + "/rest/v2/login", data=json.dumps(login))

#del s.headers["Content-Type"]
del s.headers["Cookie"]
s.headers["X-Xsrf-Token"] = s.cookies["XSRF-TOKEN"]

#get the report's JSON:
reportsResponse = s.get('http://' + hostPort + "/rest/v2/json-emport?exportElements=reports")
#print reportsResponse.text
reportsList = json.load( StringIO( reportsResponse.text ))["reports"]
report = None
for rpt in reportsList :
	if rpt["xid"] == reportXid :
		report = rpt
		break
		
if report is None :
	print "Couldn't find report with xid: " + reportXid
	exit()
	
if removeExistingPoints :
	report.points = []
	
baseReportPoint = {
               "pointXid":"",
               "colour":"",
               "consolidatedChart":True,
               "plotType":1,
               "pointKey":"p",
               "weight":1.0
            }

if len(addDataSources) &gt; 0 :
	dataPointsRql = "or("
	for dsXid in addDataSources :
		dataPointsRql += "eq(dataSourceXid," + dsXid + "),"
	dataPointsRql = dataPointsRql[:-1] + ")&amp;" + additionalRQL
else :
	dataPointsRql = additionalRQL
	
#print dataPointsRql

def pointInReport(reportPoints, point) :
	for pnt in reportPoints :
		if pnt["pointXid"] == point["xid"] :
			return True
	return False

pointsResponse = s.get("http://" + hostPort + "/rest/v2/data-points?" + dataPointsRql)
#print pointsResponse.text
pointsList = json.load( StringIO( pointsResponse.text ))["items"]
for pnt in pointsList :
	#You may wish to configure the report points here as well
	if not pointInReport(report["points"], pnt) :
		newReportPoint = copy.deepcopy(baseReportPoint)
		newReportPoint["pointXid"] = pnt["xid"]
		newReportPoint["pointKey"] += str(pnt["id"])
		report["points"].append(newReportPoint)
		#print "Added point: " + pnt["xid"]

#Save the modified report through the json-emport
saveResponse = s.post("http://" + hostPort + "/rest/v2/json-emport", data=json.dumps({"reports":[report]}))
print "Saving report returned status: ", saveResponse
</code></pre>
<p dir="auto">You probably need to change my print statements if you're using Python 3.</p>
<p dir="auto">Edit: Fixed up the multiple data source possibility some</p>
]]></description><link>https://forum.mango-os.com/post/17366</link><guid isPermaLink="true">https://forum.mango-os.com/post/17366</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Fri, 16 Feb 2018 19:53:54 GMT</pubDate></item><item><title><![CDATA[Reply to Enhance Reports by adding device vs. individual point selection on Fri, 16 Feb 2018 18:08:02 GMT]]></title><description><![CDATA[<p dir="auto">Thank you, Philip. Something similar to the Watchlist Builder sounds great.<br />
If you had a simple python example I could use as a starting point I would be owe you yet another beer.</p>
]]></description><link>https://forum.mango-os.com/post/17362</link><guid isPermaLink="true">https://forum.mango-os.com/post/17362</guid><dc:creator><![CDATA[Wingnut2.0]]></dc:creator><pubDate>Fri, 16 Feb 2018 18:08:02 GMT</pubDate></item><item><title><![CDATA[Reply to Enhance Reports by adding device vs. individual point selection on Fri, 16 Feb 2018 16:27:10 GMT]]></title><description><![CDATA[<p dir="auto">Hi Wingnut2.0,</p>
<p dir="auto">Thanks for the idea! I know internally we're talking about ways to unify the reporting, and I would definitely expect we'll consider this and put in some mechanisms resembling those in the Watchlist Builder.</p>
<p dir="auto">One could do something like this with either a python script or a script inside of Mango. I can show you how, but admittedly it isn't as smooth as having a UI to do it from.</p>
]]></description><link>https://forum.mango-os.com/post/17359</link><guid isPermaLink="true">https://forum.mango-os.com/post/17359</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Fri, 16 Feb 2018 16:27:10 GMT</pubDate></item></channel></rss>