staromeste / homebridge-http-advanced-accessory

Supports all devices on HomeBridge Platform / Bridges devices to http
Apache License 2.0
65 stars 22 forks source link

JSON Mapping #22

Closed Stefan-83 closed 4 years ago

Stefan-83 commented 4 years ago

Hi, i want to get the status of my rainsensor by using the HTTP-Output, when using http://192.168.178.98/jc?pw=passwort:

{"devt":1588464348,"nbrd":1,"en":1,"sn1":0,"sn2":0,"rd":0,"rdst":0,"sunrise":365,"sunset":1244,"eip":1304293196,"lwc":1588458071,"lswc":1588458071,"lupt":1588021556,"lrbtc":4,"lrun":[2,3,60,1588453261],"RSSI":-61,"loc":"48.86826,8.28199","jsp":"https://ui.opensprinkler.com/js","wsp":"weather.opensprinkler.com","wto":{"h":100,"t":79,"r":77,"bh":30,"bt":66.2,"br":0.059,"key":""},"ifkey":"","wtdata":{"wp":"Manual"},"wterr":0,"curr":0,"sbits":[0,0],"ps":[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]}

The status is "sn1" (0 or 1) I tried to use this config below, but no luck. Any ideas? Thanks :)

        {
            "accessory": "HttpAdvancedAccessory",
            "service": "ContactSensor",
            "name": "Rain Sensor",
            "polling": "true",
            "forceRefreshDelay": 5,
            "debug": true,
            "optionCharacteristic": [],
            "urls": {
                "getContactSensorState": {
                    "url": "http://192.168.178.98/jc?pw=passwort",
                    "mappers": [
                        {
                            "type": "jpath",
                            "parameters": {
                                "jpath": "$sn1:",
                                "index": "0"
                            }
                        },
                        {
                            "type": "static",
                            "parameters": {
                                "mapping": {
                                    "ALARM": "1",
                                    "NORMAL": "0"
                                }
                            }
                        }
                    ]
                }
            }
        }
staromeste commented 4 years ago

I didn’t try it but looking at the configuration I spotted a mistake in “jpath” it should be “$.sn1”

Guido

Il giorno 3 mag 2020, alle ore 00:49, Stefan-83 notifications@github.com ha scritto:

 Hi, i want to get the status of my rainsensor by using the HTTP-Output, when using http://192.168.178.98/jc?pw=passwort:

{"devt":1588464348,"nbrd":1,"en":1,"sn1":0,"sn2":0,"rd":0,"rdst":0,"sunrise":365,"sunset":1244,"eip":1304293196,"lwc":1588458071,"lswc":1588458071,"lupt":1588021556,"lrbtc":4,"lrun":[2,3,60,1588453261],"RSSI":-61,"loc":"48.86826,8.28199","jsp":"https://ui.opensprinkler.com/js","wsp":"weather.opensprinkler.com","wto":{"h":100,"t":79,"r":77,"bh":30,"bt":66.2,"br":0.059,"key":""},"ifkey":"","wtdata":{"wp":"Manual"},"wterr":0,"curr":0,"sbits":[0,0],"ps":[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]} The status is "sn1" (0 or 1) I tried to use this config below, but no luck. Any ideas? Thanks :)

    {
        "accessory": "HttpAdvancedAccessory",
        "service": "ContactSensor",
        "name": "Rain Sensor",
        "polling": "true",
        "forceRefreshDelay": 5,
        "debug": true,
        "optionCharacteristic": [],
        "urls": {
            "getContactSensorState": {
                "url": "http://192.168.178.98/jc?pw=passwort",
                "mappers": [
                    {
                        "type": "jpath",
                        "parameters": {
                            "jpath": "$sn1:",
                            "index": "0"
                        }
                    },
                    {
                        "type": "static",
                        "parameters": {
                            "mapping": {
                                "ALARM": "1",
                                "NORMAL": "0"
                            }
                        }
                    }
                ]
            }
        }
    }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Stefan-83 commented 4 years ago

@staromeste: That was it! Problem solved. Thanks :)