![image](https://user-images.githubusercontent.com/18219467/189523406-1da330b7-080b-4a06-95f5-701cbe1e21d3.png) Hi Community, In this article I will demonstrate the functionality of my app iris-energy-isodata .   Application is accessing energy data (production, demand and supply)  from the major Independent System Operators (ISOs) in the United States to ensure sustainable consumption and production patterns (SDG's 12) Application is using python library isodata , Production EXtension PEX  along with <a csp="" docbook="" docbook.ui.page.cls="" docs.intersystems.com="" https:="" irisforhealthlatest="">**Embedded Python. **</a> Special Thanks to @Guillaume Rongier for the template  template for guidance ### Below is the list of Independent System Operators(ISOs) 1. ** California ISO (caiso)** 2. ** PJM (pjm)** 3. ** **** ISO New England (isone)** ## And below are the details of energies  1. **Natural Gas ** 2. **Solar       ** 3. **Imports     ** 4. **Wind        ** 5. **Large Hydro ** 6. **Nuclear     ** 7. **Batteries   ** 8. **Geothermal  ** 9. **Biomass     ** 10. **Small hydro ** 11. **Biogas      ** 12. **Coal    **    So let's start First of all we have to start the production. ![](https://user-images.githubusercontent.com/18219467/190370238-ac152029-5ec0-4c79-8b59-239d3c81fadd.png) Our production contains 3 Business Services (Every ISO's has its own service)  Business service importing BusinessService class which is inherited from  Ens.BusinessService and isodata python library. Below python code of business service Isodata.CaliforniaService is calling get\_latest\_fuel\_mix() function to get detail productions of energies, get\_demand\_today() function to get today  demand and get\_supply_today() function to get today supply.
&lt;span class="hljs-keyword">from&lt;/span> grongier.pex &lt;span class="hljs-keyword">import&lt;/span> BusinessService
&lt;span class="hljs-keyword">import&lt;/span> isodata

&lt;span class="hljs-comment">#Event to get data and pass to process&lt;/span>
&lt;span class="hljs-function">&lt;span class="hljs-keyword">def&lt;/span> &lt;span class="hljs-title">on_task&lt;/span>&lt;span class="hljs-params">(self)&lt;/span> -> PostClass:&lt;/span>
     &lt;span class="hljs-comment">#selecting ISO's&lt;/span>
     iso = isodata.get_iso(&lt;span class="hljs-string">'caiso'&lt;/span>)
     caiso = iso()
     &lt;span class="hljs-comment">#Get production details of the entergies&lt;/span>
     getdata = str(caiso.get_latest_fuel_mix())
     &lt;span class="hljs-comment">#Get today Demand&lt;/span>
     demandpd = caiso.get_demand_today()
     demand = str(demandpd[&lt;span class="hljs-string">'Demand'&lt;/span>].iloc[&lt;span class="hljs-number">0&lt;/span>])
     &lt;span class="hljs-comment">#Get today Supply&lt;/span>
     supplypd = caiso.get_supply_today()
     supply = str(supplypd[&lt;span class="hljs-string">'Supply'&lt;/span>].iloc[&lt;span class="hljs-number">0&lt;/span>])
     post = PostClass.from_dict(value[&lt;span class="hljs-string">'data'&lt;/span>])
     post.fuel_mix = getdata
     post.title=&lt;span class="hljs-string">"caiso"&lt;/span>
     post.demand = demand+&lt;span class="hljs-string">" NW"&lt;/span>
     post.supply = supply+&lt;span class="hljs-string">" NW"&lt;/span>
     self.log_info(post)
     &lt;span class="hljs-keyword">return&lt;/span> post
### Business Process   Business process importing BusinessProcess class which is inherited from  Ens.BusinessProcess. Getting message from service and based on the title passing to the operation. Below is the python code of Business Process (Isodata.FilterRoutingRule)
from grongier.pex import BusinessProcess
from message import PostMessage
from obj import PostClass
import iris

&lt;span class="hljs-keyword">class&lt;/span> FilterPostRoutingRule(BusinessProcess):
    &lt;span class="hljs-string">"""
    This process receive a PostMessage and send to operation based on the title
    """&lt;/span>
    def on_init(self):
        &lt;span class="hljs-keyword">if&lt;/span> not hasattr(self,'target'):
            self.target = &lt;span class="hljs-string">"Isodata.CaliforniaOperation"&lt;/span>
        &lt;span class="hljs-keyword">return&lt;/span>
    def iris_to_python(self, request:'iris.dc.Demo.PostMessage'):
        request = PostMessage(post=PostClass(title=request.Post.Title,                                             
                                             created_utc=request.Post.CreatedUTC,
                                             fuel_mix=request.Post.OriginalJSON))
        &lt;span class="hljs-keyword">return&lt;/span> self.on_python_message(request)

    def on_python_message(self, request: PostMessage):
        #based on the title from message, routing to the operation
        &lt;span class="hljs-keyword">if&lt;/span> 'caiso'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.CaliforniaOperation"&lt;/span>
        elif 'ercot'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.TexasOperation"&lt;/span>
        elif 'nyiso'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.NewYorkOperation"&lt;/span>
        elif 'spp'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.SouthWestOperation"&lt;/span>
        elif 'pjm'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.PjmOperation"&lt;/span>
        elif 'miso'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.MidcontinentOperation"&lt;/span>
        elif 'isone'.upper() in request.post.title.upper():
            target = &lt;span class="hljs-string">"Isodata.IsoneOperation"&lt;/span>
        &lt;span class="hljs-keyword">if&lt;/span> target is not None:
            self.send_request_sync(target,request)
            rsp = iris.cls('Ens.StringResponse')._New(f&lt;span class="hljs-string">"{request.post.title}"&lt;/span>)
            &lt;span class="hljs-keyword">return&lt;/span> rsp
        &lt;span class="hljs-keyword">else&lt;/span>:
            &lt;span class="hljs-keyword">return&lt;/span>
  ### Business Operation Business Operation importing BusinessOperation class which is inherited from Ens.BusinessOperation. Business Operation is receiving message from Business process and writing the message details to the file based on the message title. Below is the python code of Business Operation (Isodata.CaliforniaOperation)
from grongier.pex import BusinessOperation, Utils
import iris
import os
import datetime
import smtplib
from email.mime.text import MIMEText

&lt;span class="hljs-keyword">class&lt;/span> FileOperation(BusinessOperation):
    &lt;span class="hljs-string">"""
    This operation receive a PostMessage and write down in the right company
    .txt all the important information and the time of the operation
    """&lt;/span>
    def on_init(self):
        &lt;span class="hljs-keyword">if&lt;/span> hasattr(self,'path'):
            os.chdir(self.path)

    def on_message(self, request):
        ts = title = fuel_mix =  demand = supply = &lt;span class="hljs-string">""&lt;/span>
        fuel_mix = request.post.fuel_mix
        demand = request.post.demand
        supply = request.post.supply

        &lt;span class="hljs-keyword">if&lt;/span> (request.post is not None):
            title = request.post.title
            ts = datetime.datetime.fromtimestamp(request.post.created_utc).__str__()

        line = ts+&lt;span class="hljs-string">" : "&lt;/span>+title
        filename = title+&lt;span class="hljs-string">".txt"&lt;/span>
        self.put_line(filename, line)
        self.put_line(filename, &lt;span class="hljs-string">""&lt;/span>)
        self.put_line(filename, fuel_mix)
        self.put_line(filename, &lt;span class="hljs-string">""&lt;/span>)
        self.put_line(filename, demand)
        self.put_line(filename, &lt;span class="hljs-string">""&lt;/span>)
        self.put_line(filename, supply)
        self.put_line(filename, &lt;span class="hljs-string">" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"&lt;/span>)

        &lt;span class="hljs-keyword">return&lt;/span>
    def put_line(self,filename,string):
        &lt;span class="hljs-keyword">try&lt;/span>:
            with &lt;span class="hljs-keyword">open&lt;/span>(filename, &lt;span class="hljs-string">"a"&lt;/span>,encoding=&lt;span class="hljs-string">"utf-8"&lt;/span>) &lt;span class="hljs-keyword">as&lt;/span> outfile:
                outfile.&lt;span class="hljs-keyword">write&lt;/span>(string)
        except Exception &lt;span class="hljs-keyword">as&lt;/span> e:
            raise e
![image](https://user-images.githubusercontent.com/18219467/189573214-36d3f351-f688-4be1-8b12-cbde9b18fec4.png) Below is the message details which contains ISO name, Total production, details of energies, today demand and supply ![image](https://user-images.githubusercontent.com/18219467/189573344-f32fbb6c-73bf-4e5f-8453-8effc396f556.png) Thanks