Sensor with information about your COVID19 test (germany)

Tags: #<Tag:0x00007f3264777f70> #<Tag:0x00007f3264777ea8> #<Tag:0x00007f3264777de0>

Today I got tested for COVID19. In germany you receive a qr-code with a custom URL and a PIN to view your test result online. I am too lazy to look for the result every few hours, so the nerd in me thought a sensor and an automation in Home Assistant would be pretty awesome. Digging into it I found they are using an API to display the results on their website. Jackpot! :partying_face:

May I present you my corona sensor using the REST integration.

sensor:
  - platform: rest
    name: corona_testresult
    resource: 'https://ixpatient.com/ixshare/ticket/INSERT-TEST-ID-HERE'
    method: POST
    payload: '{ "pin" : "INSERT-PIN-HERE" }'
    value_template: '{{ value_json.results[0].headline }}'
    json_attributes_path: '$.results[0]'
    json_attributes:
      - result
      - image
      - type
    headers:
      Content-Type: application/json
    scan_interval: 120

And this is my automation which notifies me after on any updates or when my results are available (with german messages). It uses many of the lates new features (thanks for those!). To use it you have to insert your own notification service.

- id: 'notification_corona'
  alias: 'Benachrichtigung: Corona-Test'
  description: ''
  trigger:
  - platform: state
    entity_id: sensor.corona_testresult
  condition: []
  action:
  - choose:
    - conditions:
      - condition: state
        entity_id: sensor.corona_testresult
        state: positiv
        attribute: image
      sequence:
      - service: notify.your_notification_service
        data:
          title: Corona-Update
          message: Du wurdest positiv getestet!
    - conditions:
      - condition: state
        entity_id: sensor.corona_testresult
        state: negativ
        attribute: image
      sequence:
      - service: notify.your_notification_service
        data:
          title: Corona-Update
          message: Du wurdest negativ getestet.
    default:
    - service: notify.your_notification_service
      data:
        title: Corona-Update
        message: '{{ states("sensor.corona_testresult") }}'
  mode: single

I hope anyone of you guys has some fun with these while waiting at home! Please share your own ideas and improvements.

Stay healthy.

1 Like

And back at you. Good on you for testing, the world needs more testing.

1 Like