Publish state of Power Suply Comoponent to MQTT

Is there a way to publish the state of the Power Supply Component to a MQTT topic? I´m wokring on a dimmerpack wich is also probing the Power Input of the external Powersuply, to check if the External Powersuply is realy suplying power when switched on.

Happy new year to all of you!

greetz

roque

Use automation with state trigger + mqtt.publish

Thanks for your reply , i tried attaching on_state trigger to the PSU

power_supply:
  - id: 'EXT_PSU'
    pin: GPIO12
    on_state:
         then: .........

I also tried on_press / on_release , however the editor gives me an error that [on_state] is an invalid option for [0]. Sadly the Power Suply Component documentation also doesnt give much information.

greetz

Roque

That’s syntax for ESPHome automations. Try using the Home Assistant automation UI.

Im kinda confused, if i should use the Home Assistant automation UI i need to set that up inside HA then, but i can´t see the state of the Power Suply Component submittet neither thru the native API nor thru mqtt. How can i check the state of the Power Suply Component fom there?

Create an automation so that whenever the power supply status changes, it publishes it to MQTT. Or you could just use the native api with this component:

I tried several attemps for an automation now, the problem is i can´t figure out how to read the state from the Power Suply Component. If i look in the esphome wiki for automations somehow i need to treat the PSC as a binary sensor when reading the state but whatever i tried the Editor will tell me it is not supported for “power_supply” or when trying within a lambda the compiler will exit with an error like this:

src/main.cpp:942:20: error: 'class esphome::power_supply::PowerSupply' has no member named 'state'

Wich makes sense as the PSC is its own class and not listed under binary sensors. Is it possible that there is no way to read the state of the Power supply?

Nope, it’s possible. What’s the name of your entity for your power supply in HA?

I had a close look agian inside the HA entities i can find all my binary sensors, sensors, text sensors and light components but i can´t find a entity for the Power Suply Component.

Just to make clear I´m talking about this ESPhome Component: https://esphome.io/components/power_supply.html

The Component is defined as follow in my ESPhome yaml:

power_supply:
  - id: 'EXT_PSU'
    pin: GPIO12
    

Oh, oh, oh. How confused I was. I thought you wanted to export the Home Assistant Raspberry Pi power supply component into ESPHome.
You should use the switch.output component for this.

1 Like

I already tried the generic switch output component, that way i can manually control the output, but the state of the generic switch is not updated if the PSU output is switched on by the Power Supply Component.

I will put a feature request on the ESPhome github page.

@KTibow Thanks a lot for your patience. Happy new year to you!

greetz
Roque

Also interested in this! Are there any updates on the issue / did you open an issue on GitHub and do you have a link to it?

1 Like