I have successfully integrated the SpaceAPI component into my HA installation.
I had to create a binary rest-sensor:
binary_sensor:
- platform: rest
name: "Front Door"
resource: "http://IP_ADDRESS/ENDPOINT"
value_template: '{{ value_json["state"]["open"] }}'
Which, in turn, had to be added to the SpaceAPI component configuration:
spaceapi:
space: "HACKERSPACE_NAME"
logo: "URL_FOR_LOGO"
url: "URL"
location:
address: "ADDRESS"
contact:
email: "EMAIL_ADDRESS"
issue_report_channels:
- email
state:
entity_id: binary_sensor.front_door
All this information can be extracted from the Hackerspaces’ JSON endpoint, e.g. https://status.stratum0.org/status.json and yields this JSON response:
{
"version": "0.1",
"isOpen": true,
"since": "2018-06-12T10:55:19.124826",
"openedBy": "Drahflow",
"api": "0.13",
"space": "Stratum 0",
"url": "https://stratum0.org",
"logo": "https://stratum0.org/mediawiki/images/thumb/c/c6/Sanduhr-twitter-avatar-black.svg/240px-Sanduhr-twitter-avatar-black.svg.png",
"location": {
"address": "Hamburger Strasse 273a, Haus A2, 38114 Braunschweig, Germany",
"lon": 10.5211247,
"lat": 52.2785658
},
"contact": {
"phone": "+49 531 287 69 245",
"twitter": "@stratum0",
"email": "[email protected]",
"ml": "[email protected]",
"issue_mail": "cm9oaWViK3NwYWNlYXBpLWlzc3Vlc0Byb2hpZWIubmFtZQ==",
"irc": "irc://chat.freenode.net/#stratum0",
"foursquare": "4f243fd0e4b0b653a35e3ae4"
},
"issue_report_channels": [
"issue_mail"
],
"state": {
"ext_since": 1528793719,
"lastchange": 1528793719,
"open": true,
"icon": {
"open": "http://status.stratum0.org/open_square.png",
"closed": "http://status.stratum0.org/closed_square.png"
},
"trigger_person": "Drahflow",
"lastchange": 1528793719
},
"feeds": {
"blog": {
"type": "atom",
"url": "https://stratum0.org/blog/atom.xml"
},
"wiki": {
"type": "atom",
"url": "https://stratum0.org/mediawiki/index.php?title=Spezial:Letzte_%C3%84nderungen&feed=atom"
},
"calendar": {
"type": "ical",
"url": "https://stratum0.org/calendar/events.ics"
}
}
}
I think it would be much more prudent to have a user only specify this endpoint url and the component creates things like (binary) sensors and maybe a card. I was thinking like this:
spaceapi:
endpoint: "https://status.stratum0.org/status.json"
Don’t you agree? Otherwise, what is the purpose of having a SpaceAPI component? Am I missing something obvious?