Skip to content

Return the listeners with the template result for the websocket api#39925

Merged
bdraco merged 2 commits intohome-assistant:devfrom
bdraco:return_listeners_with_template_result
Sep 11, 2020
Merged

Return the listeners with the template result for the websocket api#39925
bdraco merged 2 commits intohome-assistant:devfrom
bdraco:return_listeners_with_template_result

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented Sep 11, 2020

Backstory

@SeanPM5 had some templates that were listening for all states which needed to be cut down to just the needed states. Its hard to tell what the template will listen for currently. To solve this we can return what the template is listening for in the websocket api response. cc @bramkragten

I'm not sure if there are enough users with lots of 'all states' templates that
we should try to get this into 0.115

Proposed change

Return the listeners with the template result for the websocket api

This should make it much easier to find inefficient templates

The thinking is we could update /developer-tools/template to show
what the template is listening for to help make more efficient
templates.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

Example api responses

{
	"id": 24,
	"type": "event",
	"event": {
		"result": "The temperature is 25 \u00b0C.\n\nThe sun will rise at 2020-09-11 07:04:11.\n\nFor loop example getting 3 entity values:\n\nThe security is disarmed, the david office unknown 2 is off and the main fridge usage is 0 W.",
		"listeners": {
			"all": true,
			"entities": [],
			"domains": []
		}
	}
}
{
	"id": 32,
	"type": "event",
	"event": {
		"result": "The temperature is 25 \u00b0C.\n\nThe sun will rise at 2020-09-11 07:04:11.\n\nFor loop example getting 3 entity values:\n\nThe dark sky is partlycloudy.",
		"listeners": {
			"all": false,
			"entities": ["weather.dark_sky", "sun.sun"],
			"domains": ["weather"]
		}
	}
}

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@bdraco bdraco merged commit 741487a into home-assistant:dev Sep 11, 2020
@bdraco bdraco deleted the return_listeners_with_template_result branch September 11, 2020 18:18
@bdraco
Copy link
Copy Markdown
Member Author

bdraco commented Sep 11, 2020

Tagging this for 0.115 since I think it a small change, and it is going to be difficult and frustrating for users to figure out which state changed events the template is listening for otherwise.

If someone feels otherwise, please remove the milestone.

@bdraco bdraco added this to the 0.115.0 milestone Sep 11, 2020
bdraco added a commit to bdraco/home-assistant that referenced this pull request Sep 11, 2020
bdraco added a commit to bdraco/home-assistant that referenced this pull request Sep 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants