Updating Hassio Entities with context received from a WLAN server

Hi guys I am looking for some help with conforming data I get from an HTTP GET request into the appropriate form to update a home assistant entity via API.

I have this one but the data structure is a little different with the new one i am working on.
This one makes a request to a 48 port poe switch, manipulates the data, breaks it up into the individual entities and updates the home assistant entity through API.

[{"id":"c4ebeae2.faf7a8","type":"http request","z":"65d74546.4f245c","name":"","method":"GET","ret":"obj","paytoqs":false,"url":"http://10.1.2.1/rest/v1/poe/ports/stats","tls":"","persist":false,"proxy":"","authType":"","x":170,"y":80,"wires":[["9805d80d.f8fe98"]]},{"id":"9805d80d.f8fe98","type":"change","z":"65d74546.4f245c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.port_poe_stats","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":40,"wires":[["3352286b.126aa8"]]},{"id":"7fbf0699.60b488","type":"inject","z":"65d74546.4f245c","name":"","topic":"","payload":"","payloadType":"str","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":40,"wires":[["c4ebeae2.faf7a8"]]},{"id":"3352286b.126aa8","type":"split","z":"65d74546.4f245c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":430,"y":80,"wires":[["9ccfb20a.3494b"]]},{"id":"9ccfb20a.3494b","type":"change","z":"65d74546.4f245c","name":"","rules":[{"t":"change","p":"payload.poe_detection_status","pt":"msg","from":"PPDS_DELIVERING","fromt":"str","to":"on","tot":"str"},{"t":"change","p":"payload.poe_detection_status","pt":"msg","from":"PPDS_SEARCHING","fromt":"str","to":"off","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":40,"wires":[["db298abb.e55778"]]},{"id":"db298abb.e55778","type":"ha-api","z":"65d74546.4f245c","name":"","server":"c9987224.12e8f","debugenabled":true,"protocol":"http","method":"post","path":"states/sensor.lab_poe_{{payload.port_id}}","data":"{\"state\":\"{{payload.poe_detection_status}}\",\"attributes\":{\"port_voltage_in_volts\":\"{{payload.port_voltage_in_volts}}\",\"mps_absent_count\":\"{{payload.mps_absent_count}}\",\"actual_power_in_watts\":\"{{payload.actual_power_in_watts}}\"},\"entity_id\":\"sensor.lab_poe_{{payload.port_id}}\"}","dataType":"json","location":"payload","locationType":"msg","responseType":"json","x":750,"y":40,"wires":[["c93cba83.0e6c98"]]},{"id":"c93cba83.0e6c98","type":"debug","z":"65d74546.4f245c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":990,"y":40,"wires":[]},{"id":"c9987224.12e8f","type":"server","z":"","name":"HASSIO","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I am interested at creating a new flow similar to the above but a different http request to a different server that will give me information about wifi clients. I attemted to deconstruct the one above to fit this one but the data structure is too different to figure it out on my own right now at my level lol.The problem is I am terrible at this. The http request gives me the following result. (below) I have removed a buch of the entries so it doesnt fill up the page, but just know there is over 100 entries that will come in via this request.

{
    "Station_result": [
        {
            "msg": {
                "sta_eth_mac": {
                    "addr": "FCDBB36D34FB"
                },
                "username": "fcdbb36d34fb",
                "role": "iot-default-psk",
                "bssid": {
                    "addr": "A8BD27CC1132"
                },
                "device_type": "Android",
                "sta_ip_address": {
                    "af": "ADDR_FAMILY_INET",
                    "addr": "10.1.2.157"
                },
                "hashed_sta_eth_mac": "760DCCF8F7827A533FD542C607C4C4AE93A161DA",
                "hashed_sta_ip_address": "C63BBBA59BFEA09D8ECD375A60AC9D58CB3EDEDC",
                "ap_name": "LB-AP-335"
            },
            "ts": 1585691661
        },
        {
            "msg": {
                "sta_eth_mac": {
                    "addr": "F4F5D8CBC890"
                },
                "username": "iot-ds-speaker",
                "role": "media-player",
                "bssid": {
                    "addr": "A8BD27CC1136"
                },
                "device_type": "Linux",
                "sta_ip_address": {
                    "af": "ADDR_FAMILY_INET",
                    "addr": "10.1.2.115"
                },
                "hashed_sta_eth_mac": "B8E0A83F812DB3B3F5AEF35E82EDE88DD2044997",
                "hashed_sta_ip_address": "27A5C2D4C2E6615D798B68401D05F8704EC6EA9D",
                "ap_name": "LB-AP-335"
            },
            "ts": 1585668511
        },
        {
            "msg": {
                "sta_eth_mac": {
                    "addr": "F4F5D8B50466"
                },
                "username": "iot-lr-speaker",
                "role": "media-player",
                "bssid": {
                    "addr": "A8BD27CBAB12"
                },
                "device_type": "Linux",
                "sta_ip_address": {
                    "af": "ADDR_FAMILY_INET",
                    "addr": "10.1.2.100"
                },
                "hashed_sta_eth_mac": "83B15F61356CB196867C81D67E3342962FBF7099",
                "hashed_sta_ip_address": "A8CDE96149FB2F5EE4AAFDAF5279368F0C1A780E",
                "ap_name": "LR-AP-325-Point"
            },
            "ts": 1585702901
        }

I like to creat a flow that uses all of the data returned from the request to creat and update entity attributs. Something like the following:

"state": "{On",
entity id = MAC address of user device. somehow make it colon seperated
"attributes": {
"username": "{{username}}", username of the user
"role": "{{role}}", role of user
"bssid": "{{bssid}}" mac address of bssid (somehow make it colon seperated)
"device_type": "{{device_type}}",
"sta_ip_address": "{{sta_ip_address}}", IP address of the user device
"ap_name": "{{ap_name}}, name of access point connected to

Is this something that is pretty simple for some of you? Let me know the effort. This is just for my own interest and learning but will hopefully lead to more things, not using nodered and homeassistant lol

Many Many Many thanks in advance for reading.

username is sometimes a MAC address but I do not want to add colons to this field given most are actual usernames. As for the fields that are MAC address, the do NOT have to be colon separated but would be nice. Again let me know the effort or if you happen to get bored and its easy to you, send me a donation link :slight_smile:

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.