Supereg / homebridge-http-switch

Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
ISC License
219 stars 36 forks source link

Help with statusPattern #75

Closed BertoTavira closed 3 years ago

BertoTavira commented 3 years ago

Hi there! First thanks for the plug-in and the hard work, it is very useful :)

I plan to create a switch for mi Yi camera that turns on/off the RTSP service. I have all working but cannot create a regex for my statusPattern.

I’ve tried to change other examples and users patterns and see if I could understand it better, but seems to complex for me.

Could please somebody help me?

This is the config json of my camera:

{ "HTTPD":"yes", "TELNETD":"no", "SSHD":"yes", "FTPD":"yes", "BUSYBOX_FTPD":"no", "DISABLE_CLOUD":"yes", "REC_WITHOUT_CLOUD":"yes", "MQTT":"yes", "RTSP":"yes", "RTSP_STREAM":"high", "RTSP_AUDIO":"no", "ONVIF":"no", "ONVIF_WSDD":"no", "ONVIF_PROFILE":"high", "ONVIF_WM_SNAPSHOT":"no", "NTPD":"yes", "NTP_SERVER":"pool.ntp.org", "PROXYCHAINSNG":"no", "SWAP_FILE":"no", "RTSP_PORT":"554", "ONVIF_PORT":"80", "HTTPD_PORT":"8080", "USERNAME":"", "PASSWORD":"", "TIMEZONE":"CET-1CEST,M3.5.0,M10.5.0/3", "FREE_SPACE":"0", "FTP_UPLOAD":"no", "FTP_HOST":"", "FTP_DIR":"", "FTP_DIR_TREE":"no", "FTP_USERNAME":"", "FTP_PASSWORD":"", "FTP_FILE_DELETE_AFTER_UPLOAD":"", "SSH_PASSWORD":"xxxxxx", "HOSTNAME":"xxxxxx", "NULL":"NULL" }

And this is my homebridge config:

{ "accessory": "HTTP-SWITCH", "name": "RTPS YiHome", "onUrl": { "url": "http://ip:8080/cgi-bin/service.sh?name=rtsp&action=start&param1=high" }, "offUrl": { "url": "http://ip:8080/cgi-bin/service.sh?name=rtsp&action=stop&param1=high" }, "statusUrl": { "url": "http://ip:8080/cgi-bin/get_configs.sh?conf=system", "method": "GET" }, "pullInterval": 5000, "debug": true, "statusPattern": "\"RTSP\":yes" },

And my homebridge log: 18915661-0660-49D1-9047-4704F5D6FDD0

Thanks for your time!

BertoTavira commented 3 years ago

I think I got it just trying and checking...

"statusPattern": "\"RTSP\":\"yes"

Now homebridge log shows switch ON :) Seemed to be a missing character, IDK. This tool helped me: https://regexr.com/

Supereg commented 3 years ago

I assume this is solved?

BertoTavira commented 3 years ago

Yes, it is, regex now find the string, thanks.

My problem now is different: I can turn on/off RTSP stream (checked in Home app and in homebridge log) but camera system status config doesn’t get updated, it always shows "RTSP":"yes” and as result button status is always on.

I’m thinking to create now two stateless buttons (my idea is to create automations to disable RTSP when I’m at home)

Anyway, again, thanks for the plugin!