Lock Down API for the UK using HA REST

Let me strat by saying that i didn’t create this, i have copied this from a twitter post, which i have linked to,

Original twitter post with screenshots of the code in the follow up.
https://mobile.twitter.com/nicktheguitar/status/1315933472742150144

I just thought that it would easier for people to copy & pasta ( before some clever sod makes an Integration for UK GOV API https://coronavirus.data.gov.uk/developers-guide )

This uses the awesome API from https://www.lockdownapi.com/

Replace XXX with the first part of your postcode

- platform: rest
  name: Lockdown Update
  resource: 'https://www.lockdownapi.com/XXX'
  json_attributes:
  - lockdownstatus
  - nonessentialshops
  - twohouseholds
  - gymsandfitness
  - meetoutdoors
  - pubsandrestuarants
  value_template: 'OK'
  scan_interval:
    minutes: 61

- platform: template
  sensors:
    lockdown_status:
      friendly_name: Lockdown status is
      value_template: '{{ states.sensor.lockdown_update.attributes["lockdownstatus"] }}'
    nonessential_shops_open:
      friendly_name: Non-Essential Shops are open?
      value_template: '{{ states.sensor.lockdown_update.attributes["nonessentialshops"] }}'
    two_households_meet:
      friendly_name: Two Households can meet?
      value_template: '{{ states.sensor.lockdown_update.attributes["twohouseholds"] }}'
    gyms_and_fitness_open:
      friendly_name: Gyms Are Open?
      value_template: '{{ states.sensor.lockdown_update.attributes["gymsandfitness"] }}'
    meet_outdoors:
      friendly_name: Can We Meet Outdoors?
      value_template: '{{ states.sensor.lockdown_update.attributes["meetoutdoors"] }}'
    pubs_and_restuarants_open:
      friendly_name: Pub Are Open?
      value_template: '{{ states.sensor.lockdown_update.attributes["pubsandrestuarants"] }}'

@nicktheguitar is the man that created and posted on twitter

2 Likes

should line 2 read :

name: lockdown_update

?

Seems to work with out it for me, I think that it’s like the friendly name so doesn’t need the underscore.

Pretty cool.
I have no use of it since I’m not from UK, but that is clever.
I would probably add an automation to trigger a notification when something changes.
But do you really need 61 minutes scan interval?
Isn’t once a day enough?

The automation you describe is exactly what I setup once I got it working.

I’ve got it running every 30 minutes I think, but that was a guess as I didn’t really know how often it would be changed.