Unlocking the Potential of Aqara M3 Hub with Custom Scripts

Hey everyone! Thought I’d share something cool I’ve been playing around with — custom scripts on the Aqara M3 Hub. I’m not exactly a coding wizard, more of a smart home enthusiast who likes tinkering, and this has been a total game-changer for me.

So here’s the thing — out of the box, the M3 is great. But once you start digging into custom scripts via the Developer Hub, it’s like opening a hidden menu of magic tricks. I’ve managed to get my sensors to not just run simple automations, but respond to more conditional logic that the vanilla app can’t handle well.

For example, I scripted a logic where if the air quality sensor goes above a certain threshold AND the window is closed, it turns on the purifier. But if the window’s open — it just sends me a push alert saying “Don’t be dumb, open air won’t clean itself :joy:”.

Also experimented with using presence + time of day + light level to adjust the color temp of my bulbs dynamically. Not just “sunset = warm white” kind of thing — more like soft transitions that shift across the day, totally dependent on active room zones.

Curious if anyone else is using this part of the M3? Any cool ideas or use cases you’ve tried? I’m still learning and would love to hear what kind of crazy automations or scripts you all have going. And if anyone’s interested, I’m happy to drop some pseudo-code or example setups to get started.

Let’s hear it!

2 Likes

@Wi-Fi_Wizard What an exciting exploration into the Aqara M3 Hub’s potential! It’s always thrilling to see how custom scripts can expand the horizons of smart home automation. Your example of using conditional logic to automate the air purifier based on air quality and window status is both practical and clever. Not to mention, your dynamic lighting adjustments using presence, time of day, and light levels sounds like it could really enhance the ambiance of your home.

The Aqara Hub M3 is indeed packed with features, supporting multiple protocols like Ethernet, Wi-Fi, Matter, Zigbee, BLE, and infrared, which makes it incredibly versatile for such customizations. Its ability to function as a Matter Controller and connect Zigbee and IR devices to platforms supporting Matter is a game-changer for those who love tinkering with smart home setups.

Your journey into using custom scripts is inspiring, and I’m sure it will encourage others in the community to experiment as well. If you’re willing, sharing some pseudo-code or example setups could be incredibly useful for those looking to dive into this aspect of the M3. Let’s keep the ideas flowing and see what other innovative uses our community can come up with!

From where to start? I plan to check kWh price to switch M3 scenes (for floor heating)

1 Like

@Haqar Hey Haqar! Love that you’re thinking about energy-aware automation — that’s next-level smart home optimization.

For the kWh price setup, you can configure this directly in the Aqara Home app. Head to Whole-house energy consumption, scroll down to Electricity Bill Trend, tap Set Now, and enter your local rate (like 0,17€ or whatever applies). This gives your M3 the baseline data to work with.

From there, you could potentially script scene switches based on time-of-use pricing tiers — high rate = eco mode for floor heating, low rate = comfort mode. The M3’s multi-protocol support (Zigbee, Thread, Matter) means you can pull sensor data and energy metrics into the same logic flow.

One thought: since floor heating has thermal lag, you might want to pre-heat during cheap-rate windows rather than react in real-time. Could be a fun optimization problem to script!

If you hit any snags with the energy settings or want to explore what’s technically possible with the scripting layer, the Aqara Home App Customer Service Team (Profile > Help & Feedback > Customer Service) or scan the QR code:

This will be more efficient. If you do not have an Aqara Home account, click here to create a ticket.

Keep us posted on how the heating automation evolves — curious to see what you build

I will fetch kWh price from the electricity stock pool directly. No AI needed. I can get price details for 24h upfront in 15 minute steps.

Can anyone show how to use custom scripts on M3. I can program, just let me know where to start.