cgarwood / hatouch

Touch Interface for Home Assistant
31 stars 3 forks source link

Create REST endpoint for Notifications #5

Closed cgarwood closed 6 years ago

cgarwood commented 7 years ago

HATouch has a notifications area in the top menubar. We should create a simple REST endpoint so HomeAssistant can push notifications to the HATouch frontend.

Simple PHP endpoint that dumps JSON encoded notifications into flat text files in a notifications folder? This eliminates the dependency on having MySQL or another database engine installed, and we shouldn't have so many notifications that performance becomes an issue with flat files.

cgarwood commented 7 years ago

Started on this in 8a6c5a938b1e2a809a3220c9aec913b0ee918bde

You can POST json to api.php?service=notify and it will save it in the notifications folder as [timestamp].json

Need to add a GET request to pull all current notifications, and add GET or POST requests to remove notifications.

cgarwood commented 6 years ago

Since moving to the HomeAssistant websocket API, we can pull notify events straight from the Event Stream. No need to have a special API that HomeAssistant calls.

Downside is that HATouch has to be loaded to receive the notification, but thats an OK tradeoff as important notifications will be sent to my phone anyway, and HATouch should be always running on the devices even if the screen is off.

Removed in 666fc9ee80d4431a0691ef8013e43080c4b41b65