[GH-ISSUE #173] [Feature]: Smart Plugs MQTT Support #113

Closed
opened 2026-05-06 12:25:58 +02:00 by BreizhHardware · 10 comments

Originally created by @tobiaswaelde on GitHub (Jan 29, 2026).
Original GitHub issue: https://github.com/maziggy/bambuddy/issues/173

Originally assigned to: @maziggy on GitHub.

Problem or Use Case

I have a shelly (with Zigbee2MQTT) to monitor the printers energy consumption and to turn it on/off.

Proposed Solution

It would be nice if I could set the MQTT topic to which the energy is published. And maybe set a multiplication factor (the Shellies publish power in W and energy in Wh)

The value published to the main MQTT topic is a JSON Object. Single values are published to subtopics.

{
  "ac_frequency_l1": 49.94,
  "ac_frequency_l2": 49.98,
  "current_l1": 0.125,
  "current_l2": 0,
  "device": {
    "friendlyName": "shelly-working-room",
    "ieeeAddr": "XXXXXXXXXXXXXXXX",
    "manufacturerID": 5264,
    "manufacturerName": "Shelly",
    "model": "XXXX-XXXXXXXX-SWITCH",
    "networkAddress": 22486,
    "powerSource": "Mains (single phase)",
    "type": "Router",
    "zclVersion": 8
  },
  "dhcp_enabled": true,
  "energy_l1": 2.056,
  "energy_l2": 0.006,
  "ip_address": "10.8.91.221",
  "linkquality": 87,
  "power_apparent_l1": 9,
  "power_apparent_l2": 0,
  "power_factor_l1": 0,
  "power_factor_l2": 0,
  "power_l1": 8, // <-- This is the power consumption of the Printer in Watt
  "power_l2": 0,
  "power_reactive_l1": 0,
  "power_reactive_l2": 0,
  "produced_energy_l1": 0,
  "produced_energy_l2": 0,
  "state_l1": "ON",
  "state_l2": "OFF",
  "voltage_l1": 228.08,
  "voltage_l2": 225.11,
  "wifi_config": {
    "enabled": true,
    "ssid": "waelde-iot"
  },
  "wifi_status": "got ip"
}

In my special case, l1 is the printer and l2 is a LED strip for my chamber light.

As lot of devices publish JSON instead of single values, we would need two fields

  • Topic: e.g. zigbee/shelly-working-room
  • JSON path: e.g. power_l1 or key.subkey

Alternatives Considered

No response

Feature Category

Smart Plugs

Priority

Nice to have

Mockups or Examples

No response

Contribution

  • I would be willing to help implement this feature

Checklist

  • I have searched existing issues to ensure this feature hasn't already been requested
Originally created by @tobiaswaelde on GitHub (Jan 29, 2026). Original GitHub issue: https://github.com/maziggy/bambuddy/issues/173 Originally assigned to: @maziggy on GitHub. ### Problem or Use Case I have a shelly (with Zigbee2MQTT) to monitor the printers energy consumption and to turn it on/off. ### Proposed Solution It would be nice if I could set the MQTT topic to which the energy is published. And maybe set a multiplication factor (the Shellies publish power in W and energy in Wh) The value published to the main MQTT topic is a JSON Object. Single values are published to subtopics. ```jsonc { "ac_frequency_l1": 49.94, "ac_frequency_l2": 49.98, "current_l1": 0.125, "current_l2": 0, "device": { "friendlyName": "shelly-working-room", "ieeeAddr": "XXXXXXXXXXXXXXXX", "manufacturerID": 5264, "manufacturerName": "Shelly", "model": "XXXX-XXXXXXXX-SWITCH", "networkAddress": 22486, "powerSource": "Mains (single phase)", "type": "Router", "zclVersion": 8 }, "dhcp_enabled": true, "energy_l1": 2.056, "energy_l2": 0.006, "ip_address": "10.8.91.221", "linkquality": 87, "power_apparent_l1": 9, "power_apparent_l2": 0, "power_factor_l1": 0, "power_factor_l2": 0, "power_l1": 8, // <-- This is the power consumption of the Printer in Watt "power_l2": 0, "power_reactive_l1": 0, "power_reactive_l2": 0, "produced_energy_l1": 0, "produced_energy_l2": 0, "state_l1": "ON", "state_l2": "OFF", "voltage_l1": 228.08, "voltage_l2": 225.11, "wifi_config": { "enabled": true, "ssid": "waelde-iot" }, "wifi_status": "got ip" } ``` In my special case, l1 is the printer and l2 is a LED strip for my chamber light. As lot of devices publish JSON instead of single values, we would need two fields - Topic: e.g. `zigbee/shelly-working-room` - JSON path: e.g. `power_l1` or `key.subkey` ### Alternatives Considered _No response_ ### Feature Category Smart Plugs ### Priority Nice to have ### Mockups or Examples _No response_ ### Contribution - [ ] I would be willing to help implement this feature ### Checklist - [x] I have searched existing issues to ensure this feature hasn't already been requested
BreizhHardware 2026-05-06 12:25:58 +02:00
Author
Owner

@maziggy commented on GitHub (Jan 29, 2026):

Not sure if I understand it. I assume the Shelly is connected to Home Assistant or such, but not to Bambuddy?!

<!-- gh-comment-id:3817729809 --> @maziggy commented on GitHub (Jan 29, 2026): Not sure if I understand it. I assume the Shelly is connected to Home Assistant or such, but not to Bambuddy?!
Author
Owner

@tobiaswaelde commented on GitHub (Jan 29, 2026):

The shelly is connected to Zigbee and I use Zigbee2MQTT to get the data to my MQTT.
I am not using HomeAssistant :) My whole networks is built on MQTT and I have a custom Software (I am currently in v8, so the screenshots are a bit outdated)

