helgeerbe / picframe

Picture frame viewer for raspi, controlled via mqtt and automatticly integrated as mqtt device in homeassistant.
MIT License
110 stars 32 forks source link

Overview of http commands available? #417

Open sapnho opened 14 hours ago

sapnho commented 14 hours ago

Do we have a primer on HTTP commands for PictureFrame like Helge did for MQTT?

I am just playing around with a few ideas where I need to send HTTP commands to PictureFrame but somewhat my syntax isn't quite right yet.

paddywwoof commented 12 hours ago

Good idea, I will do something later. The commands are basically the same as the function names in the model or control file I think.Paddy

sapnho commented 8 hours ago

I used the directory command here: https://www.thedigitalpictureframe.com/expand-your-digital-picture-frame-use-cases-with-pi3d-integrated-usb-media-stick-support/

Tried to figure out the full list with your HTTP frontend and Google Console but that only worked for a few commands. Things like next/back I couldn't figure out, pause or display on/off was easy.

jgodfrey commented 6 hours ago

Hi Wolfgang,

Paddy's the expert here but until he chimes in you can always open Chrome dev tools, go to the network tab, and see what the existing HTML web page sends with each command. For example, here are a few for reference.

image

Just provide the IP address and port of your frame along with the command. So, something like this:

http://192.168.0.150:9000/?next={}

paddywwoof commented 4 hours ago

Thanks Jeff, that's a really useful way of hacking all kinds of web accessible gadgets such as solar inverters etc etc. Chrome (or firefox) can basically give you the recipe for what you need to feed from your DIY app.

The HTTP interface gets a list of methods from the Controller object (see https://github.com/helgeerbe/picframe/blob/654006514513ddeb19f5ed16ba9736d0fb20f7f3/src/picframe/interface_http.py#L120) .. and here's the file listing https://github.com/helgeerbe/picframe/blob/main/src/picframe/controller.py

You can then send the method name = method argument as GET arguments to the HTTP server. i.e. like Jeff says http://192.168.0.150:9000/?next={} The methods are listed below (true can be upper or lower case and many things that seem plausible such as true, on, yes, false, off, no):

@property setters - these don't need a dict of arguments as they can 'just' set the value

?paused=true
?subdirectory=holiday2019
?date_from=2020/09/01
?date_to=2024/12/01
?display_is_on=true
?clock_is_on=true
?shuffle=true
?fade_time=10
?time_delay=30
?brightness=0.5
?matting_images=0.0
?location_filter=eldwick
?tags_filter=birthday

non @property methods must be passed arguments as dict of {"key1":val1, "key2":val2...   etc}
non argument methods
?back={}
?next={}
?delete={}
?refresh_show_text={}
?purge_files={}
?get_number_of_files={}
?get_directory_list={}
?get_current_path={}

methods with arguments
?set_show_text={"txt_key":"title", "val":true} // text_key can be "title", "caption", "name", "date", "location", "folder"
?text_is_on={"txt_key":"title"}

PS I'm doing this from the file listing as I'm away from an actual picframe to test on. I will double check the actual syntax when I'm home!!!