Skip to content

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

@zoe-codez

Description

@zoe-codez

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions