MQTT per-entity feed for status and state

Perhaps it was regarded as so trivial a use of templates that no one documented it, but I’m a bit stuck.

I’m trying to create some remote keypads, run by ESP8266 modules that link through WiFi to MQTT. They need to be able to transmit state set requests when the buttons are pushed, and they need to be able to have the lights in the button mirror the state of the device.

It makes no sense to have every keypad get every event for the entire house, when it just needs to be subscribed to a few. So while mqtt_eventstream is great, it’s a firehose, and I need to be able to sip…

Specifically, what I’m looking for is to take the Events feed, and send it to MQTT, as appropriately formatted Topics, i.e.

homeassistant/switch.kitchen/state off homeassistant/light.living_room_globe/state on

There are times it would be useful to simply dump the whole state, i.e.

homeassistant/thermostat.whole_house/state {"temperature":69.6, "max_temp":85.6, "mode":"heat", "current_operation":"idle", "fan":false, "away_mode":false, "current_temperature":70.5, "humidity":48, "target_temp_high":69.6, "target_humidity":35.0, "target_temp_low":69.6, "friendly_name":"Whole House", "unit_of_measurement":"°F", "min_temp":"54.8 @ 05:32:01 20-03-2016"}

But even then, it could be broken down as:

homeassistant/thermostat.whole_house/temperature/state 69.6 homeassistant/thermostat.whole_house/mode/state heat homeassistant/thermostat.whole_house/current_operation/state idle homeassistant/thermostat.whole_house/fan/state off homeassistant/thermostat.whole_house/away_mode/state off homeassistant/thermostat.whole_house/current_temperature/state 70.5 homeassistant/thermostat.whole_house/humidity/state 48

It would be great to be able to set from MQTT, i.e.

homeassistant/thermostat.whole_house/temperature/set 71.1 homeassistant/switch.kitchen/set toggle homeassistant/light.living_room_globe/set {"brightness":128, "rgbcolor":[128,0,0], "state":"on", "transition":5}

I guess I could use /api/services/toggle or turn_on or turn_off…can I do a scene invocation through the API as well?

"POST /api/services/homeassistant/turn_off HTTP/1.1"

Thanks in advance for any help you can provide.

I would use an mqtt switch in home assistant, and setup command and state topics. Let the keypad subscribe to the command topic and publish to the state topic.

To connect and control other devices through the keypad I would use automations and scenes if multiple state changes are needed.

I’m not seeing the difficulty here so I might have misunderstood what your goal is.