Skip to main content

Valve entity

A valve entity controls valve devices such as the water or gas valves in your home. Derive a platform entity from homeassistant.components.valve.ValveEntity.

Properties

tip

Properties should always only return information from memory and not do I/O (like network requests). Implement update() or async_update() to fetch data.

NameTypeDefaultDescription
current_valve_positionint | NoneNoneThe current position of the valve where 0 means closed and 100 is fully open. This attribute is required on valves with reports_position = True, where it's used to determine state.
is_closedbool | NoneNoneIf the valve is closed or not. Used to determine state for valves that don't report position.
is_closingbool | NoneNoneIf the valve is closing or not. Used to determine state.
is_openingbool | NoneNoneIf the valve is opening or not. Used to determine state.
reports_positionboolRequiredIf the valve knows its position or not.

Device classes

ConstantDescription
ValveDeviceClass.WATERControl of a water valve.
ValveDeviceClass.GASControl of a gas valve.

States

The state is defined by setting it's properties. The resulting state is using the ValveState enum to return one of the below members.

ValueDescription
OPENINGThe valve is in the process of opening to reach a set position.
OPENThe valve has reached the open position.
CLOSINGThe valve is in the process of closing to reach a set position.
CLOSEDThe valve has reached the closed position.

Supported features

Supported features are defined by using values in the ValveEntityFeature enum and are combined using the bitwise or (|) operator.

ValueDescription
OPENThe valve supports being opened.
CLOSEThe valve supports being closed.
SET_POSITIONThe valve supports moving to a specific position between opened and closed.
STOPThe valve supports stopping the current action (open, close, set position)

Methods

Open valve

Only implement this method if the flag SUPPORT_OPEN is set. For valves that can set position, this method should be left unimplemented and only set_valve_position is required.

class MyValve(ValveEntity):
# Implement one of these methods.

def open_valve(self) -> None:
"""Open the valve."""

async def async_open_valve(self) -> None:
"""Open the valve."""

Close valve

Only implement this method if the flag SUPPORT_CLOSE is set. For valves that can set position, this method should be left unimplemented and only set_valve_position is required.

class MyValve(ValveEntity):
# Implement one of these methods.

def close_valve(self) -> None:
"""Close valve."""

async def async_close_valve(self) -> None:
"""Close valve."""

Set valve position

Only implement this method if the flag SUPPORT_SET_POSITION is set. This method must be implemented in valves that can set position.

class MyValve(ValveEntity):
# Implement one of these methods.

def set_valve_position(self, position: int) -> None:
"""Move the valve to a specific position."""

async def async_set_valve_position(self, position: int) -> None:
"""Move the valve to a specific position."""

Stop valve

Only implement this method if the flag SUPPORT_STOP is set.

class MyValve(ValveEntity):
# Implement one of these methods.

def stop_valve(self) -> None:
"""Stop the valve."""

async def async_stop_valve(self) -> None:
"""Stop the valve."""