The workaround for the missing features of the rest sensor is a command sensor with a script.
Don’t give up. I have a lot of these sensors and I love that they support local LAN URL calls. Someone made and app for them in smart things if you want to check out the code and methods they used.
Not sure if you figured it out but I had some success. I followed their instructions to get the OAuth2 code. Then I was able to get data in using this config:
- platform: rest
name: 'Wireless 1 Temp'
resource: https://www.mytaglist.com/ethClient.asmx/GetTagList
method: POST
value_template: '{{ value_json.d[0].temperature | round(2) }}'
unit_of_measurement: °C
headers:
Content-Type: application/json
Authorization: 'Bearer xxxxOAuthCodexxx'
Run that curl command you did above to get the full JSON and then each tag is d[0], d[1]… You should be able to get all data in this way. Great little sensors.
This was very helpful Kevin - thank you! I’m working on making a rest post to a Photon with published web functions (accessible through a restful API). An example of the CURL request is:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -d 'access_token=SECRET&args="1%2C0%2C10"' "https://api.particle.io/v1/devices/1e0026001247343339383037/WARM_STRIP/"
There are two parameters being passed: access_token and args (string). How should I form a valid rest post in HA given the requirements above?
I think it’s something like what I have below, but I can’t make it over the finish line.
- platform: rest
resource: https://api.particle.io/v1/devices/1e0026001247343339383037/WARM_STRIP/
method: POST
name: Particle Devices
payload: '{ "access_token: SECRET, args: "1,100,30"" }' (Syntax for multiple parameters?)
value_template: '{{ value_json.state | dictsort }}' (do I need this?)
Thank you for this. I just purchased some tags, and used this code to pull their values into HA with relative ease. Hardest part was getting the OAuth stuff to work from them.
@kevince52 can you please post your configuration and any other code you used to get this working? I am thinking about purchasing one of these tags myself for outside door as well as a motion sensor.
Thanks.
I used the code @kevince52 has above. the trick for me was getting the Authorization key.
I followed the directions here: http://wirelesstag.net/eth/oauth2_apps.html
for the re-direct url, I just put on that wouldn’t work, as all you need is the code that is appended to the URL you are re-directed to after you got o the link in step 1. you then use that code in the curl statement in step 3 to get the Authorization code.
Once I had that, I just put the code @kevince52 has above into my configuration, with the Auth code I got and it worked.
If you use the curl statement from @a8ree above, you can get the full json output from the site. there you can see the names, so I use:
'{{ value_json.d[0].temperature | round(2) }}' For temperature
'{{ value_json.d[0].cap | round(2) }}' for humidity %
'{{ value_json.d[0].lux | round(2) }}' for Light Lux value.
Thank you! It looks like these are not water proof… I was looking for a water proof door sensor and maybe a motion sensor too. So, most probably I will keep looking.
@rosahas they have rain proof tags, which can detect motion: not sure if it meets your needs or not:
Thanks, will take a look.
Just a quick warning - when I added some additional Tag Sensors, the order the order of the tags got scrambled, so I had to re-align the sensors with the correct order from the response.
What you can do is use the curl statement in a commandline:
curl -X POST mytaglist.com/ethClient.asmx/GetTagList2 -H 'Content-Type: application/json' -H 'Authorization: Bearer YOU_RBEARER_CODE' -d ""
Take the response, put it in a text editor, and change the comma in the },{ sequence to a return, and you can see the sensors in order, each line from the top down is 0,1,2,3, so on, which goes inside the brackets in the value_template line:
value_template: '{{ value_json.d[0].temperature | round(2) }}'
hello some one please help me with this
im trying to get below json value on rest sensor.
sensor setup
- platform: rest
resource: http://api.aladhan.com/timingsByCity?city=aljubail&country=SaudiArabia&method=2
name: Prayer Time
value_template: '{{ value_json.fajr }}'
json
{"code":200,"status":"OK","data":{"timings":{"Fajr":"04:11","Sunrise":"05:17","Dhuhr":"11:42","Asr":"15:13","Sunset":"18:07","Maghrib":"18:07","Isha":"19:13","Imsak":"04:01","Midnight":"23:42"},"date":{"readable":"16 Apr 2017","timestamp":"1492321943"}}}
i get the empty value
but if i change value_template
value_template: '{{ value_json.code }}'
i get the sensor value 200
Fajr is nested inside of timings, which is nested inside of data…
Here’s a recent post that gives some pointers about using the template dev tool to debug json templating:
i have done it. this worked for me
value_template: '{{ value_json.data.timings.fajr }}'
Hi sorry for my ignorance, but can you share all the configuration. I am new at this Hass.io stuff and I’m really struggling to get this to work with my wireless tag sensors.
Thanks in advance.
sorry for the delay was busy with work had no time to check the community
here it is
- platform: mqtt
name: Fuel Left
unit_of_measurement: "%"
state_topic: local/car/state
value_template: '{{ value_json.fuelleft }}'
another
- platform: mqtt
state_topic: local/prayer/state
name: Fajr
value_template: '{{ value_json.data.timings.Fajr }}'
I just started with my first set of tags… They’re pretty neat. But if the order of tags changes randomly in GetTagLis
t and GetTagList2
(and I’m pretty sure that’s legal, if inconvenient sometimes, in JSON) you can use GetTagForSlaveId
. I’m not sure what the slaveid
is other than an incremental of what tags were added to the system, but so far it seems unchanging. I’d prefer an endpoint you can retrieve specific tags off of the uuid, but I haven’t found that yet.
Hi, just read your post and I also have these wireless tag sensors. I’m a newbie and would love to have these running win home assistant/hass.io. Can you share how to put these sensor working ?? Where should all this code go ?
Thanks so much in advance.
I keep getting an error when adding these wireless tags as a rest sensor: Invalid config for [sensor.rest]: required key not provided @ data[‘resource’]. Got None.
I can curl successfully and see the data, but I can’t get my sensor config right.
- platform: rest
sensors:
guest_bathroom_humidity:
friendly_name: 'guest bathroom humidity'
resource: https://my.wirelesstag.net/ethClient.asmx/GetTagList2
method: POST
value_template: '{{ value_json.d[0].temperature | round(2) }}'
unit_of_measurement: °F
headers:
Content-Type: application/json
Authorization: 'Bearer <my_auth_code>'
Here’s sample data returned via curl:
{"d":[{"__type":"MyTagList.Tag2","managerName":"Home","mac":"<mac_address>","dbid":2,"mirrors":[],"notificationJS":null,"name":"guest bath","uuid":"<udid value>","comment":"","slaveId":0,"tagType":13,"lastComm":131587221142341535,"alive":true,"signaldBm":-72,"batteryVolt":2.9375063932615917,"beeping":false,"lit":false,"migrationPending":false,"beepDurationDefault":1001,"eventState":0,"tempEventState":0,"OutOfRange":false,"lux":0,"temperature":21.072044372558594,"tempCalOffset":0,"capCalOffset":0,"image_md5":null,"cap":42.2177734375,"capRaw":0,"az2":0,"capEventState":0,"lightEventState":0,"shorted":false,"thermostat":null,"playback":null,"postBackInterval":300,"rev":111,"version1":3,"freqOffset":2705,"freqCalApplied":0,"reviveEvery":4,"oorGrace":2,"LBTh":2.55,"enLBN":true,"txpwr":16,"rssiMode":true,"ds18":false,"v2flag":18,"batteryRemaining":0.91}]}
Any ideas?
FYI to anyone trying to set these up, URLs have changed without documentation. You should use https://my.wirelesstag.net for both OAuth and service calls.