Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entity proxies should have the ability to actively manage state #54

Open
zoe-codez opened this issue Jul 15, 2024 · 0 comments
Open

Entity proxies should have the ability to actively manage state #54

zoe-codez opened this issue Jul 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@zoe-codez
Copy link
Member

zoe-codez commented Jul 15, 2024

Context

The automation.managed_switch workflow is very useful, being able to take a callback and list of entities to react to, then turning that into service calls.

automation.managed_switch({
  context,
  entity_id: "switch.dragonfly_lights",
  onUpdate: [officePlants, meetingMode, isHome],
  shouldBeOn() {
    if (!isHome.is_on) {
      return false;
    }
    if (meetingMode.is_on) {
      return true;
    }
    return !automation.time.isBetween("AM1:30", "PM4");
  },
});

Synapse builds on the pattern with SettableConfiguration, which is set on specific properties across the library.

synapse.switch({
  context,
  is_on: {
    current() {
      return !binary_sensor.is_on;
    },
    onUpdate: [binary_sensor],
  },
  name: "Example switch",
});

For hass internal domains, this type of functionality should be available directly on the entity proxy.

hass.refBy.id("switch.example").manage({
  current() {
	return true | "on"
  },
  onUpdate: [],
  schedule: ...
})

This will require some manual mapping of domains to specific service calls in order to work correctly

@zoe-codez zoe-codez added the enhancement New feature or request label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant