Basic guide to get wirelesstags working on Home Assistant

Before you start - note, wirelesstag.net and mytaglist.com are 2 entities but contain the same info.
Pick one url and use it for all the commands below.

Credit for some of the instructions below - https://groups.google.com/forum/#!msg/wireless-sensor-tags/OSQeLHsE4W8/sfls9AUCEwAJ

Client ID
Client Secret
Code
Access Token - this is the value that you will be passing to the server with each API call

So here’s how you get all of those pieces:

Go to http://www.mytaglist.com/eth/oauth2_apps.html
Fill out the info in the "Register a new app" section
    You only need to provide a "Display Name"
    Click "Create", the section will change and you will now see your unique Client ID and Client Secret
    Save those, you will need them later, but you can always get back to them by accessing the link in step 1.
Now we need to form a URL using the Client ID

    the basic pattern is:  https://www.mytaglist.com/oauth2/authorize.aspx?client_id=[client ID of your app]  (do not include the brackets)
    So it should look something like:  https://www.mytaglist.com/oauth2/authorize.aspx?client_id=92bb1001-jeje-8c8c-k4oi-999hh55kk99l
Paste your newly created URL into your web browser
    If you formed your URL correctly, you will see a page that asks to "Grant API Access to [your app name]?"
Click the "Grant Access" button
At this point, you will get a server error "403 - Forbidden: Access is denied."  Relax, this is normal.
Put your cursor in the address box of the web browser and inspect the URL, inside you will find your 3rd piece of information...the "Code"
    It will look something like this:  https://www.mytaglist.com/oauth2/?code=1234ab56-7c8d-90e1-f23g-4hi56jklm78n&state=
    Make note of everything between "code=" and "&state="
    That's your "Code"

Download and install Advanced REST Client
https://install.advancedrestclient.com/

follow the image below
set method to POST
Enter the request url as shown
click body
body content type to application/x-www-form-urlencoded
click add form parameter and enter the client id, client secret and code
press SEND
you will get the result below with your access token.
Copy and paste the token somewhere safe, you will need to enter it in you config.yaml file

Example code - to be put under Sensor in your config.yaml file

- platform: rest
name: 'upstairs-hall'
resource: https://www.mytaglist.com/ethClient.asmx/GetTagList
method: POST
value_template: '{{ value_json.d[0].temperature | round(1) }}'
unit_of_measurement: °C
headers:
Content-Type: application/json
Authorization: 'Bearer ~Enter-your-access-token-from-ARC~~'
`

Chandings the XYZ value in ‘{{ value_json.d[XYZ].temperature | round(1) }}’ will give results of different sensors.

Your sensors should now show up in Home Assistant

3 Likes

Hi,
Have doubts of what to put in this line:

value_template: '{{ value_json.d[0].temperature | round(1) }}'

My log is giving the following error:

-03-18 00:52:23 ERROR (MainThread) [homeassistant.config] Invalid config for [sensor.rest]: expected a dictionary for dictionary value @ data['headers']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/sensor.rest/

I have this working for a single sensor.

But I’m confused as to how to get multiple sensors. Right now I’m using the below but it shows up as one sensor with two values (its two physical sensors).

    - platform: rest
    name: 'lower-wineador'
    resource: https://www.mytaglist.com/ethClient.asmx/GetTagList
    method: POST
    value_template: '{{ value_json.d[0].temperature | round(2), value_json.d[1].temperature | round(2) }}'
    unit_of_measurement: °F
    headers:
    Content-Type: application/json
    Authorization: 'Bearer xxx'

I’ve tried instead doing two platforms - but then I get authorization errors as it states that the token has expired. How have others pulled data from various sensors or temp AND humidity from a single sensor?

@Fanta_the_dog - how did you tackle this? I feel like im missing something super obvious

what is your entire sensor config? and which sensor are you trying to pull data from?

And so I generally got myself sorted out (I am certain this can be consolidated or cleaned up, I welcome any suggestions!) - Notice how I’ve converted the temp to Fahrenheit too

sensor uppertemp:
  - platform: rest
    name: 'wineador upper temp'
    resource: https://my.wirelesstag.net/ethClient.asmx/GetTagList
    method: POST
    value_template: '{{ ((float(value_json.d[0].temperature) * 9/5) + 32) | round(1) }}'
    unit_of_measurement: °F
    headers:
      Content-Type: application/json
      Authorization: 'Bearer xxx'

sensor upperhumid:
  - platform: rest
    name: 'wineador upper humidity'
    resource: https://my.wirelesstag.net/ethClient.asmx/GetTagList
    method: POST
    value_template: '{{ value_json.d[0].cap | round(0) }}'
    unit_of_measurement: '%'
    headers:
      Content-Type: application/json
      Authorization: 'Bearer xxx'

sensor lower:
  - platform: rest
    name: 'wineador lower temp'
    resource: https://my.wirelesstag.net/ethClient.asmx/GetTagList
    method: POST
    value_template: '{{ ((float(value_json.d[1].temperature) * 9/5) + 32) | round(1) }}'
    unit_of_measurement: °F
    headers:
      Content-Type: application/json
      Authorization: 'Bearer xxx'

sensor lowerhumid:
  - platform: rest
    name: 'wineador lower humidity'
    resource: https://my.wirelesstag.net/ethClient.asmx/GetTagList
    method: POST
    value_template: '{{ value_json.d[1].cap | round(0) }}'
    unit_of_measurement: '%'
    headers:
      Content-Type: application/json
      Authorization: 'Bearer xxx'

Anyone figured out a good way to make this work with the API auth changes in later versions of Home Assistant? The character limit is a drag.

It’s not pretty. But I’m using a proxy that injects the key.

That’s what I ended up doing too. Did you ever come up with a workaround for Home Assistant restarts? It will overwrite my proxy config in the URL calling settings of my tags any time I reboot Home Assistant. That’s a bit annoying. Haven’t gotten around to writing a script to fix that.

I have the ip address of the tag manager in Trusted Networks entry of auth_providers

homeassistant:
  customize: !include customize.yaml
  auth_providers:
  - type: homeassistant
  - type: trusted_networks
    trusted_networks:
      - 192.168.5.101/32

but I continually get this error in the logs

Login attempt or request with invalid authentication from 192.168.5.101

I dont have any push notifications setup

I find it easier to make one rest call and read the data into a sensor instead of making multiple calls to GetTagList for each sensor. You can then parse that sensor data into multiple sensors with attributes.

Hi @khouse75, I’m interested in your approach but I’m confused what the value_template would be for this initial sensor to pull in all the data for the state of this sensor. Do you have the config you can share for the initial sensor and an example of a second sensor parsed from the main sensor?

I’m having this same problem. Has anyone figured out how to fix it?