Read & control HA from ESPHome

I have Zigbee devices integrated into HA that i want to incorporate into an ESPHome device. Can anyone point me towards example code to do this?

I need to read the temperature from a TH sensor (br_th), and how to declare and control 2 switches (br_sw1 & br_sw2).

Home Assistant Sensor — ESPHome

1 Like

This looks easy enough.

Now to figure out the HA switches.

Thanks

I might bring all sensors into ha and setup automations inside ha for business logic.

I’m 99% positive that i found a good example for both reading and controlling HA sensors & switches on this project:

I was mistaken. I’m still trying to figure out how to define a switch in ESPHome that will control a switch connected to HA via Zigbee.

Again, why don’t you bring sensor data to home assistant as a sensor and solve this problem inside home assistant automation (when x happens, turn on switch)

At worst, you are allowed to execute ha service calls from esp home (switch.turn_on)

Because i was asking HOW to turn an HA-connected switch FROM ESPHome.

it would be great to have a reasoning around it, rather than going with usual way. it might be a valid case when you want esphome to run as a standalone tool, but I want it because I want it does not answer my question.

to answer your initial question, you can call home assistant services from esphome.

The REASON is because I asked HOW, that’s all that’s needed. Thanks for the reply.

and how do you think it is going to be helpful to learn and improve. we might find a better question to ask rather than the original question.

I asked VERY specific questions. The reasons do not matter.

1 Like

In this forum you find a thread/post on how to ask a good question - may take some time to read it!

This is exactly what I do and I can control all ha entities like this directly from my esphome nodes thanks to the native api.

# In some trigger
on_...:
  # Simple
  - homeassistant.service:
      service: switch.toggle
      ...

Look at my original post and tell me how i asked “wrong”?