<!-- gh-comment-id:3817801298 --> @tobiaswaelde commented on GitHub (Jan 29, 2026): The shelly is connected to Zigbee and I use [Zigbee2MQTT](https://www.zigbee2mqtt.io/) to get the data to my MQTT. I am not using HomeAssistant :) My whole networks is built on MQTT and I have a [custom Software](https://tobiaswaelde.com/projects/smarthome-v3) (I am currently in v8, so the screenshots are a bit outdated)
Author
Owner

@maziggy commented on GitHub (Jan 29, 2026):

And what should Bambuddy do with it? Still don't get it!

<!-- gh-comment-id:3817844242 --> @maziggy commented on GitHub (Jan 29, 2026): And what should Bambuddy do with it? Still don't get it!
Author
Owner

@tobiaswaelde commented on GitHub (Jan 29, 2026):

It should use it as input source for tracking energy usage

<!-- gh-comment-id:3817964067 --> @tobiaswaelde commented on GitHub (Jan 29, 2026): It should use it as input source for tracking energy usage
Author
Owner

@maziggy commented on GitHub (Jan 29, 2026):

Got it! So basically you want to subscribe to MQTT and use the data for Bambuddy stats.

<!-- gh-comment-id:3818052677 --> @maziggy commented on GitHub (Jan 29, 2026): Got it! So basically you want to subscribe to MQTT and use the data for Bambuddy stats.
Author
Owner

@maziggy commented on GitHub (Jan 30, 2026):

Please use branch feature/173 and let me know if it works for you.

Docs -> https://wiki.bambuddy.cool/features/smart-plugs/?h=mqtt#option-3-mqtt-monitor-only

<!-- gh-comment-id:3822289709 --> @maziggy commented on GitHub (Jan 30, 2026): Please use branch feature/173 and let me know if it works for you. Docs -> https://wiki.bambuddy.cool/features/smart-plugs/?h=mqtt#option-3-mqtt-monitor-only
Author
Owner

@tobiaswaelde commented on GitHub (Jan 30, 2026):

WOW, that was fast 🚀
Thank you so much. It works now in my case.

Image

But it would be nice if there was also an option to extract the values from different topics.
I also think using one multiplier for power and one for energy should adapt better for all users.

What do you think about adding three sections to the Smart Plug settings:

  1. Power
  • Topic (either for JSON value or raw value)
  • JSON path (only if topic has JSON value)
  • Multiplier
  1. Energy
  • Topic (either for JSON value or raw value)
  • JSON path (only if topic has JSON value)
  • Multiplier
  1. State
  • Topic (either for JSON value or raw value)
  • JSON path (only if topic has JSON value)
  • ON-value ("ON" for some devices, sometimes could be true for other devices)
<!-- gh-comment-id:3823550282 --> @tobiaswaelde commented on GitHub (Jan 30, 2026): WOW, that was fast 🚀 Thank you so much. It works now in my case. <img width="924" height="495" alt="Image" src="https://github.com/user-attachments/assets/f445b3bb-3db5-4d72-9d99-9d78116dad37" /> But it would be nice if there was also an option to extract the values from different topics. I also think using one multiplier for power and one for energy should adapt better for all users. What do you think about adding three sections to the Smart Plug settings: 1. Power - Topic (either for JSON value or raw value) - JSON path (only if topic has JSON value) - Multiplier 2. Energy - Topic (either for JSON value or raw value) - JSON path (only if topic has JSON value) - Multiplier 3. State - Topic (either for JSON value or raw value) - JSON path (only if topic has JSON value) - ON-value (`"ON"` for some devices, sometimes could be `true` for other devices)
Author
Owner

@maziggy commented on GitHub (Jan 30, 2026):

Plese use branch feature/173 and do a git pull. Can you please test and give feedback? I don't have the required entities in my HS setup. Thanks.

<!-- gh-comment-id:3823706659 --> @maziggy commented on GitHub (Jan 30, 2026): Plese use branch feature/173 and do a git pull. Can you please test and give feedback? I don't have the required entities in my HS setup. Thanks.
Author
Owner

@tobiaswaelde commented on GitHub (Jan 30, 2026):

Looks already really nice 👍
But the JSON path seems not to be optional.

Image

Power works, Energy does not work

Image Image
<!-- gh-comment-id:3824430443 --> @tobiaswaelde commented on GitHub (Jan 30, 2026): Looks already really nice 👍 But the JSON path seems not to be optional. <img width="403" height="486" alt="Image" src="https://github.com/user-attachments/assets/514c09f4-ec96-4815-9076-976168217949" /> Power works, Energy does not work <img width="620" height="548" alt="Image" src="https://github.com/user-attachments/assets/d3b4fbf0-7f97-4d8c-b75d-3c38d0fecc36" /> <img width="619" height="348" alt="Image" src="https://github.com/user-attachments/assets/100020ab-f613-4344-873e-13ae0a2a2ec7" />
Author
Owner

@maziggy commented on GitHub (Jan 30, 2026):

Updated branch feature/173. Please let me know.

It may be neccessary to recompile the frontend after git pull. cd frontend && npm run build

<!-- gh-comment-id:3824553099 --> @maziggy commented on GitHub (Jan 30, 2026): Updated branch feature/173. Please let me know. It may be neccessary to recompile the frontend after git pull. cd frontend && npm run build
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#113
No description provided.