How to define valve component

I have on of the “tuya wifi smart valve controller” with a WB3S module converted to ESPhome. (example:

This works great, but I want the valve to show up as a valve in Home assistant using the “valve” integration: Valve - Home Assistant

The only reference to a valve in ESPhome I can find is in the sprinkler controller: Sprinkler Controller — ESPHome

Is there a way to define valves in ESPhome config that aren’t sprinklers? Or is this not implemented yet?

That depends on how it is defined I think. If it’s a switch then you can set any category that HA supports.

  • entity_category (Optional, string): The category of the entity. See Entity | Home Assistant Developer Docs for a list of available options. Requires Home Assistant 2021.11 or newer. Set to "" to remove the default entity category.

When setting the entity_category i’m getting this error:

I don’t think entity_category of a switch is what I’m looking for, see the definition here: Entity | Home Assistant Developer Docs.

I think you define it as a switch then reference it in the sprinkler component:

I haven’t tried it though so just guessing.

This would be my guess.

It seems HA valves came out in Jan, and there hasn’t been an ESPHome release since Dec, so maybe (?) in the coming Feb release?

Edit… A comment on Discord.

Ooh that makes sense, thanks for the screenshot! (I didn’t check discord)

For people in the same boat: for now you can just define a switch in esphome, and in the device in home assistant, you can pick valve in the “show as” drop down box for the options for that switch. This creates a valve entity and hides the original switch one (but it’s still being used in the background). Now you have a real-ish valve and can use valve.<name>!

Screenshot 2024-02-13 at 01.26.39

This way there should be minimal changes once the valve component in esphome lands.


If you’re using it like a switch and not a valve, what’s the difference? You get to use valve.turn_on instead of switch.turn_on? Does it at least use PWM to control how much it opens/closes? If not, it’s just a switch and i’m not sure what a “valve integration” would add in this situation or any situation when the integrations you would need to create a valve are already available(pwm/ledc/Output). The only difference wold be the one you mentioned, it would have it’s own valve domain now. You do have both the valve/switch and you added the hidden switch entity to you’re HA Controls card for some reason so… maybe you’re just particular and having it’s own domain is just a significant detail to you and not so much for me?

Correct, I’m particular and want the valves having their own domain. This way i can use and valve.close and i can define it’s a valve for water in the device class.
Would it work with a switch? yes. But it’s a valve so I want to use the valve entity! Even comes with a nice little valve icon!

1 Like

Ya, i kind of get that especially for those with pwm valves and quickly calling a % open/close. Im just not quite OCD to where it bothers me one way or the other, but to each his own, its your home build it however it pleases you. I was really just curious more than anything and i had forgot about the valve entity being added in HA untill i saw your post. I dont quite understand that either. You cant directly create valve entities, but its a “building block” for other integrations.

I assume there are other popular integrations for some hardware that created valve entiities but HA didnt have the valve domain and this new integration is to fix that?
Or do you think its more for esphome users and creating valve entities there?

ESPHome does not yet support the valve entity type.

Regarding the sprinkler component, it simply uses switch components as “valves” – do not confuse this with a valve entity in HA. They are not the same/interchangeable.

If there is sufficient demand and/or if someone does a PR to support valve entities, I see no reason why we wouldn’t add it to ESPHome so it’s properly supported. :smile:

1 Like

Right, we know its not a supported entity. The question was, if it will be supported because, the HA documentation states that its valve entity is basically only there to facilitate other integrations to being able to create the entity. What integrations? I dont personally think its a high priority but, it seems like a fair assumption to assume Esphome would be one of those “other integrations” the HA docs are referring to.

1 Like

The question was, if it will be supported

I see no reason why it would not eventually be supported – I guess the remaining question then is just “when?”. :slight_smile:

1 Like

Bingo! I’ve never tried to change Esphome code and submit a PR but, I would think it wouldn’t be all that difficult to do this would it? I mean you could almost go copy something like the Fan integration, change the names/domains to a valve and link it to an Output it would seem to me. It’s basically the exact same functionality as a fan, if you need control of how much it opens/closes. For On/Off or Binary valves it’s the same thing. It’s basically just a gpio switch renamed or it’s linked to a gpio ouptut and does on/off.

Am I oversimplifying this?

1 Like

Having some patience paid off, thanks to the person that implemented/add it!

1 Like