Page 1 of 1

Feature Request - Enable/Disable/Trigger Wireless Projection Connection via API

Posted: Thu Aug 13, 2026 8:16 pm
by dsparks156
This would be very useful in my setup where the Pi gets woken up alongside the cars infotainment bus, which typically comes up long before the ignition is on and your in the car (usually unlock or door open), and subsequently stays awake after you get out of the car for a bit.

Works great for having the Pi booted and ready to go by the time im turning the ignition, just like the factory radio, but is equally quite frustrating having my AA connect on me when im not in the car (ie, working on it and it got woken, etc).

Having an API method to disable all wireless projection connectivity and enable it (as well as force reconnect, not sure if this would be useful, depends how it otherwise behaved) would allow me to disable connectivity by default, and then enable it once the ignition is on, or even when the door opens and it seems like someones getting in to make it a little faster. and then disable once again when the ignition turns off (or even the door closes and passenger has left if im trying to keep it on slightly longer)

I also would like to be able to keep the pi awake for a fair bit of time after ignition off, like 15 minutes, but i dont want it connecting to my phone during that. So id then disable connection when the ignition is off.

would get me to the dream CarPI AA setup, where the Pis booted and ready to go before the ignition is on, and just connects as soon as it is basically, like a (good) oem setup.

the pi has 5v whenever the radio is awake (so infotainment bus active), or the Pi is latching it on. the pi shuts down after radio goes to sleep, but if the Pi doesnt finish shutting down before the radio wakes again, the Pi gets stuck in the shutdown state but still has power. I cant mitigate this in a dedicated power management MCU, because im using a carpihat. but, leaving the Pi on for say 15 minutes would sufficiently mitigate it.

Re: Feature Request - Enable/Disable/Trigger Wireless Projection Connection via API

Posted: Fri Aug 14, 2026 8:42 am
by hudiy
Android Auto connection can be managed via the API. In Hudiy, you can disable autostart and manage connecting and disconnecting using e. g. a Python script.

https://github.com/wiboma/hudiy/blob/ma ... ndroidauto (autostart)
https://github.com/wiboma/hudiy/blob/ma ... ed-actions (connect_android_auto_wifi, quit_android_auto)

Using the API, you can check the status of the phone's Bluetooth connection as well as the projection status:

https://github.com/wiboma/hudiy/blob/ma ... eStatus.py
https://github.com/wiboma/hudiy/blob/ma ... nStatus.py
https://github.com/wiboma/hudiy/blob/ma ... hAction.py
https://github.com/wiboma/hudiy/blob/main/api/Api.proto

Below, we provide an example that triggers the connection to Android Auto 10 seconds after the phone connects via Bluetooth. After another 10 seconds from the start of the projection, it terminates it.

This can be expanded to check the ignition state and establish/terminate the connection depending on that state.

Code: Select all

#
#  Copyright (C) Hudiy Project - All Rights Reserved
#

import threading
import common.Api_pb2 as hudiy_api
from common.Client import Client, ClientEventHandler


class EventHandler(ClientEventHandler):

    def on_hello_response(self, client, message):
        print(
            "received hello response, result: {}, app version: {}.{}, api version: {}.{}"
            .format(message.result, message.app_version.major,
                    message.app_version.minor, message.api_version.major,
                    message.api_version.minor))

        set_status_subscriptions = hudiy_api.SetStatusSubscriptions()
        set_status_subscriptions.subscriptions.append(
            hudiy_api.SetStatusSubscriptions.Subscription.PROJECTION)
        set_status_subscriptions.subscriptions.append(
            hudiy_api.SetStatusSubscriptions.Subscription.PHONE)
        client.send(hudiy_api.MESSAGE_SET_STATUS_SUBSCRIPTIONS, 0,
                    set_status_subscriptions.SerializeToString())

    def on_projection_status(self, client, message):
        print("projection status, active: {}".format(message.active))

        if message.active:
            threading.Timer(
                10.0, 
                self.dispatch_action, 
                args=[client, "quit_android_auto"]
            ).start()

    def on_phone_connection_status(self, client, message):
        print("phone connection status: {}, name: {}".format(
            message.state, message.name))

        if message.state == hudiy_api.PhoneConnectionStatus.PHONE_CONNECTION_STATE_CONNECTED:
            threading.Timer(
                10.0, 
                self.dispatch_action, 
                args=[client, "connect_android_auto_wifi"]
            ).start()

    def dispatch_action(self, client, action_name):
        dispatch_action = hudiy_api.DispatchAction()
        dispatch_action.action = action_name
        client.send(hudiy_api.MESSAGE_DISPATCH_ACTION, 0,
                    dispatch_action.SerializeToString())


def main():
    client = Client("projection status example")
    event_handler = EventHandler()
    client.set_event_handler(event_handler)
    client.connect('127.0.0.1', 44405)

    active = True
    while active:
        try:
            active = client.wait_for_message()
        except KeyboardInterrupt:
            break

    client.disconnect()


if __name__ == "__main__":
    main()

Re: Feature Request - Enable/Disable/Trigger Wireless Projection Connection via API

Posted: Sun Aug 16, 2026 2:43 am
by dsparks156
Oh, I totally forgot auto start could just, be disabled... Well, I (the LLM I'm bossing around) will get to work then on adding that to my existing car management scripts.