niceboygithub / AqaraCamera

Aqara Camera G3 integration for Home Assistant
27 stars 6 forks source link

[Idea] Webserver? #3

Open Wh1terat opened 2 years ago

Wh1terat commented 2 years ago

Never been a fan of poking devices via telnet constantly.

What about grabbing a busybox binary with httpd compiled and using cgi? e.g

#!/bin/sh

while IFS= read -r -d '&' KEYVAL && [[ -n "$KEYVAL" ]]; do
case ${KEYVAL%=*} in
        prop) PROP=${KEYVAL#*=} ;;
    esac
done <<END
$(echo "${QUERY_STRING}&")
END

if [ -z "$PROP" ]; then
    PROP="full"
fi

RES=`agetprop "$PROP"`
IS_JSON=`echo "$RES" | grep -c "^{"`

if [[ "$IS_JSON" -gt 0 ]]; then
    printf "Content-type: application/json\n\n"
else
    printf "Content-type: text/plain\n\n"
fi

echo "$RES"
x@x:[~]$ curl -v "http://x.x.x.x/cgi-bin/get_prop.sh?prop=ro.sys.fw_ver"
*   Trying x.x.x.x...
* TCP_NODELAY set
* Connected to x.x.x.x (x.x.x.x) port 80 (#0)
> GET /cgi-bin/get_prop.sh?prop=ro.sys.fw_ver HTTP/1.1
> Host: x.x.x.x
> User-Agent: curl/7.54.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-type: text/plain
<
3.3.4

Could be nice for your ptz control stuff, getting uptime, sdcard usage, etc etc.

niceboygithub commented 2 years ago

It is good but need a lot of efforts.

I will add features one by one.

I studied yi-hack-mstar before. It is a good example.

niceboygithub commented 2 years ago

image image

sdavides commented 1 month ago

Hi, is this idea in progress?

sdavides commented 1 month ago

I added many functions via static binary, such as crontab, sshd, nginx fcgiwrap and php, but I don't know what the command is to move ptz for example.

Can you help me or send me the web page you created?

sdavides commented 1 month ago

found /data/bin/mi_motor

sdavides commented 1 month ago

I created a guide for setting nginx with cgi and took your getprop page. thank you

https://github.com/sdavides/AqaraG3-armv7-binary

niceboygithub commented 1 month ago

Please reference to another solution, using miio socket. There are two approaches.

https://github.com/niceboygithub/AqaraGateway/issues/242

Using miio socket, you can control/access G3 to set/get more settings of G3.

sdavides commented 1 month ago

Thanks for the reply, I didn't know this method with mii socket-mqtt. I tried it but I don't need to have the mqtt messages and it doesn't seem to capture all the messages.

My project on git whith nodered with post requests works best for me.

I was just looking for a command to move the camera and "/data/bin/mi_motor" works fine. Thank you