Maximo Open Forum

Expand all | Collapse all

How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

  • 1.  How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 07:41
    Edited by Alekhya Dadi 09-17-2020 08:07
    I would like to retrieve all the meters associated to an Asset or Location. I queried MXASSET OS as shown below. 

    https://MAXIMOSITEIP/maximo/oslc/os/mxasset?lean=1&oslc.select=assetnum,description,siteid,assetmeter{*}&oslc.pageSize=20&oslc.where=assetnum=21 and siteid="PLANT"​
    { "member": [ { "assetmeter_collectionref": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/int_assetmeter", "_rowstamp": "3491525333", "assetmntskd_collectionref": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/assetmntskd", "assetnum": "21", "description": "PUMP SKID 1", "siteid": "PLANT", "href": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX", "assetopskd_collectionref": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/assetopskd", "assetspec_collectionref": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/assetspecclass", "assetusercust_collectionref": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/assetusercust" } ], "href": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset", "responseInfo": { "href": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset?lean=1&oslc.select=assetnum,description,siteid,assetmeter{*}&oslc.pageSize=5&oslc.where=assetnum=21%20and%20siteid=%22PLANT%22", "pagenum": 1 } } ​


    When I query int_assetmeter, I get this with no results. 

    https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/int_assetmeter

    { "member": [], "href": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/int_assetmeter", "responseInfo": { "href": "https://MAXIMOSITEIP/maximo/oslc/os/mxasset/_MjE2NjEvUFdX/int_assetmeter" } }


    Am I missing something security/provisioning/access related or am I not headed the right direction? To add to it, what is the OS for querying for meters associated to a Location. Is it MXAPILOCATIONMETER?

    I am using Postman/Insomnia REST clients. Eventually, PowerShell/Python for automation. Any help is appreciated!

    #RESTAPI #oslc #7.6.1.1

    ​​​
    #Integrations
    #IoT

    ------------------------------
    MaximoPower!
    ------------------------------


  • 2.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 08:18
    This is going to sound silly, but are you sure the asset you retrieved has a meter?

    By having the oslc.select include assetmeter{*}, it should be returning the asset meters as a json array in your initial response (along with assetnum, description, & siteid from the asset object). I'd recommend limiting it to just the fields you need over using *, but that itself should be fine. Combine that with you making a request to int_assetmeter explicitly and the member array being empty (which is where you should see localref to get the details for each of those meters since you didn't specify an oslc.select), I'm assuming this particular asset doesn't have meters.

    ------------------------------
    Steven Shull
    Projetech
    ------------------------------



  • 3.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 08:50
    Thanks for the quick response Steven. That's a good point, Dev Maximo did not have meters for the Assets I tested! The Locations do have a bunch of meters. I get a 400 on Location meter query. Looks like access related issue. 

    I would like to use as much out of the box Maximo Object Structures (OS) as possible for this integration. The integration - Bring Historian DCS data and updating Maximo meters (Assets and Locations)  with that data. I am trying to understand the difference between MXAPIASSET and MXASSET. Do I use MXAPI* prefixed Object Structures for the integration? 

    Are my assumptions below correct and are best practices for integration with Maximo?

    • Query all meters for Asset - Use OS MXAPIASSETMETER (or MXASSET?)
    • Query all meters for Location - Use OS MXAPILOCATIONMETER (or MXAPILOCATION?)
    • Update MXMETERDATA with DCS data for each of the queried meter

    Thanks again!

    ------------------------------
    Alekhya Dadi
    ByteX
    ------------------------------



  • 4.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 09:19
    In general, we don't recommend utilizing out of the box object structures for integrations. We recommend duplicating one (like MXASSET) and configuring it for your own purposes. That allows you to remove objects/attributes that aren't required and include any additional objects/attributes that your integration needs without worrying about impacting anything else in Maximo (or other third party products that also utilize these).

    The MXAPI* object structures are almost all (if not all) used by work centers. I definitely would recommend not modifying these. Out of the box, the MXASSET and MXOPERLOC aren't utilized so they're safer in that changes to them won't impact core Maximo. A customer may have utilized them in another integration or application import/export but it wouldn't break anything Maximo. 

    As for entering the meter readings, using MXMETERDATA is fine but you should also be able to use the asset/location object structure and provide the newreading in that. I haven't done it personally, but it's definitely a supported process and is documented in section 11 of the REST document Overview (ibm.com)

    ------------------------------
    Steven Shull
    Projetech
    ------------------------------



  • 5.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 09:35
    Thanks again for the detailed response. I was of the opinion that any READ operations (GET) on out of the box object structures should be fine since we are not modifying any of those. Just curious why it is not safe to only read (and not modify anything) from the out of the box object structures? (Only purpose is to read the meter names for the Assets/Locations). 

    I will make a separate post for bulking these POST operations for the meters. I am using MXMETERDATA but will try using asset/location OS instead. 



    ------------------------------
    Alekhya Dadi
    ByteX
    ------------------------------



  • 6.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-17-2020 10:11
    There are quite a few reasons we recommend custom object structures. And to be clear, we DO recommend duplicating the out of the box one to ensure you maintain the java class references as those are important.  

    The biggest for us is around security. MXASSET & MXOPERLOC for example have no security configured for them out of the box (neither an application nor our preferred approach of configuring it specifically for that object structure). All you need is a valid username/password and you can use these object structures in full, whether or not you have access to assets, locations, etc. 

    Maximo implemented a switch to block this (mxe.int.enableosauth) where it would require security to be configured for each object structure to utilize but most organizations won't have this enabled. So an integration may work today, but when someone finally learns about and configures the appropriate security controls (either on the object specifically or at the system level) the integration might break. We like to build all new integrations with their own object structures and security groups to ensure that we have as granular security as possible. For example, if our integration just needs to be able to read that object structure, only grant the READ permission for the object structure that we've created. If it only needs to access data for a single site, only give it access to that site. 

    Beyond security, you run into multiple solutions/existing integrations depending on these out of the box object structures. For example, if the customer is using MXLoader it'll use MXASSET by default to load assets. What happens when a user using that decides they don't want some of the objects or need different ones or even just a change of the relationship between the objects? All too often they'll go and modify that object structure in Maximo. So all of a sudden you were expecting ASSETMETER to be part of the object structure but it might not be anymore or might return fewer results than you should have. 

    And less important when you're retrieving information, it also gives you the flexibility to implement changes specific to your integration. For example, you can build additional validation that only applies to your integration by creating an object structure inbound processing automation script. If MXLoader, your integration, and other integrations are all using the same object structure it becomes more difficult to implement those restrictions. Actions, queries, etc. can also be specific to your object structure.

    ------------------------------
    Steven Shull
    Projetech
    ------------------------------



  • 7.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 09-28-2020 18:12
    Thanks a lot Steven for the detailed response. I needed this kind of background to understand this in depth. I am requesting duplication of these Object Structures for all the right reasons! Really appreciate your patiently answering all my questions in this thread. 


    ------------------------------
    Alekhya Dadi
    ByteX
    ------------------------------



  • 8.  RE: How to retrieve all the meters associated to an Asset or Location using REST or OSLC API?

    Posted 23 days ago
    I am personally a fan of using the relationships to get back any data I need, wether it is in the object structures or not.  All you need to know is the relationship name from the database config for the parent object.  This one gets the asset, ,workorders, and collected meters for an asset:  oslc/os/mxasset?lean=1&oslc.where=ASSETNUM="93"&oslc.select=siteid,assetnum,description,status,location--assetloc,location.status,rel.allwo{wonum,status,changedate,description,istask},rel.measurements{measuredate,metername,observation,measurementvalue}

    I doubt there is something like this for inbound, but querying this is the easiest way if you don't want to change your object structures.

    ------------------------------
    Milton Williams
    activeG
    ------------------------------